Language: C++

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

typedef long long 	   ll;
typedef unsigned long long ull;

const int N = 100 + 20;


ll m, n;
vector <ll> a[N], b[N];
ll mem[1<<20][N];
ll mp[N][M], mskk[N], pos[N];
vector <ll> v;

void dfs(int x, int par){
    v.push_back(x);
    for (int i = 0; i < a[x].size(); i++) {
        if (a[x][i] == par)
            continue;
        dfs(a[x][i], x);
    }
}

void dfs2(int x, int par){
    v.push_back(x);
    for (int i = 0; i < a[x].size(); i++) {
        if (a[x][i]==par)
            continue;
        dfs2(a[x][i], x);
        v.push_back(x);
    }
}


ll dp(int x, int msk){
    if (x + 1 == v.size())
        return msk == (1 << m) - 1;
    if (mem[msk][x] != -1)
        return mem[msk][x];
    ll res = 0;
    res = dp(x + 1, msk);
    if (mp[v[x]][v[x + 1]] != -1 && x < pos[v[x + 1]])
        res += dp(x + 1, msk|mskk[mp[v[x]][v[x + 1]]]);
    mem[msk][x] = res;
    return res;
}

ll x[N / 2], y[N / 2], l[N / 2][N / 2];

int main() {
    while (cin>>n) {
        ll ans = 0;
        memset(mp, -1, sizeof mp);
	memset(q1, 0, sizeof q1);
	memset(q2, 0, sizeof
        for (int i = 0; i < n - 1; i++){
            cin >> x[i] >> y[i];
            a[x[i]].push_back(y[i]);
            a[y[i]].push_back(x[i]);
            mp[x[i]][y[i]] = mp[y[i]][x[i]] = i;
        }
        int q1[22], q2[22];
        cin>>m;
        memset(l, -1, sizeof l);
        for(int i = 0; i < m; i++) {
            scanf("%d%d",q1 + i, q2 + i);
            l[q1[i]][q2[i]] = l[q2[i]][q1[i]] = i;
        }
        vector <int> v1, v2;
        for (int i = 0; i < n - 1; i++) {
            int x1 = x[i], x2 = y[i];
            dfs(x1, x2);
            v1 = v;
	    v.clear();
            dfs(x2, x1);
            v2 = v;
	    v.clear();
            for (int j = 0; j < v1.size(); j++)
                for (int k = 0; k < v2.size(); k++)
                    if (l[v1[j]][v2[k]] > -1)  
                        mskk[i]|=(1<<l[v1[j]][v2[k]];
        }
        memset(mem, -1, sizeof mem);
        dfs2(1, -1);
        for(int i = (int)(v.size()) - 1; i >= 0; i--)
            pos[v[i]] = i;
        assert(v.size() < 110);
        ans = dp(0, 0);
        cout << ans << endl;
    }
  return 0;
}


Compiler output:
a.cc:13:10: error: 'M' was not declared in this scope
   13 | ll mp[N][M], mskk[N], pos[N];
      |          ^
a.cc: In function 'll dp(int, int)':
a.cc:43:9: error: 'mp' was not declared in this scope; did you mean 'm'?
   43 |     if (mp[v[x]][v[x + 1]] != -1 && x < pos[v[x + 1]])
      |         ^~
      |         m
a.cc: In function 'int main()':
a.cc:54:16: error: 'mp' was not declared in this scope; did you mean 'm'?
   54 |         memset(mp, -1, sizeof mp);
      |                ^~
      |                m
a.cc:55:16: error: 'q1' was not declared in this scope; did you mean 'y1'?
   55 |         memset(q1, 0, sizeof q1);
      |                ^~
      |                y1
a.cc:56:16: error: 'q2' was not declared in this scope
   56 |         memset(q2, 0, sizeof
      |                ^~
a.cc:57:9: error: expected primary-expression before 'for'
   57 |         for (int i = 0; i < n - 1; i++){
      |         ^~~
a.cc:57:25: error: 'i' was not declared in this scope
   57 |         for (int i = 0; i < n - 1; i++){
      |                         ^
a.cc:74:18: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'std::vector<long long int>')
   74 |             v1 = v;
      |                  ^
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)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:77:18: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'std::vector<long long int>')
   77 |             v2 = v;
      |                  ^
/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)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/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)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:82:53: error: expected ')' before ';' token
   82 |                         mskk[i]|=(1<<l[v1[j]][v2[k]];
      |                                  ~                  ^
      |                                                     )