I want to design a context-free grammar that generates words that either both start and end with $c$, or contain the same amount of $a$-s and $b$-s. Here is what I have. The nonterminals are $S,X,Y$, the terminals are $a,b,c$, the start symbol is $S$, and the productions are
\begin{align} &S \to aYS \mid cXc \mid bXS \mid cYc \mid \varepsilon \\ &X \to a \mid bXX \\ &Y \to b \mid aYY \\ \end{align}