import sequtils,algorithm,math template `max=`*(x,y) = x = max(x,y) template useUnionFind() = # 同一集合の判定/マージ が 実質 O(1) type UnionFind[T] = ref object parent : seq[T] proc initUnionFind[T](size:int) : UnionFind[T] = new(result) result.parent = newSeqUninitialized[T](size) for i in 0.int32.." .} proc scan(): int = while true: let k = getchar_unlocked() if k < '0': return result = 10 * result + k.ord - '0'.ord type Edge = tuple[cost,src,dst:int] proc kruskal(E:seq[Edge],maxN:int) : int = # 0..