Solution (source code)

= Solution

A directed path of length two is determined by its middle vertex $x$ and an ordered pair of distinct neighbors, giving
$$
\sum_xd(x)(d(x)-1).
$$
For the colored complete graph, let
$$
S=\sum_x\left\{\binom{d_r(x)}2+\binom{d_b(x)}2\right\}.
$$
A monochromatic triangle contributes three monochromatic two-edge angles to $S$, while a nonmonochromatic triangle contributes one. If $M$ and $N$ are their respective numbers, then
$$
S=3M+N,
\qquad
\binom n3=M+N.
$$
Eliminating $N$ gives
$$
\boxed{M=\frac12S-\frac12\binom n3}.
$$