Can anyone help me in finding why this code is giving memory limit exceded


#1
    vector<int>a(A,1);
    vector<int>ans;
    
    a[0] = -1;
    a[1] = -1;
    
    for(int i = 2; i<A; i+=2){
        a[i] = -1;
    }
        a[2] = 1;
        
    for(int i = 3;i*i<A; i+=2){
        for(int j = i*i ; j<A; j+=i){
            a[j] = -1;
        }
    }
    
    for(int i = 0;i*i<A;i++){
        if(a[i] == 1 and a[A-1] == 1){
   
                ans.push_back(i);
                ans.push_back(A-i);
                return ans;
            
        }
    }
    
    
}