fn compute(input: &mut Input, index: usize) -> i64
Recursively compute the total following the tree structure all the way to the leaves.