fn main [ var lines := list_break_to_lines(read_lazy(h[0])); var list1 := empty(int); var map2 := infinite(0); for l in lines do [ var b := list_break_whitespace(l); list1 +<= ston(b[0]); map2[ston(b[1])] += 1; ] var dist := 0; for i := 0 to len(list1) do dist += list1[i] * map2[list1[i]]; write(h[1], ntos(dist) + nl); ]