Help Required

I am getting partial correct …rest TLE …please help me with this how to optimize further
Solution Link

Problem Link