Result

AC

Duration

565ms

Code [DL]

0\&6,n;
?\ia*i+4[:{-}]i0(
&\{r9[0
!\r5[}:{:@{{:}@:}*@*-]r{*&+&0}}}:?

stdin

40 17 15
79 03 10
70 17 09
61 51 89

stdout

5950

stderr