Why this code give me run time error when i run same code in sublime text it give right answer

#include<bits/stdc++.h>
#define ll long long int
#define w(tc) cin>>(tc);while(tc–)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define debuge(x) cout<<#x<<" “<<x<<”\n"

using namespace std;
int main(){

ios::sync_with_stdio(0);
cin.tie(0);

#ifndef ONLINE_JUDGE
//for getting input from input.text
freopen(“input.txt”, “r”, stdin);
//for getting output from output.text
freopen(“output.txt”, “w”, stdout);
#endif
ll tc;
cin>>tc;
while(tc–){
ll n,s,answer=0;
cin>>n>>s;
int A[n+1];
for(int i=0;i<=n;i++){
A[i]=1;
}
for(int i=0;i<=n;i++){
if(A[s-i]==1){
answer=max(answer,abs((i-(s-i))));
// cout<<(s-i)<<" “;
}
}
cout<<answer<<”\n";
// cout<<endl;
}

return 0;
}
question:CodeChef: Practical coding for everyone

This is a simple linear programming problem whose solution should be computed in O(1) time.

The run-time error is surely produced when accessing A[s-i] where the index (s-i) is out of the valid range [0,n].

I am not sure why you are using the array A. All that is needed to find a feasible solution is to check that 0 \leq s-i \leq n for some 0 \leq i \leq n.