Squared Subsequences

Got tle but how someone please help.
link

I read the whole editorial and tried to implement this one please some help