My issue
Why my code is failing?
My code
#include <stdio.h>
#include<stdlib.h>
int main() {
// your code goes here
int t;
scanf("%d", &t);
while (t--)
{
int x, y;
scanf("%d %d", &x, &y);
if (y > x)
{
int temp = y;
y = x;
x = temp;
}
if(x >= 2*y)
{
printf("0\n");
}
else
{
if(x % 2 != 0)printf("%d\n", 2*y-x);
else
{
if(abs(2*y-x) < abs(x/2-y))printf("%d\n", abs(2*y-x));
else printf("%d\n", abs(x/2-y));
}
}
}
}
Problem Link: Ratio By 2 Practice Coding Problem