Help needed Getting WA in KPRIME

I am getting WA in Qn KPRIME. I am not able to spot my error , please help.
I am not able to find any erronious case.
QN- CodeChef: Practical coding for everyone
Here is my code :

    #include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
ll p[100011]={0};
ll binasea(ll arr[],ll n,ll k)
{
    ll l = 0, r = n-1;
    ll m;
    while (l <= r)
    {
        m = (r + l)/2;
        if (arr[m] == k)
        {
            return m;
        }
        else if (arr[m] > k)
            r = m-1;
        else
            l = m + 1;
    }
    return -1;
}
void pm()
{   
    ll j;
    for(ll i=2;i<sqrt(100001);i++)
    {
        if(p[i]==0)
        {
            for( j=2*i;j<100001;j+=i)
            {
                p[j]++;
            }
        }
    }
}
int main()
{
    ll t,n=0,i,j,k=0;
    pm();
    vector<ll> a,b,c,d,e;
    ll a1,b1;
    for(int i=2;i<100001;i++)
    {
        if(p[i]==0)p[i]=1;
        if(p[i]==1)a.pb(i);
        if(p[i]==2)b.pb(i);
        if(p[i]==3)c.pb(i);
        if(p[i]==4)d.pb(i);
        if(p[i]==5)e.pb(i);
    }
    cin>>t;
    while(t--)
    {
        cin>>a1>>b1>>k;
        n=0;
        switch (k)
        {
            case 1:n=lower_bound(a.begin(),a.end(),b1)-lower_bound(a.begin(),a.end(),a1)+1;
                    if(binasea(&a[0],a.size(),b1)==-1)n--;break;
                    
            case 2:n=lower_bound(b.begin(),b.end(),b1)-lower_bound(b.begin(),b.end(),a1)+1;
                    if(binasea(&b[0],b.size(),b1)==-1)n--;break;
            
            case 3:n=lower_bound(c.begin(),c.end(),b1)-lower_bound(c.begin(),c.end(),a1)+1;
                    if(binasea(&c[0],c.size(),b1)==-1)n--;break;
            
            case 4:n=lower_bound(d.begin(),d.end(),b1)-lower_bound(d.begin(),d.end(),a1)+1;
                    if(binasea(&d[0],d.size(),b1)==-1)n--;break;
            
            case 5:n=lower_bound(e.begin(),e.end(),b1)-lower_bound(e.begin(),e.end(),a1)+1;
                    if(binasea(&e[0],e.size(),b1)==-1)n--;break;
        }
        cout<<n<<" \n";
    }
return 0;
}