Getting runtime error , please help find error


#1

vector Solution::primesum(int A) {
vector isPrime(A, true);
vector prime;
vector p;
isPrime[0] =false;
isPrime[1] = false;
for(int i=2;i<A;i++){
if(isPrime[i]){
prime.push_back(i);
for(long long int j = i*i;j<A;j++){
if(j%i == 0){
isPrime[j] = false;
}
}
}
}

for(int k = 0;k<prime.size();k++){
    if(isPrime[A -prime[k] ]){
    p.push_back(prime[k]);
    p. push_back(A-prime[k]);
    break;
    }
}
return p;

}


#2
int isPrime(int A) {
    int k=sqrt(A);
    if(A==1)return 0;
    if(A==2)return 1;
    for(int i=2;i<=k;i++)
    {
        if(A%i==0)return 0;
    }
    return 1; 
}


vector<int> Solution::primesum(int A) {
    
    vector<int> v;

    
    for(int i=2;i<=A/2;i++)
    {
        if(isPrime(i) && isPrime(A-i))
        {
            v.push_back(i);
            v.push_back(A-i);
            break;
        }
    }
    return v;
}

#3

For checking prime number your algorithm is taking O(n) time, but it can be reduced to O(sqrt(n) time. use condition i*i<=k.