easy short efficient clean code
\nclass Solution {\ntypedef long long ll;\n#define vi(x) vector<x>\n#define pb push_back\npublic:\n    ll n, rem, sum;\n    vi(vi(ll))g;\n    ll func(const vi(v
```\nclass Solution {\ntypedef long long ll;\n#define vi(x) vector<x>\n#define pb push_back\npublic:\n    ll n, rem, sum;\n    vi(vi(ll))g;\n    ll func(const vi(vi(ll))&g, const vi(int)&val, const ll&nd, const ll&par){\n        ll tot=val[nd];\n        for(ll child:g[nd]){\n            if(child!=par){\n                tot+=func(g, val, child, nd);\n            }\n        }\n        if(tot==sum){\n            --rem, tot=0;\n        }\n        return tot;\n    }\n    int componentValue(vector<int>&v, vector<vector<int>>&e) {\n        n=v.size();\n        ll tot=accumulate(begin(v), end(v), 0LL), ans=0;\n        g.resize(n);\n        for(auto edge:e){\n            g[edge[0]].pb(edge[1]);\n            g[edge[1]].pb(edge[0]);\n        }\n        for(ll i=1;i<=n;++i){\n            if(tot%i){\n                continue;\n            }\n                rem=i, sum=tot/rem;\n                func(g, v, 0, -1);\n                if(rem==0){\n                    ans=i;\n                }\n        }\n        return ans-1;\n    }\n};\n```
['Depth-First Search', 'C']