TLE in MAXPR

Why is the following solution giving TLE?
http://www.codechef.com/viewsolution/4032512

even my solution to MAXPR of complexity O(200 * N) gets TLE … please look
http://www.codechef.com/viewsolution/4077145

@krooonal and @sansid - even my O(200n) solution gave TLE. But, O(100n) gets AC!

i think ,TLE because u are using mod function so many times…use mod function this way…
“if(ans>mod)
ans%=mod;”…

thank you @r4r313 for suggesting this method. the code finally ran CodeChef: Practical coding for everyone.

but i am really frustrated with this. Such strict time limits must not be there. My algo and execution was correct. The only thing that made the difference was MOD . I personally request codechef to go through all the solutions again and next time make sure that such strict time limits are taken care off.