Wrong answer inspite of displaying correct output

I have been trying this problem (https://www.codechef.com/SEPT18B/problems/MAGICHF) and when I run it, it displays the correct output but when I put it on code chef it shows wrong answer. Why is that

the code is `#include<stdio.h>

int main(){

int x,n,s,i,j,t,a,b,k;
scanf("%d\n",&t);
for(i=1;i<=t;i++)
{
	scanf("%d%d%d",&n,&x,&s);
	//b=k;
	for(j=2;j<=s+1;j++)
	{
		scanf("%d%d",&a,&b);
		a=a-b;
		b=a+b;
		a=b-a;
	}
	printf("%d",b);
}

}`

ive done it in C

PLz dont post your problems related to any ongoing contest.