Showing TLE in my code

i have used seive algo for this question but my code is showing TLE can you please tell me why

MY CODE:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define M 2000000
int main()
{
ll t;
cin>>t;
while(t–)
{
ll a,b;
cin>>a>>b;
ll ref[M]={0};
for(ll i=0;i<M;i++)
ref[i]=1;
ref[0]=ref[1]=0;
for(ll i=2;ii<M;i++)
{
if(ref[i]==1)
for(ll j=2;i
j<M;j++)
ref[i*j]=0;
}
ll count=0;
for(ll i=a;i<=b;i++)
{
if(ref[i]==1)
count++;
}
cout<<count<<endl;
}
}

Plz send your code by saving on ide