title: How to improve Python code speed
body: <p>I was solving this python challenge <a href="http://coj.uci.cu/24h/problem.xhtml?abb=2634" rel="nofollow">http://coj.uci.cu/24h/problem.xhtml?abb=2634</a> and this is my answer</p>
  
  <pre><code>c = int(input())
  l = []
  for j in range(c) :
      i = raw_input().split()[1].split('/')
      l.append(int(i[1]))
  for e in range(1,13) :
      print e , l.count(e)
  </code></pre>
  
  <p>But it was not the fastest python solution, so i tried to find how to improve the speed and i found that  xrange was faster than range. But when i tried the following code it was actually slower</p>
  
  <pre><code>c = int(input())
  l = []
  for j in xrange(c):
      i = raw_input().split()[1].split('/')[1]
      l.append(i)
  for e in xrange(1,13) :
      print e , l.count(`e`)
  </code></pre>
  
  <p>so i have 2 questions :</p>
  
  <ol>
  <li>How can i improve the speed of my script</li>
  <li>Where can i find information on how to improve python speed</li>
  </ol>
  
  <p>When i was looking for this info i found sites like this one <a href="https://wiki.python.org/moin/PythonSpeed/PerformanceTips" rel="nofollow">https://wiki.python.org/moin/PythonSpeed/PerformanceTips</a>
  but it doesn't specify for example, if it is faster/slower to split a string multiple times in a single line or in multiple lines, for example using part of the script mentioned above :</p>
  
  <pre><code>i = raw_input().split()[1].split('/')[1]
  </code></pre>
  
  <p>vs</p>
  
  <pre><code>i = raw_input().split()
  i = i[1].split('/')
  i = i[1]
  </code></pre>
  
  <p>Edit : I have tried all your suggestions but my first answer is still the fastest and i don't know why. My firs answer was 151ms and @Bakuriu's answer was 197ms and my answer using collections.Counter was 188ms.</p>
  
  <p><strong>Edit 2 : Please disregard my last edit, i just found out that the method for checking your code performance in the site mentioned above does not work, if you upload the same code more times the performance is different each time, some times it's slower and sometimes faster</strong></p>