import sequtils template times*(n:int,body) = (for _ in 0.." ,discardable.} proc scan(): int = while true: let k = getchar_unlocked() if k < '0': return result = 10 * result + k.ord - '0'.ord # (親も子も同一視して)双方向になっている木を,0 番を根として子のノードだけ持つように変更する proc asTree(E:seq[seq[int]]):seq[seq[int]] = var answer = newSeqWith(E.len,newSeq[int]()) proc impl(pre,now:int) = for dst in E[now]: if dst == pre : continue answer[now].add(dst) impl(now,dst) impl(-1,0) return answer let n = scan() # 木やんけ var E = newSeqWith(n,newSeq[int]()) (n-1).times: let a = scan() - 1 let b = scan() - 1 E[a] &= b E[b] &= a E = E.asTree() var ans = 0.max(E[0].len - 2) for i in 1..