Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll mod_pow(ll n, ll p, ll mod) {
    ll ret = 1;
    while (p > 0) {
        if (p & 1) ret = ret * n % mod;
        n = n * n % mod;
        p >>= 1;
    }
    return ret;
}

ll mod_inv(ll n, ll mod) {
    return mod_pow(n, mod-2, mod);
}

const ll mod = 1e9 + 7;
vector<vector<int>> G;
vector<int> size, parent;

void dfs(int v, int p) {
    parent[v] = p;
    for (int c : G[v]) {
        if (c == p) continue;
        dfs(c, v);
        size[v] += size[c];
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int N;
    cin >> N;
    G.resize(N);
    for (int i = 0; i < N - 1; i++) {
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    size.resize(N, 1);
    parent.resize(N, 0);
    dfs(0, -1);

    ll ans = 0;
    ll two_inv = mod_inv(2, mod);
    for (int v = 0; v < N; v++) {
        ll prob1 = 0;
        int s = 1;
        for (int c : G[v]) {
            if (c == parent[v]) continue;
            s += size[c];
            prob1 += (1 - mod_pow(two_inv, size[c], mod) + mod) * mod_pow(two_inv, N - size[c], mod) % mod;
            prob1 %= mod;
        }
        prob1 += (1 - mod_pow(two_inv, N - s, mod) + mod) * mod_pow(two_inv, s, mod) % mod;
        prob1 %= mod;
        ll prob = (two_inv - mod_pow(two_inv, N, mod) - prob1 + mod * 2) % mod;
        ans = (ans + prob) % mod;
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:28:9: error: reference to 'size' is ambiguous
   28 |         size[v] += size[c];
      |         ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:21:13: note:                 'std::vector<int> size'
   21 | vector<int> size, parent;
      |             ^~~~
a.cc:28:20: error: reference to 'size' is ambiguous
   28 |         size[v] += size[c];
      |                    ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:21:13: note:                 'std::vector<int> size'
   21 | vector<int> size, parent;
      |             ^~~~
a.cc: In function 'int main()':
a.cc:47:5: error: reference to 'size' is ambiguous
   47 |     size.resize(N, 1);
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:21:13: note:                 'std::vector<int> size'
   21 | vector<int> size, parent;
      |             ^~~~
a.cc:58:18: error: reference to 'size' is ambiguous
   58 |             s += size[c];
      |                  ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:21:13: note:                 'std::vector<int> size'
   21 | vector<int> size, parent;
      |             ^~~~
a.cc:59:44: error: reference to 'size' is ambiguous
   59 |             prob1 += (1 - mod_pow(two_inv, size[c], mod) + mod) * mod_pow(two_inv, N - size[c], mod) % mod;
      |                                            ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:21:13: note:                 'std::vector<int> size'
   21 | vector<int> size, parent;
      |             ^~~~
a.cc:59:88: error: reference to 'size' is ambiguous
   59 |             prob1 += (1 - mod_pow(two_inv, size[c], mod) + mod) * mod_pow(two_inv, N - size[c], mod) % mod;
      |                                                                                        ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:21:13: note:                 'std::vector<int> size'
   21 | vector<int> size, parent;
      |             ^~~~