Prime Visits Question

My code is not able to pass the last 2 test cases. I am not able to find any mistake in it. Here is the code link
https://ide.codingblocks.com/s/333046.

hell0 @nikhil015

image
use long long for i .

still not passed the last 2 test cases

due to high memory usage it is not working.
use int for ur prime vector and declare it of size 10^6+1.

ur updated code->