PRIME1 TLE on Codechef but AC on SPOJ

Hello! I have just submitted the solution to the problem PRIME1 on SPOJ with AC. But on codechef when I submit it gives TLE. Here is the link. http://ideone.com/ZGIRgq. Please have a llok and help me.

The reason could be that codechef uses Pyramid clusters of SPOJ,which are the old ones, whereas SPOJ uses Cube clusters, which they introduced a few years back.

Submissions on Cube run 30 to 50 times faster than Pyramid.