1 out of 3 test cases is showing Run error.
#include<iostream>
#define ll long long int
using namespace std;
int prime_visits(int sieve[], int a, int b){
for(int i=3; i<=b; i+=2){
sieve[i] = 1;
}
for(int i=3; i<=b; i+=2){
if(sieve[i] == 1){
for(ll j=i*i; j<=b; j+=i){
sieve[j] = 0;
}
}
}
sieve[2] = 1;
int cnt = 0;
for(int i=a; i<=b; i++){
if(sieve[i] == 1){
cnt++;
}
}
return cnt;
}
int main() {
int t;
cin>>t;
while(t--){
int a,b;
cin>>a>>b;
int sieve[1000005]{0};
cout<<prime_visits(sieve,a,b)<<endl;
}
return 0;
}