I was trying to find the nth square free semi prime.(N <= 2 \* 10^6). I have the following code to try to do it. I keep getting a runtime error here, I can not figure out why.

Here is what I have done.

```
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 3000000

int main()
{
    bool* prime = new bool[N];
    int* primes = new int[N];
    int* semiprimes = new int[2000005];

    for(int i=0; i < N ; i++) prime[i] = true;
    int cnt = 0;
    for(int i=2 ; i < N ; i++)
    {
        if(prime[i])
        {
            primes[cnt++] = i;
            for(int j = i; j < N ; j+= i)
                prime[j] = false;
        }
    }

    int i, j, k = 1;
    int p, q, current_limit;
    int target = 2000000;
    for (i = 0, p = primes[i]; p < target; i++)
    {
        current_limit = target/p;
        for (j = i + 1, q = primes[j]; q <= current_limit; j++)
        {
            k++;
            semiprimes[k++] = p*q;
        }
    }
    printf("%d\n",k);

    int t;

    scanf("%d",&t);
    int n;
    while(t--)
    {
        scanf("%d",&n);
        printf("%d\n",semiprimes[n]);
    }

    delete[] prime;
    delete[] semiprimes;
    delete[] primes;

    return 0;
}

```

Could someone please tell me what I am doing wrong.