title: HackerRank Python - some test cases get "Terminated due to timeout", how can i optimize the code?
body: <p>Currently, on HackerRank, I am trying to solve the <a href="https://www.hackerrank.com/challenges/circular-array-rotation?h_r=next-challenge&amp;h_v=zen" rel="nofollow">Circular Array Rotation</a> problem. Most of the test cases work, but some are "Terminated due to timeout".</p>
  
  <p>How can I change my code to optimise it?</p>
  
  <pre><code>#!/bin/python3
  
  import sys
  
  
  n,k,q = input().strip().split(' ')
  n,k,q = [int(n),int(k),int(q)]
  a = [int(a_temp) for a_temp in input().strip().split(' ')]
  
  m = []
  for a0 in range(q):
      m.append(int(input().strip()))
  
  for i in range (0, k % n):
      temp = a[n-1]    # Stores the last element temporarily
      a.pop(n-1)       # Removes the last element
      a = [temp] + a   # Appends the temporary element to the start (prepends)
  
  
  for i in range (0, q):
      print(a[m[i]])
  </code></pre>