title: python prime numbers Sieve of Eratosthenes
body: <p>Hi can anyone tell me how to implement Sieve of Eratosthenes within this code to make it fast? Help will be really appreciated if you can complete it with sieve. I am really having trouble doing this in this particular code. </p>
  
  <pre><code>#!/usr/bin/env python
  import sys
  
  T=10 #no of test cases
  t=open(sys.argv[1],'r').readlines()
  
  import math
  def is_prime(n):
      if n == 2:
          return True
      if n%2 == 0 or n &lt;= 1:
          return False
      sqr = int(math.sqrt(n)) + 1
      for divisor in range(3, sqr, 2):
          if n%divisor == 0:
              return False
      return True
  
  #first line of each test case
  a=[1,4,7,10,13,16,19,22,25,28]
  count=0
  for i in a:
  
      b=t[i].split(" ")
      c=b[1].split("\n")[0]
      b=b[0]
  
      for k in xrange(int(b)):
          d=t[i+1].split(" ")
  
          e=t[i+2].split(" ")
          for g in d:
              for j in e:
                  try:
                      sum=int(g)+int(j)
                      p=is_prime(sum)         
                      if p==True:
                          count+=1
                          print count
                      else:
                          pass
                  except:
                      try:
                          g=g.strip("\n")
                          sum=int(g)+int(j)
                          p=is_prime(sum)
                          if p==True:
                              count+=1
                              print count
                          else:
                              pass
                      except:
                          j=j.strip("\n")
                          sum=int(g)+int(j)
                          p=is_prime(sum)
                          if p==True:
                              count+=1
                              print count
                          else:
                              pass
  
  print "Final count"+count
  </code></pre>