Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long giant;
inline char nchar() {
	static const int bufl=1<<20;
	static char buf[bufl],*a=NULL,*b=NULL;
	return a==b && (b=(a=buf)+fread(buf,1,bufl,stdin),a==b)?EOF:*a++;
}
inline int read() {
	int x=0,f=1;
	char c=nchar();
	for (;!isdigit(c);c=nchar()) if (c=='-') f=-1;
	for (;isdigit(c);c=nchar()) x=x*10+c-'0';
	return x*f;
}
const int q=1e9+7;
const giant mod=(LLONG_MAX/q-1)*q;
const int maxn=3;
const int maxm=1e5+1;
const int maxj=31;
int n,m,c[maxm];
struct mat {
	int n,m;
	int a[maxn][maxn];
	mat () {clear();}
	mat (int _n,int _m):n(_n),m(_m) {clear();}
	inline void clear() {
		memset(a,0,sizeof a);
	}
	void init_A() {
		n=m=3;
		a[0][0]=2,a[0][1]=2,a[0][2]=1;
		a[1][0]=1,a[1][1]=1,a[1][2]=1;
		a[2][0]=1,a[2][1]=0,a[2][2]=1;
	}
	void init_B() {
		n=m=3;
		a[0][0]=1,a[0][1]=2,a[0][2]=1;
		a[1][0]=0,a[1][1]=1,a[1][2]=1;
		a[2][0]=0,a[2][1]=0,a[2][2]=1;
	}
	void init_f() {
		n=3,m=1;
		a[0][0]=1,a[1][0]=1,a[2][0]=1;
	}
	inline void eye(int _n,int _m) {
		n=_n,m=_m;
		assert(n==m);
		clear();
		for (int i=0;i<n;++i) a[i][i]=1;
	}
	mat operator * (const mat &b) const {
		assert(m==b.n);
		mat ret(n,b.m);
		for (int i=0;i<n;++i) for (int j=0;j<b.m;++j) {
			giant tmp(0);
			for (int k=0;k<m;++k) if ((tmp+=1ll*a[i][k]*b.a[k][j])>=mod) tmp-=mod;
			ret.a[i][j]=tmp%q;
		}
		return ret;
	}
} mi[maxj],A,B,f;
mat go(int y) {
	mat ret;
	ret.eye(3,3);
	for (int j=0;j<maxj;++j) if (y>>j&1) ret=ret*mi[j];
	return ret;
}
int main() {
	n=read(),m=read(),generate_n(c+1,m,read);
	A.init_A(),B.init_B(),f.init_f();
	mi[0]=A;
	for (int j=1;j<maxj;++j) mi[j]=mi[j-1]*mi[i-1];
	int now=1;
	for (int i=1;i<=m;++i) {
		f=B*go(c[i]-now)*f;
		now=c[i]+1;
	}
	f=go(n-now)*f;
	int ans=f.a[0][0];
	printf("%d\n",ans);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:70:37: error: no matching function for call to 'generate_n(int*, int&, <unresolved overloaded function type>)'
   70 |         n=read(),m=read(),generate_n(c+1,m,read);
      |                           ~~~~~~~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:4378:5: note: candidate: 'template<class _OIter, class _Size, class _Generator> _OIter std::generate_n(_OIter, _Size, _Generator)'
 4378 |     generate_n(_OutputIterator __first, _Size __n, _Generator __gen)
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4378:5: note:   template argument deduction/substitution failed:
a.cc:70:37: note:   couldn't deduce template parameter '_Generator'
   70 |         n=read(),m=read(),generate_n(c+1,m,read);
      |                           ~~~~~~~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:204:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Size, class _Generator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::generate_n(_ExecutionPolicy&&, _ForwardIterator, _Size, _Generator)'
  204 | generate_n(_ExecutionPolicy&& __exec, _ForwardIterator __first, _Size count, _Generator __g);
      | ^~~~~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:204:1: note:   candidate expects 4 arguments, 3 provided
a.cc:73:51: error: 'i' was not declared in this scope
   73 |         for (int j=1;j<maxj;++j) mi[j]=mi[j-1]*mi[i-1];
      |                                                   ^