The Rayleigh-Ritz variation method
Instead of doing the whole derivation, I will provide the following two hints usefull in the derivation:


Use the quotient rule (as is was already done by OP).
$$
  \left({\frac {f}{g}}\right)'={\frac {f'g-fg'}{g^{2}}} \, ,
$$
where in this particular case $f = \sum_{i,j} c_i c_j H_{ij}$ and $g = \sum_{i,j} c_i c_j S_{ij}$.
Then, when taking the derivatives of the above mentioned $f$ and $g$, take into account that for each and every $c_i c_j X_{ij}$ term (where $X$ is either $H$ or $S$) there are only three possibilities:


$i = k$ in which case $\partial (c_i c_j X_{ij})/\partial c_k = c_j X_{kj}$;
$j = k$ in which case $\partial (c_i c_j X_{ij})/\partial c_k = c_i X_{ik}$;
$i \neq k$ and $j \neq k$ in which case $\partial (c_i c_j X_{ij})/\partial c_k = 0$.