Solution (source code)

= Solution

For the <centralizer of a subset>, the identity commutes with every $h\in A$. If $g,k$ commute with each member of $A$, then for every such $h$,
$$
(gk)h=g(kh)=g(hk)=(gh)k=h(gk).
$$
Also $gh=hg$ implies $g^{-1}h=hg^{-1}$ after multiplication by $g^{-1}$ on both sides. Thus identity, products and inverses lie in $C(A)$, proving that it is a <subgroup>.

For the <conjugation action>, identity acts trivially, and
$$
\rho(g_1,\rho(g_2,h))=g_1g_2h g_2^{-1}g_1^{-1}
=\rho(g_1g_2,h).
$$
These are the defining laws of a left <group action>. Its <orbits of a group action> are the <conjugacy classes>. The stabilizer of $h$ is exactly its <centralizer>, since $ghg^{-1}=h$ if and only if $gh=hg$. The <orbit-stabilizer theorem> therefore gives
$$
|O_i|=[G:C(\{h_i\})]=\frac{|G|}{|C(\{h_i\})|}.
$$
A class has one element exactly when that element commutes with all of $G$, so the singleton classes are precisely the elements of $C(G)$, the <centre of a group>. Partitioning $G$ into all its <conjugacy classes> now proves the <class equation>
$$
\boxed{|G|=|C(G)|+\sum_{|O_i|>1}\frac{|G|}{|C(\{h_i\})|}}.
$$
For $|G|=p^r$, <Lagrange's theorem for finite groups> makes every class size a power of $p$. A nonsingleton class has size at least $p$ and is therefore divisible by $p$. Reducing the <class equation> modulo $p$ yields $|C(G)|\equiv0\pmod p$, because $r>0$. The identity lies in $C(G)$, so its order is positive and divisible by $p$. Consequently
$$
\boxed{|C(G)|\ge p>1}.
$$
This proves the <nontrivial center of a finite p-group> directly from the conjugation classes.