Language: C++

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

#define int long long;

signed main(){
  int n,m;
  cin>>n>>m;
  vector<int> a(m+1);
  for(auto &v:a) cin>>v;
  vector<int> b(m);
  for(auto &v:b) cin>>v;
  int res=0;
  vector<pair<pair<int,int>,int>> state;
  for(int i=0;i<m;i++){
    state.push_back({{a[i],a[i+1]},(1<<b[i])});
  }
  for(int rank=n;rank>=0;rank--){
    if(rank==0){
      if(!(state[0].second& 1)){
	res++;
      }
      break;
    }
    vector<pair<pair<int,int>,int>> nex;
    for(int i=0;i<state.size();i++){
      int lef=state[i].first.first+state[i].first.first%2;
      int rig=state[i].first.second-state[i].first.second%2;
      if(lef<rig){
	if(!(state[i].second&(1<<rank))){
	  res+=(rig-lef)/2;
	}
	nex.push_back({{lef/2,rig/2},state[i].second});
      }
      
      if(rig!=state[i].first.second){
	int val=state[i+1].second;
	if(state[i].second&(1<<rank)){
	  nex.push_back({{rig/2,rig/2+1},val});
	}
	else if(val & (1<<rank)){
	  nex.push_back({{rig/2,rig/2+1},state[i].second});
	}
	else{
	  res++;
	  nex.push_back({{rig/2,rig/2+1},state[i].second|val});
	}
      }
    }

    state=nex;
  }
  cout<<res<<endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:18: error: declaration does not declare anything [-fpermissive]
    4 | #define int long long;
      |                  ^~~~
a.cc:7:3: note: in expansion of macro 'int'
    7 |   int n,m;
      |   ^~~
a.cc:7:7: error: 'n' was not declared in this scope; did you mean 'yn'?
    7 |   int n,m;
      |       ^
      |       yn
a.cc:7:9: error: 'm' was not declared in this scope; did you mean 'tm'?
    7 |   int n,m;
      |         ^
      |         tm
a.cc:4:18: error: template argument 1 is invalid
    4 | #define int long long;
      |                  ^~~~
a.cc:9:10: note: in expansion of macro 'int'
    9 |   vector<int> a(m+1);
      |          ^~~
a.cc:4:18: error: template argument 2 is invalid
    4 | #define int long long;
      |                  ^~~~
a.cc:9:10: note: in expansion of macro 'int'
    9 |   vector<int> a(m+1);
      |          ^~~
a.cc:9:13: error: expected primary-expression before '>' token
    9 |   vector<int> a(m+1);
      |             ^
a.cc:9:15: error: 'a' was not declared in this scope
    9 |   vector<int> a(m+1);
      |               ^
a.cc:4:18: error: template argument 1 is invalid
    4 | #define int long long;
      |                  ^~~~
a.cc:11:10: note: in expansion of macro 'int'
   11 |   vector<int> b(m);
      |          ^~~
a.cc:4:18: error: template argument 2 is invalid
    4 | #define int long long;
      |                  ^~~~
a.cc:11:10: note: in expansion of macro 'int'
   11 |   vector<int> b(m);
      |          ^~~
a.cc:11:13: error: expected primary-expression before '>' token
   11 |   vector<int> b(m);
      |             ^
a.cc:11:15: error: 'b' was not declared in this scope
   11 |   vector<int> b(m);
      |               ^
a.cc:4:18: error: declaration does not declare anything [-fpermissive]
    4 | #define int long long;
      |                  ^~~~
a.cc:13:3: note: in expansion of macro 'int'
   13 |   int res=0;
      |   ^~~
a.cc:13:7: error: 'res' was not declared in this scope
   13 |   int res=0;
      |       ^~~
a.cc:4:18: error: wrong number of template arguments (1, should be 2)
    4 | #define int long long;
      |                  ^~~~
a.cc:14:20: note: in expansion of macro 'int'
   14 |   vector<pair<pair<int,int>,int>> state;
      |                    ^~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:89:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
   89 |     struct pair;
      |            ^~~~
a.cc:14:15: error: wrong number of template arguments (1, should be 2)
   14 |   vector<pair<pair<int,int>,int>> state;
      |               ^
/usr/include/c++/14/bits/stl_pair.h:89:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
   89 |     struct pair;
      |            ^~~~
a.cc:14:10: error: template argument 1 is invalid
   14 |   vector<pair<pair<int,int>,int>> state;
      |          ^
a.cc:14:10: error: template argument 2 is invalid
a.cc:14:23: error: expected primary-expression before ',' token
   14 |   vector<pair<pair<int,int>,int>> state;
      |                       ^
a.cc:4:13: error: expected primary-expression before 'long'
    4 | #define int long long;
      |             ^~~~
a.cc:14:24: note: in expansion of macro 'int'
   14 |   vector<pair<pair<int,int>,int>> state;
      |                        ^~~
a.cc:14:27: error: expected primary-expression before '>' token
   14 |   vector<pair<pair<int,int>,int>> state;
      |                           ^
a.cc:14:28: error: expected primary-expression before ',' token
   14 |   vector<pair<pair<int,int>,int>> state;
      |                            ^
a.cc:4:13: error: expected primary-expression before 'long'
    4 | #define int long long;
      |             ^~~~
a.cc:14:29: note: in expansion of macro 'int'
   14 |   vector<pair<pair<int,int>,int>> state;
      |                             ^~~
a.cc:14:32: error: expected primary-expression before '>>' token
   14 |   vector<pair<pair<int,int>,int>> state;
      |                                ^~
a.cc:14:35: error: 'state' was not declared in this scope; did you mean '_xstate'?
   14 |   vector<pair<pair<int,int>,int>> state;
      |                                   ^~~~~
      |                                   _xstate
a.cc:4:18: error: declaration does not declare anything [-fpermissive]
    4 | #define int long long;
      |                  ^~~~
a.cc:15:7: note: in expansion of macro 'int'
   15 |   for(int i=0;i<m;i++){
      |       ^~~
a.cc:15:11: error: 'i' was not declared in this scope
   15 |   for(int i=0;i<m;i++){
      |           ^
a.cc:15:18: error: expected ')' before ';' token
   15 |   for(int i=0;i<m;i++){
      |      ~           ^
      |                  )
a.cc:15:19: error: 'i' was not declared in this scope
   15 |   for(int i=0;i<m;i++){
      |                   ^
a.cc:4:18: error: declaration does not declare anything [-fpermissive]
    4 | #define int long long;
      |                  ^~~~
a.cc:18:7: note: in expansion of macro 'int'
   18 |   for(int rank=n;rank>=0;rank--){
      |       ^~~
a.cc:18:15: error: expected unqualified-id before '=' token
   18 |   for(int rank=n;rank>=0;rank--){
      |               ^
a.cc:18:22: error: missing template arguments before '>=' token
   18 |   for(int rank=n;rank>=0;rank--){
      |                      ^~
a.cc:18:25: error: expected ')' before ';' token
   18 |   for(int rank=n;rank>=0;rank--){
      |      ~                  ^
      |                         )
a.cc:18:30: error: expected unqualified-id before '--' token
   18 |   for(int rank=n;rank>=0;rank--){
      |                              ^~