TLE on oddbin

May I ask why is my solution getting TLE? I generated a few random test cases and my solution seems to run within 2 * time use by setter’s solution. Below is my solution.
http://pastebin.com/ECdkfk9r

//