title: How do I optimize this code involving counting without any libraries or modules?
body: <p>This is part of a preparation exercise in a French coding contest I'm participating in (Algoréa). Once again, this isn't the real thing, just the warm-up exercise.</p>
  
  <p>The program is supposed to receive a bunch of positions as integers, and needs to output greatest amount of time a position is passed. For example, 1 3 2 6 2 means you start at 1, then go to 3, passing by all the positions in between, then going back to 2, then 6, and so on. Here the output would be 4, as the second position has been passed 4 times.</p>
  
  <pre><code>def move(x1, x2, l):
      if x1 &lt; x2:
          l.extend(range(x1, x2))
      else:
          l.extend(range(x2, x1))
  
  
  positions = []
  for i in range(int(input())):
      positions.append(int(input()))
  
  p = [] # positions, but instead of finding [1, 3] you would find [1, 2, 3]
  for i in range(len(m) - 1):
      move(m[i], m[i + 1], p)
  
  result = [] # count how many times each space was passed
  for i in range(max(m)):
      wall.append(result.count(i))
  
  print(max(result))
  </code></pre>
  
  <p>This is easy, but to earn the maximum amount of points, you need to optimize the program as much as you can... This is where I'm stuck. I initially made it just increment the corresponding indexes in a list each time they were passed, but switched to counting each value at the end as you see here, thinking it might be faster, but it wasn't. I couldn't find any answers to this anywhere (the afore-mentioned preparation exercises are those from the real contest in 2018 so I thought I might been able to find something).</p>
  
  <p>I can't use any libraries or modules, not even built-in ones, so I can only use <code>list.count()</code> as far as I'm aware.</p>
  
  <p>Is there anything that sticks out here that could be done better? I understand that this question might be hard to answer.</p>