RRATING TLE

Although i am using heaps to solve this problem.but i am getting TLE.Can anybody tell me the reason for same.Here is my code:-

You should also add the link to the question. Here it is Restaurant Rating