Got TLE’d 6 times in a very simple problem , tried 2-3 different approaches . Can anyone help me to understand what costed me TLE’s

Link to my 6 codes

link to the question

https://www.codechef.com/PEND2020/problems/ITGUY03

Thanks in Advance for the help.You may help in 1 code also.