Prime visits Getting Time Limited Exceeded ERROR

My code works fine and passed all test cases except one and give TLE Error
//Prime visits
#include
using namespace std;
int main(){

int flag=1,n,i,t,count=0,j,a,b;
cin>>t;
while(t–){
cin>>a;
cin>>b;
count=0;
for(i=a;i<=b;++i){
if(i==1||i==0)
continue;
flag=1;
for(j=2;j<=i/2;++j){
if(i%j==0){
flag=0;
break;
}
}
if(flag==1)
count++;
}
cout<<count<<endl;
}
}

hey @dsingh200021, contraints are very high in the question, please change all int to long long int.