Let S1 and S2 denote the set of marbles that A and B have.
It can be seen that sum(S1)+sum(S2)=n*(n+1)/2.(sum of first n natural numbers)
So we know sum(S1) and sum(S2) from here.If sum(S1) and sum(S2) are integers,then we can split the first N natural numbers into two sets.
Now check if their GCD is 1 or not.If the GCD is 1,print Yes otherwise print No.