PROBLEM CODE: Contest Page | CodeChef

My code:

#include <bits/stdc++.h>

using namespace std;

int main() {

long long int t;

cin>>t;

while(t–) {

long long int a,b,m=INT_MIN;

cin>>a>>b;

long long int p = min(a,b);

long long int n = max(a,b);

long long int r1,r2,r;

for(long long int i=p;i<=n;++i) {

r1 = ceil(((b-i)/2.0));

r2 = ceil(((i-a)/2.0));

r = r1+r2;

if(r>m) {

m = r;

r=0;

```
}
}
cout<<m<<endl;
}
return 0;
```

}

Though this is working for sample test case but showing TLE. Please help.