Help me in solving CANDYSTORE problem

My issue

the code is working fine in other flatform but in this it is showing that it doesnt satisfy expected output

My code

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	int x[t],y[t];
	for(int i=0;i<t;i++)
	{
	    cin>>x[i]>>y[i];
	}
	for(int i=0;i<t;i++)
	{
	    if(x[i]>y[i])
	    {
	        cout<<x[i]-(2*y[i])<<endl;
	    }
	    else
	    {
	        cout<<2*y[i]-x[i]<<endl;   
	    }
	}
	return 0;
}

Learning course: Basic Math using C++
Problem Link: CodeChef: Practical coding for everyone

check the test cases one by one

i have checked the test cases but the last test case not giving expected output in code chef complier but in other compliers it is giving correct output

@lithigaj
your logic was not right
I have correct it with right logic
hope u will get it.

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	int x[t],y[t];
	for(int i=0;i<t;i++)
	{
	    cin>>x[i]>>y[i];
	}
	for(int i=0;i<t;i++)
	{
	    if(x[i]>y[i])
	    {
	        cout<<(y[i])<<endl;
	    }
	    else
	    {
	        cout<<x[i]+((y[i]-x[i])*2)<<endl;   
	    }
	}
	return 0;
}