I tried to code on my own but still not working

i tried to code on my own but still not working
code- https://ide.codingblocks.com/s/248094

could you please check my code whats wrong in it

@anubhavb11
You can check your code it is not matching for sample test case also.
I think your prime function is also wrong, you are checking prime for arr[i] but initially there is nothing present in arr[].
The default size for arr[], stack a and b does not mean anything, it is not matching with given constraints. Also q nothing is said so you can taking something by yourself, take it after getting the input of q.

Tip:- better use sieve() for precomputing and storing some prime numbers.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.