Time limit exceeded

i am getting TLE in this question
can you tell my mistake in this code?

instead of calling sieve function every time
call it ones only

Modified Code