Why is this giving runtime error RE (SIGSEGV) ? https://www.codechef.com/LP1TO201/problems/IMDB

#include
#include
using namespace std;

int main() {
// your code goes here
int t;
cin>>t;

while(t--){
    long long n,x,max=INT_MIN;
    cin>>n>>x;

    long long s[1000],r[1000];
    
    for(int i=1;i<=n;i++){
        cin>>s[i]>>r[i];
    }
    
    for(int i=1;i<=n;i++){
        if(r[i]>max && s[i]<=x){
            max=r[i];
        }
    }
    
    cout<<max<<endl;
    
}
return 0;

}