Language: C++

#include <bits/stdc++.h>

#define rep(i, n) for(int (i) = 0; i < (n); ++(i))

using long long int = ll;
const ll MOD = 1e9 + 7;

template<long long int P>
struct _mint {
  long long int x;
  _mint(long long int x = 0): x((x % P + P) % P) {}

  _mint operator-() const {
    return _mint(-x);
  }

  _mint& operator+=(const _mint a) {
    if((x += a.x) >= P) {
      x -= P;
    }
    return *this;
  }
  _mint& operator-=(const _mint a) {
    if((x += P - a.x) >= P) {
      x -= P;
    }
    return *this;
  }
  _mint& operator*=(const _mint a) {
    (x *= a.x) %= P;
    return *this;
  }
  _mint& operator/=(const _mint a) {
    return (*this) *= a.inv();
  }

  _mint operator+(const _mint a) const {
    _mint res(*this);
    return res += a;
  }
  _mint operator-(const _mint a) const {
    _mint res(*this);
    return res -= a;
  }
  _mint operator*(const _mint a) const {
    _mint res(*this);
    return res *= a;
  }
  _mint operator/(const _mint a) {
    _mint res(*this);
    return res /= a;
  }

  _mint pow(long long int t) const {
    if(! t) return 1;
    _mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }

  // for prime P
  _mint inv() const {
    return pow(P - 2);
  }
};
using mint = _mint<MOD>;

int dfs(int pos, int prev, std::vector<std::vector<int>> &from, std::vector<int> &cnt) {
  int ret = 1;
  for(auto b : from[pos]) {
    if(b == prev) {
      continue;
    }

    ret += dfs(b, pos, from, cnt);
  }

  return cnt[pos] = ret;
}

int main() {
  int N;
  std::cin >> N;

  std::vector<int> A(N - 1), B(N - 1);
  std::vector<std::vector<int>> from(N);
  rep(i, N - 1) {
    std::cin >> A[i] >> B[i];
    --A[i];
    --B[i];
    from[A[i]].push_back(B[i]);
    from[B[i]].push_back(A[i]);
  }

  std::vector<mint> pow(N + 1), inv(N + 1);
  pow[0] = 1;
  inv[0] = 1;
  rep(i, N) {
    pow[i + 1] = pow[i] * 2;
    inv[i + 1] = pow[i + 1].inv();
  }

  std::vector<int> cnt(N);
  dfs(0, 0, from, cnt);

  mint EV = 1;
  rep(i, N - 1) {
    int na = std::min(cnt[A[i]], cnt[B[i]]);
    int nb = N - na;

    EV += (mint(1) - inv[na]) * (mint(1) - inv[nb]);
  }

  mint ans = EV - inv[1] * N - inv[N];
  std::cout << ans.x << '\n';
}

Compiler output:
a.cc:5:7: error: expected nested-name-specifier before 'long'
    5 | using long long int = ll;
      |       ^~~~
a.cc:6:7: error: 'll' does not name a type
    6 | const ll MOD = 1e9 + 7;
      |       ^~
a.cc:67:20: error: 'MOD' was not declared in this scope
   67 | using mint = _mint<MOD>;
      |                    ^~~
a.cc:67:23: error: template argument 1 is invalid
   67 | using mint = _mint<MOD>;
      |                       ^
a.cc: In function 'int main()':
a.cc:96:15: error: 'mint' was not declared in this scope; did you mean 'uint'?
   96 |   std::vector<mint> pow(N + 1), inv(N + 1);
      |               ^~~~
      |               uint
a.cc:96:19: error: template argument 1 is invalid
   96 |   std::vector<mint> pow(N + 1), inv(N + 1);
      |                   ^
a.cc:96:19: error: template argument 2 is invalid
a.cc:97:6: error: invalid types 'int[int]' for array subscript
   97 |   pow[0] = 1;
      |      ^
a.cc:98:6: error: invalid types 'int[int]' for array subscript
   98 |   inv[0] = 1;
      |      ^
a.cc:100:8: error: invalid types 'int[int]' for array subscript
  100 |     pow[i + 1] = pow[i] * 2;
      |        ^
a.cc:100:21: error: invalid types 'int[int]' for array subscript
  100 |     pow[i + 1] = pow[i] * 2;
      |                     ^
a.cc:101:8: error: invalid types 'int[int]' for array subscript
  101 |     inv[i + 1] = pow[i + 1].inv();
      |        ^
a.cc:101:21: error: invalid types 'int[int]' for array subscript
  101 |     inv[i + 1] = pow[i + 1].inv();
      |                     ^
a.cc:107:7: error: expected ';' before 'EV'
  107 |   mint EV = 1;
      |       ^~~
      |       ;
a.cc:112:5: error: 'EV' was not declared in this scope
  112 |     EV += (mint(1) - inv[na]) * (mint(1) - inv[nb]);
      |     ^~
a.cc:112:25: error: invalid types 'int[int]' for array subscript
  112 |     EV += (mint(1) - inv[na]) * (mint(1) - inv[nb]);
      |                         ^
a.cc:112:47: error: invalid types 'int[int]' for array subscript
  112 |     EV += (mint(1) - inv[na]) * (mint(1) - inv[nb]);
      |                                               ^
a.cc:115:7: error: expected ';' before 'ans'
  115 |   mint ans = EV - inv[1] * N - inv[N];
      |       ^~~~
      |       ;
a.cc:116:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
  116 |   std::cout << ans.x << '\n';
      |                ^~~
      |                abs