TLE in 4th case in Sum of perfect squares

Please find the link of my code here:

see this here to solve the tle: