title: Wrong Answer python3.6
body: <blockquote>
  <p>You are given a set S and Q queries. Initially, S is empty. In each query:</p>
  <p>You are given a positive integer X.<br />
  You should insert X into S.<br />
  For each y∈S before this query such that y≠X, you should also insert y⊕X into S (⊕ denotes the XOR operation).
  Then, you should find two values E and O: the number of elements of S with an even number of 1's and with an odd number of 1's in the binary representation, respectively.</p>
  </blockquote>
  <p>I have tried splitting the problem into smaller subproblems but it seems to exceed time because of large input size and large list size. Any suggestion into the code and further optimization will be very helpful.I have mow used set but the expected output is not as same as my output. Any suggestions as where I am going wrong in the solution code..?</p>
  <pre><code>s=set()
  def fun(n,q):
      c=0
      cc=0
      s.add(n)
      for k in range(len(list(s))):
          if list(s)[k]!=n:
              s.add((list(s)[k])^n)
              
      for k in s:
          if bin(k)[2::].count('1')%2==0:
              c+=1
          else:
              cc+=1
      print(c,cc)
      
      
  for _ in range(int(input())):
      q=int(input())
      for j in range(q):
          n=int(input())
          fun(n,q)
   
  </code></pre>
  <p>Example Input:</p>
  <pre><code>1
  3
  4
  2
  7
  </code></pre>
  <p>Example Output:</p>
  <pre><code>0 1
  1 2
  3 4
  </code></pre>