Help me in solving LBCV208 problem

My issue

give code

My code

// Update the code below to solve the problem

#include <iostream>
#include <string>
using namespace std;

int main() 
{
 int t;
 cin>>t;
 while(t--)
 {
   int N, M;
   cin>>N>>M;
   int pairNeeded = 2*N;
 int extra = max(0, pairNeeded-M);
  cout<<extra<<endl;
   
  }
  
return 0;
}

Learning course: Beginner DSA in C++
Problem Link: CodeChef: Practical coding for everyone

@dipika_gandash
This is the correct c++ code.

// Update the code below to solve the problem

#include <iostream>
#include <string>
using namespace std;

int main() 
{
 int t;
 cin>>t;
 while(t--)
 {
   int N, M;
   cin>>N>>M;
   if(N<M)
   cout<<N;
   else
   cout<<M+(N-M)*2;
   cout<<endl;
   
  }
return 0;
}

include
include
using namespace std;

int main()
{
int t;
cin>>t;
while(t–)
{
int N, M;
cin>>N>>M;
if(N<=M){cout<<N<<endl;}
else{cout<<2*N-M<<endl;}

}
return 0;
}