All test cases are going wrong

following is my code:’

@Mudit809
store all the primes in a vector
so that for each test case u do not have to recomute
that`s taking time

refer to the below code