What is wrong with this code?

Problem code puppygcd of ltime26

I followed the approach of the editorial and still am getting tle. Can you plz tell me why? Similar solutions in practice session got ac.


I also need help with preprocessed array. How was it calculated? I applied a bruteforce to generate it but it is taking a lot of time ( don’t know exact as i got bored and stopped the process in between). In my solution i used the array in authors code.

@dragonemperor I am also confused how the preprocessed array is calculated. Why isn’t anybody answering it?