Problem - Deepak & Primes (Sieve) : Please , suggest what i am missing

I am trying to solve https://online.codingblocks.com/player/2872/content/795?s=385&tab=submissions
but i am getting tle and runtime exception .
I am trying to solve it using prime sieve

https://ide.codingblocks.com/#/s/15365

https://ide.codingblocks.com/#/s/15537
I have commented the changes,once you see you will understand.