<doocs>1120.Maximum Average Subtree_1.py
def dfs(root):
    if root is None:
        return 0, 0
    ls, ln = dfs(root.left)
    rs, rn = dfs(root.right)
    s = ls + root.val + rs
    n = ln + 1 + rn
    nonlocal ans
    ans = max(ans, s / n)
    return s, n
def sample_funcname ( var_1 ) :
    if var_1 is None :
        return 0 , 0
    var_4 , var_6 = var_0 ( var_1.left )
    var_7 , var_9 = var_0 ( var_1.right )
    var_11 = var_4 + var_1.val + var_7
    var_13 = var_6 + 1 + var_9
    nonlocal var_14
    var_14 = max ( var_14 , var_11 / var_13 )
    return var_11 , var_13
