Score : $400$ points
There are $N$ cities and $M$ roads in the Kingdom of Takahashi.
The cities are numbered $1$ through $N$, and the roads are numbered $1$ through $M$. Road $i$ is a one-way road that leads from City $A_i$ to City $B_i$, and it takes $C_i$ minutes to go through it.
Let us define $f(s, t, k)$ as the answer to the following query.
Compute $f(s,t,k)$ for all triples $s,t,k$ and print the sum of them. More formally, print $\displaystyle \sum_{s = 1}^N \sum_{t = 1}^N \sum_{k = 1}^N f(s, t, k)$.
Input is given from Standard Input in the following format:
$N$ $M$ $A_1$ $B_1$ $C_1$ $\vdots$ $A_M$ $B_M$ $C_M$
Print $\displaystyle \sum_{s = 1}^N \sum_{t = 1}^N \sum_{k = 1}^N f(s, t, k)$.
3 2 1 2 3 2 3 2
25
The triples $s,t,k$ such that $f(s,t,k) \neq 0$ are as follows.
3 0
0
We have $f(s,t,k) = 0$ for all $s,t,k$.
5 20 1 2 6 1 3 10 1 4 4 1 5 1 2 1 5 2 3 9 2 4 8 2 5 6 3 1 5 3 2 1 3 4 7 3 5 9 4 1 4 4 2 6 4 3 4 4 5 8 5 1 2 5 2 5 5 3 6 5 4 5
517