Buggy python submission (verdict: Time Limit Exceeded):
while True:
 try:
  d = 0
  a = int(input())
  for c in range(2,a):
   for b in range(2,c):
    if c % b == 0:
      break
   else:
     d += 1

  print d
 except EOFError:
   break

Fixed submission:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python
import sys
 
list=1000000*[1]
 
list[0] = 0
list[1] = 0
for i in range(1,1000000):
    if list[i] == 1:
        for j in range(i*i,1000000,i):
            list[j] = 0
 
for i in range(2,1000000):
    list[i] += list[i-1]
     
for line in sys.stdin:
    a = int(line)
    print list[a]

Buggy python submission (verdict: Time Limit Exceeded):
while True:
 try:
  d = 0
  a = int(input())
  for c in range(2,a):
   for b in range(2,c):
    if c % b == 0:
      break
   else:
     d += 1

  print d
 except EOFError:
   break

Fixed submission:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python
import sys
 
list=1000000*[1]
 
list[0] = 0
list[1] = 0
for i in range(1,1000000):
    if list[i] == 1:
        for j in range(i*i,1000000,i):
            list[j] = 0
 
for i in range(2,1000000):
    list[i] += list[i-1]
     
for line in sys.stdin:
    a = int(line)
    print list[a]

Buggy python submission (verdict: Time Limit Exceeded):
while True:
  t = []
  try:
    a = int(input())
    for n in range(2,a+1):
      for x in range(2,n):
        if n % x == 0:
          break
      else:
        t.append(n)

    print len(t[0:])
  except EOFError:
    break

Fixed submission:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python
import sys
 
list=1000000*[1]
 
list[0] = 0
list[1] = 0
for i in range(1,1000000):
    if list[i] == 1:
        for j in range(i*i,1000000,i):
            list[j] = 0
 
for i in range(2,1000000):
    list[i] += list[i-1]
     
for line in sys.stdin:
    a = int(line)
    print list[a]

Buggy python submission (verdict: Time Limit Exceeded):
while True:
  t = []
  b = 0
  try:
    a = int(input())
    for n in range(2,10000):
      for x in range(2,n):
        if n % x == 0:
          break
      else:
        t.append(n)

    for b in range(1000):
      if t[b] > a:
        print len(t[0:b])
        break
  except EOFError:
    break

Fixed submission:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python
import sys
 
list=1000000*[1]
 
list[0] = 0
list[1] = 0
for i in range(1,1000000):
    if list[i] == 1:
        for j in range(i*i,1000000,i):
            list[j] = 0
 
for i in range(2,1000000):
    list[i] += list[i-1]
     
for line in sys.stdin:
    a = int(line)
    print list[a]

Buggy python submission (verdict: Runtime Error):
t =[]
for n in range(2,10000):
  for x in range(2,n):
    if n % x == 0:
      break
  else:
    t.append(n)

while True:
  try:
    b=0
    a = int(input())
    for b in range(10000):
      if t[b] > a:
        print len(t[0:b])
        break
  except EOFError:
    break

Fixed submission:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python
import sys
 
list=1000000*[1]
 
list[0] = 0
list[1] = 0
for i in range(1,1000000):
    if list[i] == 1:
        for j in range(i*i,1000000,i):
            list[j] = 0
 
for i in range(2,1000000):
    list[i] += list[i-1]
     
for line in sys.stdin:
    a = int(line)
    print list[a]

Buggy python submission (verdict: Runtime Error):
t = []
for a in range(2,10000):
  for n in range(2,a):
    if a % n == 0:
      break
  else:
    t.append(a)

while True:
  try:
    z = int(input())
    for w in range(1000000):
     if t[w] > z:
       break

    print len(t[0:w])
  except EOFError:
    break

Fixed submission:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python
import sys
 
list=1000000*[1]
 
list[0] = 0
list[1] = 0
for i in range(1,1000000):
    if list[i] == 1:
        for j in range(i*i,1000000,i):
            list[j] = 0
 
for i in range(2,1000000):
    list[i] += list[i-1]
     
for line in sys.stdin:
    a = int(line)
    print list[a]

Buggy python submission (verdict: Runtime Error):
t =[]
for n in range(2,10000):
  for x in range(2,n):
    if n % x == 0:
      break
  else:
    t.append(n)

while True:
  try:
    a = int(input())
    for b in range(100000):
      if t[b] >= a:
        break


    print len((t[0:b]))
  except EOFError:
    break

Fixed submission:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python
import sys
 
list=1000000*[1]
 
list[0] = 0
list[1] = 0
for i in range(1,1000000):
    if list[i] == 1:
        for j in range(i*i,1000000,i):
            list[j] = 0
 
for i in range(2,1000000):
    list[i] += list[i-1]
     
for line in sys.stdin:
    a = int(line)
    print list[a]