Help me in solving CANDYSTORE problem

My issue

code not running

My code

#include <stdio.h>

int main() {
	int n,x,y;
	for (int i=0;i<n;i++){
	    scanf("%d",&x);
	    scanf("%d\n",&y);
	    if (y>x){
	        printf("%d",((y-x)*2)+x);
	    }
	    else {
	        printf("%d",y);
	    }
	}
	return 0;
}


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

#include <stdio.h>

int main() {
	int n,x,y;
    scanf("%d",&n); //fix1: scan n
	for (int i=0;i<n;i++){
	    scanf("%d",&x);
	    scanf("%d\n",&y);
	    if (y>x){
	        printf("%d\n",((y-x)*2)+x); //fix2: print new line
	    }
	    else {
	        printf("%d\n",y); //fix3: print new line
	    }
	}
	return 0;
}

I fixed your code. You forgot to scan n, which resulted in your code skipping your loop and doing nothing.