Programming Challenge Code taking too much time
<p>I wrote the following code for <a href="http://acm.timus.ru/problem.aspx?space=1&amp;num=1196" rel="nofollow">this problem.</a></p>

<pre><code>prof = sorted([int(input()) for x in range(int(input()))])
student = sorted([int(input()) for x in range(int(input()))])

prof_dates = len(prof)
stud_dates = len(student)

amount = 0

prof_index = 0
stud_index = 0

while stud_index &lt; stud_dates and prof_index &lt; prof_dates:
    if student[stud_index] == prof[prof_index]:
        amount += 1
        stud_index += 1

    elif student[stud_index] &gt; prof[prof_index]:
        prof_index += 1

    elif student[stud_index] &lt; prof[prof_index]:
        stud_index += 1


print(amount)
</code></pre>

<p>But the code is producing a Time Limit Exceeded Error. Earlier I had tried using a <code>in</code> for every item in student but it produced a TLE and I believe that's because the <code>in</code> statement is <code>O(n)</code>. So, I wrote this code whose steps required are roughly equal to the sum of the lengths of both the lists. But this is also producing a TLE. So, what changes should I make in my code. Is there some particular part which has a high time expense?</p>

<p>Thanks.</p>