Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#define o 1000005
#define re register int
#define ll long long
#define g0(a) memset(a,0,sizeof(a))
#define gc(a,b) memcpy(a,b,sizeof(a))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define REP(i,a,b) for(int i=a;i>=b;i--)
#define pa pair<int,int>
#define mpp make_pair
#define s1 first
#define s2 second
#define go(x) for(ll i=h[x];i;i=w[i].next)
using namespace std;
inline int read()
{
	register int data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=(data<<1)+(data<<3)+(ch^48),ch=getchar();
	return data*w;
}
int n,m,f[22][1<<17],fac[o],size[o],inv[o],a[o];
const int mod=1e9+7;
void fix(int &x){x-=mod;x+=x>>31&mod;}
int KSM(int x,int k)
{
	int tmp=1,y=x;
	for(int i=k;i;i>>=1,y=1ll*y*y%mod)if(i&1)tmp=1ll*tmp*y%mod;
	return tmp;
}
int A(int n,int m){
	return n<m?0:1ll*fac[n]*inv[n-m]%mod;
}
int main()
{
	n=read(),m=read();
	FOR(i,1,m)a[i]=read();
	sort(a+1,a+m+1);
	fac[0]=1;
	FOR(i,1,(1<<n)-1)fac[i]=1ll*fac[i-1]*i%mod;
	FOR(i,0,(1<<n)-1)inv[i]=KSM(fac[i],mod-2);
	f[m+1][0]=1;
	REP(i,m,1)FOR(j,0,(1<<n)-1)
	{
		if(!f[i+1][j])continue;
		int sz=(1<<n)-a[i];
		FOR(k,0,n-1)if(j>>k&1)sz-=1<<k;
		if(sz<0)continue;
		FOR(k,0,n-1)if(!(j>>k&1))fix(f[i][j|1<<k]+=1ll*A(sz,(1<<k)-1)*(1<<k)%mod*f[i+1][j]%mod);
		fix(f[i][j]+=f[i+1][j]);
	}
	int ans=0;
	size[0]=mod-1;
	FOR(i,0,(1<<n)-1)
	{
		size[i]=mod-size[i-(i&-i)];
		if(!f[1][i])continue;
		int sz=(1<<n)-1;
		FOR(j,0,n-1)if(i>>j&1)sz-=1<<j;
		ans=(ans+1ll*size[i]*f[1][i]%mod*fac[sz])%mod;
	}
	cout<<1ll*ans*(1<<n)%mod<<'\n';
	return 0;
}

Compiler output:
a.cc: In function 'int read()':
a.cc:24:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   24 |         register int data=0,w=1;
      |                      ^~~~
a.cc:24:29: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   24 |         register int data=0,w=1;
      |                             ^
a.cc: In function 'int main()':
a.cc:62:9: error: reference to 'size' is ambiguous
   62 |         size[0]=mod-1;
      |         ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:31:29: note:                 'int size [1000005]'
   31 | int n,m,f[22][1<<17],fac[o],size[o],inv[o],a[o];
      |                             ^~~~
a.cc:65:17: error: reference to 'size' is ambiguous
   65 |                 size[i]=mod-size[i-(i&-i)];
      |                 ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:31:29: note:                 'int size [1000005]'
   31 | int n,m,f[22][1<<17],fac[o],size[o],inv[o],a[o];
      |                             ^~~~
a.cc:65:29: error: reference to 'size' is ambiguous
   65 |                 size[i]=mod-size[i-(i&-i)];
      |                             ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:31:29: note:                 'int size [1000005]'
   31 | int n,m,f[22][1<<17],fac[o],size[o],inv[o],a[o];
      |                             ^~~~
a.cc:69:30: error: reference to 'size' is ambiguous
   69 |                 ans=(ans+1ll*size[i]*f[1][i]%mod*fac[sz])%mod;
      |                              ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:31:29: note:                 'int size [1000005]'
   31 | int n,m,f[22][1<<17],fac[o],size[o],inv[o],a[o];
      |                             ^~~~