Hackercup C1, only 1 testcase failed

So, basically, I used a bit overkill idea of LCA for finding max path sum from any leaf node to any other leaf node whose LCA is 1, but it’s giving less answer on their first test case and I am unable to debug it… So if anyone has any idea, then pls help me… Thank you!

Code: Ubuntu Pastebin

Input: Ubuntu Pastebin

My Output: 356881775
Actual Output: 361976459