Fail two test cases

#include
using namespace std;
#define ll long long
//long long a[1000000];
long long a[90000000];

//PRIME SIEVE & OPTIMISATIONS

void primeSieve(ll *p,ll n){

p[0] = p[1] = 0;
p[2] = 1;

//Let us Mark all Odd Numbers as Prime(Initialisations)
for(ll i=3;i<=n;i+=2){
    p[i] = 1;
}

//Sieve Login to mark non prime numbers as 0
//1. Optimsation : Iterate only over odd Numbers
for(ll i=3;i<=n;i+=2){
    
    if(p[i]){
        //Mark all the multiples of that number as not prime.
        //2. Optimisation Take a jump of 2i starting from i*i
        for(ll j=i*i;j<=n;j+=2*i){
            p[j] = 0;
        }
    }

}
int k=0;
for(int i=2;i<1000000;++i){
    if(p[i]){
        a[k]=i;
        k++;
    }
}
return;

}

int main() {
// ll N = 1000001;
ll N=90000000;
ll p[N] = {0};
primeSieve(p,N-1);

ll n;

cin>>n;
cout<<a[n-1];

}

@Rishabhsharmwhen your are storing prime numbers in array a[ ] you should run your for loop upto n, running upto 10^6 will give you wrong answer as for bigger number it can exceed 10^6.

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.