Language: C++

#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
struct edge{ll to,id;};
vector<vector<edge> > v(50);
vector<int> root;
bool dfs(int now,int p,int f){
	if(now==f)return true;
	for(edge i:v[now]){
		if(i.to==p)continue;
		if(dfs(i.to,now,f)){
			root.pb(i.id);
			return true;
		}
	}
	return false;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,a,b;
    cin>>n;
    for(ll i=1LL;i<n;i++){
    	cin>>a>>b;
    	a--;b--;
    	v[a].push_back({b,i-1});
    	v[b].push_back({a,i-1});
    }
    cin>>m;
    vector<ll> s(m);
    for(ll i=0LL;i<m;i++){
    	cin>>a>>b;
    	a--;b--;
    	root=vector<ll>();
    	dfs(a,-1LL,b);
    	for(auto j:root){
    		s[i]|=1LL<<j;
    	}
    }
    ll ans=0,maki=(1LL<<m);
    for(ll bit=0;bit<maki;bit++){
    	ll mask=0;
    	for(ll i=0LL;i<m;i++){
    		if(bit>>i&1)mask|=s[i];
    	}
    	ll num=__builtin_popcount(mask);
    	ll count=1LL<<(n-1-num);
    	if(__builtin_popcount(bit)%2==0)ans += count;
    	else ans -= count;
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:25: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'std::vector<long long int>')
   39 |         root=vector<ll>();
      |                         ^
In file included from /usr/include/c++/14/vector:72,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'const std::vector<int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::vector<int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::initializer_list<int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~