I can’t figure out any reason for runtime error in my solution: Solution: 53456590 | CodeChef

Pretty sure algorithm is correct, using DP (memoization) to compute gcd of the two subtrees split up by deleting edge (a, b)

Would also love it if I can reproduce the error in a custom test case, but so far not successful. Any help would be much appreciated!