Suppose $G$ is a finite group with order $n$ and $G$ has $k$ conjugacy classes in $G$. Find a formula in terms of the order of $G$ and the number of conjugacy classes in $G$ for the number of unordered pairs $\{(x,y)\colon x,y\in G, xy=yx\}$.
My attempt:
Suppose $$G=\bigcup_g^.\ [g]$$ where each $[g]$ stands for the conjugacy class $\{rgr^{-1}:r\in G\}$ of $g$.
We are actually asked to find the stabilizer of every $g\in G$ by the conjugate action on $G$. And we have $$ |G_{g_i}|=\frac{|G|}{|[g_i]|} .$$ So \begin{align} 2|\{(x,y)\colon x,y\in G, xy=yx\}|&=\sum_{i=1}^n |G_{g_i}|\\ &=\sum_{i=1}^n\frac{|G|}{|[g_i]|}\\ &=\sum_{i=1}^n\frac{n}{|[g_i]|} \end{align} But how can we get $k$ involved?
Suppose $C_1,\dots,C_k$ are the $k$ conjugacy classes of $G$, then your formula becomes \begin{equation*} \sum_{i = 1}^n\frac{n}{|[g_i]|} = \sum_{j = 1}^k\sum_{g\in C_j}\frac{n}{|C_j|} = n\sum_{j = 1}^k\sum_{g\in C_j}\frac{1}{|C_j|} = n\sum_{j = 1}^k|C_j|\frac{1}{|C_j|} = n\sum_{j = 1}^k1 = nk. \end{equation*}