For this problem : Product of divisors,

These are 2 of my solutions :

Solution 1 (This solution gave a TLE)

Solution 2 (This one gave an AC)

The only difference between the 2 is that I have declared all the variables at the beginning in solution 2… Does declaring variables in between slow down the program? (Or is there any other reason for the TLE?)