#include
using namespace std;
bool rem(int n){
int check=0;
for(int i = 1; i<=n; i++){
if(n%i == 0){
check = check + 1;
}
}
return(check == 2)?true:false;
}
int main() {
// your code goes here
int t;
cin >> t;
int anst = 1;
while(t–){
int ans; int count =0;
int x , y;
cin >> x >> y;
int i = 1;
ans = x + y+i;
you declare value of anst=1
outside of while loop and its increasing until t test case are running
means you have to set value anst=1
after every new input
like this
int anst = 1;
while(t–){
int ans; int count =0;
int x , y;
cin>>x>>y;
anst=1;
//remaining code
}