MAX_DIFF: The Two Dishes 

Problem:

Chef prepared two dishes yesterday. Chef had assigned the tastinesstastiness T1T1 and T2T2 to the first and to the second dish respectively. The tastiness of the dishes can be any integerinteger between 00 and NN (both inclusive).

Unfortunately, Chef has forgotten the values of T1T1 and T2T2 that he had assigned to the dishes. However, he remembers the sum of the tastiness of both the dishes – denoted by SS.

Chef wonders, what can be the maximum possible absolute difference between the tastiness of the two dishes. Can you help the Chef in finding the maximum absolute difference?

#include <iostream>
using namespace std;

int main()
{
   int t;
   cin>>t;
   while(t--)
   {
     long long n;
     long long s;
     cin>>n>>s;
     int diff;
     if(s<=n)
     {
       diff=s;
     }
     else
     {
       diff=(n-s)+n;
     }
     cout<<diff<<endl;
   }
   return 0;
}

See also  HNUM: Joy giving number