From the Lagrangian we know that the FOC is:
\(\frac{P_X}{P_Y}=\frac{Y}{X}\)
Substituting in the budget constraint to find the individual demand function:
\(P_X*\bar{X}+P_Y=P_X X+ P_XX\)
\(X=0.5\bar{X}+0.5\frac{P_Y}{P_X}\)
X here is the quantity bought while the quantity consummed by the first kind of agents is equal to X+R.
The demand curve for Y is:
\(Y=0.5+0.5\bar{X}\frac{P_X}{P_Y}\)
The budget constraint for the second kind of agent is:
\((2-\bar{X}) P_X+\omega_Y P_Y \leqslant X P_X+Y P_Y\)