#include
#include<stdio.h>
#include<math.h>
using namespace std;
int main()
{
long long int a=0,b=0,x=0,y=0,z=0,total=0,i=0;
long long int small(long long int p,long long int q);
cin>>total;
for(i=0;i<total;++i)
{
cin>>a;
cin>>b;
x=fabs(a);
y=fabs(b);
if(y==0)
{
if(x%2==0)
{
z=2*x;
}
else
z=(2*x+1);
}
else if(x==0)
{
if(y%2==0)
{
z=2*y;
}
else
z=(2*y-1);
}
else if(x==y)
{
z=2*x;
}
else if(x%2!=0 && y%2!=0)
{
z=(2*fabs(y-x)+2*small(x,y));
}
else
{
z=(2*fabs(y-x)-1)+2*small(x,y);
}
cout<<z<<endl;
}
return 0;
}
long long int small(long long int p,long long int q)
{
if(p>=q)
return q;
else
return p;
}
What is wrong with this code…