Deepak and primes problem why i am getting run error in this

// CPP program to the nth prime number

#include <bits/stdc++.h>
using namespace std;

// initializing the max value
#define MAX_SIZE 10000005

void SieveOfEratosthenes(vector &primes)
{

bool IsPrime[MAX_SIZE]; 
memset(IsPrime, true, sizeof(IsPrime)); 

for(int i = 4;i<MAX_SIZE;i+=2)
    IsPrime[i] = false;

for (int p = 3; p * p < MAX_SIZE; p+=2) 
{ 
	
	if (IsPrime[p] == true) 
	{ 
	
		for (int i = p * p; i < MAX_SIZE; i += p) 
			IsPrime[i] = false; 
	} 
} 
IsPrime[0] = false;
IsPrime[1] = false;
IsPrime[2] = true;
// Store all prime numbers 
for (int p = 2; p < MAX_SIZE; p++) 
if (IsPrime[p]) 
		primes.push_back(p); 

}

// Driver Code
int main()
{
// To store all prime numbers
vector primes;

// Function call 
SieveOfEratosthenes(primes); 

int n;
cin>>n;
cout<<primes[n];
return 0; 

}

@Nitishkumar9711 you have o print 5000000th prime number that lies around 10^8 so your max size should be this, taking an integer array of this much size can cause memory error for this problem so you should take a bool array to check prime,

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.