Language: C++

#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;
#define int long long;


struct Edge{
    ll to;
    ll id;
    Edge(ll a, ll b):to(a), id(b){};
};

vector<Edge> g[55];
vector<ll> es;

bool dfs(ll v, ll tv, int p = -1)
{
    if (p==1) es = vector<ll> ();
    if (v==tv) {
        return true;
    }
    for (auto e: g[v]) {
        if (e.to==p) continue;
        if (dfs(e.to, tv, v)) {
            es.emplace_back(e.id);
            return true;
        }
    }
    return false;
}

int main(){
    ll n, m;
    cin >> n;
    rep (i, n-1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].emplace_back(b, i);
        g[b].emplace_back(a, i);
    }
    cin >> m;
    vector<ll> eset(m);
    rep (i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        dfs(a, b);
        for (auto e: es) {
            eset[i] |= (1LL << e);
        }
    }
    ll ans = 0;
    rep (i, 1LL<<m) {
        ll mask = 0;
        rep (j, m) {
            if (i>>j & 1) {
                mask |= eset[j];
            }
        }
        ll white = __builtin_popcountll(mask);
        ll now = 1LL << (n-1-white);
        if (__builtin_popcountll(i)%2==0) ans += now;
        else ans -= now;
    }
    
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc:10:22: error: expected ')' before ';' token
   10 | #define int long long;
      |                      ^
a.cc:22:23: note: in expansion of macro 'int'
   22 | bool dfs(ll v, ll tv, int p = -1)
      |                       ^~~
a.cc:22:9: note: to match this '('
   22 | bool dfs(ll v, ll tv, int p = -1)
      |         ^
a.cc:22:27: error: 'p' does not name a type
   22 | bool dfs(ll v, ll tv, int p = -1)
      |                           ^
a.cc:10:18: error: declaration does not declare anything [-fpermissive]
   10 | #define int long long;
      |                  ^~~~
a.cc:38:1: note: in expansion of macro 'int'
   38 | int main(){
      | ^~~
a.cc:38:5: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   38 | int main(){
      |     ^~~~
a.cc: In function 'int main()':
a.cc:10:18: error: declaration does not declare anything [-fpermissive]
   10 | #define int long long;
      |                  ^~~~
a.cc:3:26: note: in expansion of macro 'int'
    3 | #define FOR(i, a, b) for(int i=(a);i<(b);++i)
      |                          ^~~
a.cc:4:19: note: in expansion of macro 'FOR'
    4 | #define rep(i, n) FOR(i, 0, n)
      |                   ^~~
a.cc:41:5: note: in expansion of macro 'rep'
   41 |     rep (i, n-1) {
      |     ^~~
a.cc:41:10: error: 'i' was not declared in this scope
   41 |     rep (i, n-1) {
      |          ^
a.cc:3:30: note: in definition of macro 'FOR'
    3 | #define FOR(i, a, b) for(int i=(a);i<(b);++i)
      |                              ^
a.cc:41:5: note: in expansion of macro 'rep'
   41 |     rep (i, n-1) {
      |     ^~~
a.cc:3:41: error: expected ')' before ';' token
    3 | #define FOR(i, a, b) for(int i=(a);i<(b);++i)
      |                         ~               ^
a.cc:4:19: note: in expansion of macro 'FOR'
    4 | #define rep(i, n) FOR(i, 0, n)
      |                   ^~~
a.cc:41:5: note: in expansion of macro 'rep'
   41 |     rep (i, n-1) {
      |     ^~~
a.cc:41:10: error: 'i' was not declared in this scope
   41 |     rep (i, n-1) {
      |          ^
a.cc:3:44: note: in definition of macro 'FOR'
    3 | #define FOR(i, a, b) for(int i=(a);i<(b);++i)
      |                                            ^
a.cc:41:5: note: in expansion of macro 'rep'
   41 |     rep (i, n-1) {
      |     ^~~
a.cc:10:18: error: declaration does not declare anything [-fpermissive]
   10 | #define int long long;
      |                  ^~~~
a.cc:3:26: note: in expansion of macro 'int'
    3 | #define FOR(i, a, b) for(int i=(a);i<(b);++i)
      |                          ^~~
a.cc:4:19: note: in expansion of macro 'FOR'
    4 | #define rep(i, n) FOR(i, 0, n)
      |                   ^~~
a.cc:51:5: note: in expansion of macro 'rep'
   51 |     rep (i, m) {
      |     ^~~
a.cc:3:41: error: expected ')' before ';' token
    3 | #define FOR(i, a, b) for(int i=(a);i<(b);++i)
      |                         ~               ^
a.cc:4:19: note: in expansion of macro 'FOR'
    4 | #define rep(i, n) FOR(i, 0, n)
      |                   ^~~
a.cc:51:5: note: in expansion of macro 'rep'
   51 |     rep (i, m) {
      |     ^~~
a.cc:10:18: error: declaration does not declare anything [-fpermissive]
   10 | #define int long long;
      |                  ^~~~
a.cc:3:26: note: in expansion of macro 'int'
    3 | #define FOR(i, a, b) for(int i=(a);i<(b);++i)
      |                          ^~~
a.cc:4:19: note: in expansion of macro 'FOR'
    4 | #define rep(i, n) FOR(i, 0, n)
      |                   ^~~
a.cc:62:5: note: in expansion of macro 'rep'
   62 |     rep (i, 1LL<<m) {
      |     ^~~
a.cc:3:41: error: expected ')' before ';' token
    3 | #define FOR(i, a, b) for(int i=(a);i<(b);++i)
      |                         ~               ^
a.cc:4:19: note: in expansion of macro 'FOR'
    4 | #define rep(i, n) FOR(i, 0, n)
      |                   ^~~
a.cc:62:5: note: in expansion of macro 'rep'
   62 |     rep (i, 1LL<<m) {
      |     ^~~