Baised Standing Code error


spoj link : https://www.spoj.com/problems/BAISED/

my code is showing TLE error while sumbission
on spoj .how to optimize my solution ?

hi @mandeepchohan96 you can refer to this approach https://ide.codingblocks.com/s/333112