c solution
\nint countOfSubtree(struct TreeNode* root, int* ans){\n    if(!root) return 0;\n    \n    int left = countOfSubtree(root->left, ans);\n    int right = countOfS
```\nint countOfSubtree(struct TreeNode* root, int* ans){\n    if(!root) return 0;\n    \n    int left = countOfSubtree(root->left, ans);\n    int right = countOfSubtree(root->right, ans);\n\n    int currCnt = left + right + 1;\n    int currSum = root->val;\n    currSum += (root->left)?root->left->val : 0;\n    currSum += (root->right)?root->right->val : 0;\n    \n    if(root->val == (currSum / currCnt))\n        (*ans)++;\n    root->val = currSum;\n    return currCnt;\n}\n\nint averageOfSubtree(struct TreeNode* root){\n    int ans = 0;\n    countOfSubtree(root, &ans);\n    return ans;\n}\n```
['C']