Code not giving any output for very long input

In deepak and primes problem my code is not
giving any output for very long input and fails for one or two test cases
link-https://ide.codingblocks.com/s/80889

hey @rishu7865, please increase the size of N and in various for loop make it <n instead of <=.
I have made the changes on your code and mentioned them as comment. You can check it here.