Language: C++

#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eps 1e-12
#define int long long
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
    int ans = 1;
    for (; b; b >>= 1, a = a * a % mod)
        if (b & 1)
            ans = ans * a % mod;
    return ans;
}

int fa[2000];
int id[2000];
int sta[2000];
vector<pii> G[200];
int dp[55][110000];

void dfs(int x,int f,int p){
    fa[x]=f;id[x]=p;
    for(auto &i:G[x]){
        if(i.fi!=f)dfs(i.fi,x,i.se);
    }
}
int vis[200];
signed main()
{
    io;
    int n;cin>>n;
    rep(i,1,n-1){
        int l,r;cin>>l>>r;
        G[l].pb(mp(r,i));G[r].pb(mp(l,i));
    }
    dfs(1,0,0);
    int m;cin>>m;
  //  puts("11111");
    for (int x = 0; x < m; x++)
    {
        int u,v;cin>>u>>v; int lca;
        memset(vis,0,sizeof vis);
        for(int i=u;i;i=fa[i])vis[i]=1;
        for(int i=v;i&&!vis[i];i=fa[i])lca=fa[i];
      //  cout<<"lca: "<<lca<<endl;
        for(int i=u;i!=lca;i=fa[i])sta[id[i]]|=(1ll<<x);
        for(int i=v;i!=lca;i=fa[i])sta[id[i]]|=(1ll<<x);
    }

 //   puts("11111");
    dp[0][0]=1;
    for(int i=1;i<n;i++){
        for(int j=0;j<(1<<m);j++){
            dp[i][j] += dp[i-1][j];
            dp[i][j|sta[i]] += dp[i-1][j];
        }

    }
    cout<<dp[n-1][(1<<m)-1]<<endl;
  



    getchar(); //
    getchar();
}
#include "bits/stdc++.h"
using namespace std;
#define all(v) (v).begin(), (v).end()
#define io ios::sync_with_stdio(0)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rson rt << 1 | 1, mid + 1, r
#define lson rt << 1, l, mid
#define lll __int128
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eps 1e-12
#define int long long
const int mod = 1e9 + 7;
inline int ksm(int a, int b)
{
    int ans = 1;
    for (; b; b >>= 1, a = a * a % mod)
        if (b & 1)
            ans = ans * a % mod;
    return ans;
}

int fa[2000];
int id[2000];
int sta[2000];
vector<pii> G[200];
int dp[55][110000];

void dfs(int x,int f,int p){
    fa[x]=f;id[x]=p;
    for(auto &i:G[x]){
        if(i.fi!=f)dfs(i.fi,x,i.se);
    }
}
int vis[200];
signed main()
{
    io;
    int n;cin>>n;
    rep(i,1,n-1){
        int l,r;cin>>l>>r;
        G[l].pb(mp(r,i));G[r].pb(mp(l,i));
    }
    dfs(1,0,0);
    int m;cin>>m;
  //  puts("11111");
    for (int x = 0; x < m; x++)
    {
        int u,v;cin>>u>>v; int lca;
        memset(vis,0,sizeof vis);
        for(int i=u;i;i=fa[i])vis[i]=1;
        for(int i=v;i&&!vis[i];i=fa[i])lca=fa[i];
      //  cout<<"lca: "<<lca<<endl;
        for(int i=u;i!=lca;i=fa[i])sta[id[i]]|=(1ll<<x);
        for(int i=v;i!=lca;i=fa[i])sta[id[i]]|=(1ll<<x);
    }

 //   puts("11111");
    dp[0][0]=1;
    for(int i=1;i<n;i++){
        for(int j=0;j<(1<<m);j++){
            dp[i][j] += dp[i-1][j];
            dp[i][j|sta[i]] += dp[i-1][j];
        }

    }
    cout<<dp[n-1][(1<<m)-1]<<endl;
  



    getchar(); //
    getchar();
}


Compiler output:
a.cc:93:11: error: redefinition of 'const long long int mod'
   93 | const int mod = 1e9 + 7;
      |           ^~~
a.cc:16:11: note: 'const long long int mod' previously defined here
   16 | const int mod = 1e9 + 7;
      |           ^~~
a.cc:94:12: error: redefinition of 'long long int ksm(long long int, long long int)'
   94 | inline int ksm(int a, int b)
      |            ^~~
a.cc:17:12: note: 'long long int ksm(long long int, long long int)' previously defined here
   17 | inline int ksm(int a, int b)
      |            ^~~
a.cc:103:5: error: redefinition of 'long long int fa [2000]'
  103 | int fa[2000];
      |     ^~
a.cc:26:5: note: 'long long int fa [2000]' previously declared here
   26 | int fa[2000];
      |     ^~
a.cc:104:5: error: redefinition of 'long long int id [2000]'
  104 | int id[2000];
      |     ^~
a.cc:27:5: note: 'long long int id [2000]' previously declared here
   27 | int id[2000];
      |     ^~
a.cc:105:5: error: redefinition of 'long long int sta [2000]'
  105 | int sta[2000];
      |     ^~~
a.cc:28:5: note: 'long long int sta [2000]' previously declared here
   28 | int sta[2000];
      |     ^~~
a.cc:106:13: error: redefinition of 'std::vector<std::pair<long long int, long long int> > G [200]'
  106 | vector<pii> G[200];
      |             ^
a.cc:29:13: note: 'std::vector<std::pair<long long int, long long int> > G [200]' previously declared here
   29 | vector<pii> G[200];
      |             ^
a.cc:107:5: error: redefinition of 'long long int dp [55][110000]'
  107 | int dp[55][110000];
      |     ^~
a.cc:30:5: note: 'long long int dp [55][110000]' previously declared here
   30 | int dp[55][110000];
      |     ^~
a.cc:109:6: error: redefinition of 'void dfs(long long int, long long int, long long int)'
  109 | void dfs(int x,int f,int p){
      |      ^~~
a.cc:32:6: note: 'void dfs(long long int, long long int, long long int)' previously defined here
   32 | void dfs(int x,int f,int p){
      |      ^~~
a.cc:115:5: error: redefinition of 'long long int vis [200]'
  115 | int vis[200];
      |     ^~~
a.cc:38:5: note: 'long long int vis [200]' previously declared here
   38 | int vis[200];
      |     ^~~
a.cc:116:8: error: redefinition of 'int main()'
  116 | signed main()
      |        ^~~~
a.cc:39:8: note: 'int main()' previously defined here
   39 | signed main()
      |        ^~~~