please help with time complexity

time-complexity

#1

Can anyone please explain me why first code https://www.codechef.com/viewsolution/21531950 gets TLE while the second one https://www.codechef.com/viewsolution/21531975 doesn’t. The only difference between them is in loop condition. In first its (i*i)<=d while in second its i<=(d/i).


#2

Overflow?
Try long long.