### My issue

include

using namespace std;

int main(){

int t;

cin>>t;

while(t–){

int n,k,b;

cin>>n>>k;

int max,a=0;

for (int i=0;i<=n;i++){

a=(i%k)*((n-i)%k);

if (max<a){

max=a;

b=i;

}

}

cout<<b<<endl;

```
}
return 0;
```

}

please help me finding error in this ques maximal expression running perefectly for 2 test case but choking in 3rd one

### My code

```
#include <iostream>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int n,k,b;
cin>>n>>k;
int max,a=0;
for (int i=0;i<=n;i++){
a=(i%k)*((n-i)%k);
if (max<a){
max=a;
b=i;
}
}
cout<<b<<endl;
}
return 0;
}
```

Problem Link: MAXIMALEXP Problem - CodeChef