Help me in solving CHESS_PAIR problem

My issue

not gettin ans vro when submitted, but when i ran the code it got correct output

My code

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int n,tot, x, unrated,t,now;
	
	
	cin >> t;
	
	while(t--)
	{
	    cin >> n >> x;
	    tot = n*2;
	    now == tot%x;
	    if (n!=x && x!=6)
	    {
	        cout << x << endl;
	    }
	    else if(x > n && tot > x)
	    {
	        cout << n << endl;
	    }
	    else
	    {
	        cout << "0" << endl;
	    }
	    
	    unrated = tot - x ;
	    
	}
	
	return 0;
}

Problem Link: Chess Pairing Practice Coding Problem - CodeChef

@mitaoe278
here bro refer my c++ code , u will get the logic

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    int n,x;
	    cin>>n>>x;
	    n=n*2;
	    int ur=n-x;
	    if(ur>=x)
	    cout<<0;
	    else
	    cout<<x-ur;
	    cout<<endl;
	}
	return 0;
}