#include #if __has_include() #include #endif namespace ttl{ using namespace std; using f80=long double; using i64=int64_t; using u64=uint64_t; template struct mymodint{ i64 vl; static constexpr i64 get_mod(){ return mod; } i64 val(){ return vl; } mymodint(i64 vl_=0):vl(vl_%mod){} mymodint operator-(){ return (vl==0)?0:mod-vl; } mymodint operator+(mymodint rhs){ return mymodint(*this)+=rhs; } mymodint operator-(mymodint rhs){ return mymodint(*this)-=rhs; } mymodint operator*(mymodint rhs){ return mymodint(*this)*=rhs; } mymodint operator/(mymodint rhs){ return mymodint(*this)/=rhs; } mymodint pow(i64 rhs){ mymodint res=1,now=(*this); while(rhs){ res*=((rhs&1)?now:1),now*=now,rhs>>=1; } return res; } mymodint& operator+=(mymodint rhs){ vl+=rhs.vl,vl-=((vl>=mod)?mod:0); return (*this); } mymodint& operator-=(mymodint rhs){ vl+=((vl using modint= #if __has_include() atcoder::static_modint; #else mymodint; #endif template std::ostream& operator<<(std::ostream& os,modint x){ return os<<(x.val()); } template std::istream& operator>>(std::istream& is,modint& x){ i64 t; is>>t,x=t; return is; } template void scn_(T& a){ cin>>a; } template void scn_(pair& a){ scn_(a.first),scn_(a.second); } template void scn_(vector& a){ for(auto& v:a){ scn_(v); } } template void scn_(vector>& a){ for(auto& v:a){ for(auto& u:v){ cin>>u; } } } void scn(){} template void scn(T& n,Args&... args){ scn_(n),scn(args...); } template void prt_(T a){ cout< void prt_(pair a){ cout<<"{"< void prt(vector a){ for(size_t i=0;i void prt(vector> a){ for(auto& v:a){ for(size_t i=0;i void prt(T a){ prt_(a),cout<<"\n"; } template void prt(T a,Args... args){ prt_(a),cout<<" ",prt(args...); } template struct multi_dim_vector{ using type=vector::type>; }; template struct multi_dim_vector{ using type=T; }; template vector mvec(int n,Arg&& arg){ return vector(n,arg); } template class multi_dim_vector::type mvec(int n,Args&&... args){ return typename multi_dim_vector::type(n,mvec(args...)); } template void rev(T& a){ reverse(a.begin(),a.end());} template void srt(T& a){ sort(a.begin(),a.end()); } template void rsrt(T& a){ sort(a.rbegin(),a.rend()); } template T revd(T a){ reverse(a.begin(),a.end()); return a; } template T srtd(T a){ sort(a.begin(),a.end()); return a; } template T rsrtd(T a){ sort(a.rbegin(),a.rend()); return a; } template T summ(vector a){ return accumulate(a.begin(),a.end(),T(0)); } template T maxi(vector a){ return *max_element(a.begin(),a.end()); } template T mini(vector a){ return *min_element(a.begin(),a.end()); } template void chmx(T& a,T b){ a=max(a,b); } template void chmn(T& a,T b){ a=min(a,b); } i64 ppcnt(u64 k){ return __builtin_popcountll(k); } template T powe(T a,i64 n){ T res=1; while(n){ if(n&1){ res*=a; } a*=a; n/=2; } return res; } i64 powe(i64 a,i64 n,i64 m){ i64 res=1; while(n){ if(n&1){ res=res*a%m; } a=a*a%m; n/=2; } return res; } template void zip(vector& a){ auto b=srtd(a); b.erase(unique(b.begin(),b.end()),b.end()); map mp; for(int i=0;i1){ i64 mid=(ok+ng)/2; (mid*mid<=n?ok:ng)=mid; } return ok; } i64 sqrc(i64 n){ i64 ok=1e9+5,ng=0; while(std::abs(ok-ng)>1){ i64 mid=(ok+ng)/2; (mid*mid>=n?ok:ng)=mid; } return ok; } i64 dvf(i64 a,i64 b){ if(b<0){ a*=-1,b*=-1; } if(a<0){ return -(-a+b-1)/b; } return a/b; } i64 dvc(i64 a,i64 b){ if(b<0){ a*=-1,b*=-1; } if(a<0){ return -(-a)/b; } return (a+b-1)/b; } vector bfs(vector> G,int v){ int N=G.size(); vector dst(N,-1); queue q; dst[v]=0; q.emplace(v); while(q.size()){ int t=q.front(); q.pop(); for(auto u:G[t]){ if(dst[u]==-1){ dst[u]=dst[t]+1; q.emplace(u); } } } return dst; } vector dijkstra(vector>>& G,int s){ int N=G.size(); vector dst(N,1e18); dst[s]=0; priority_queue,vector>,greater>> pq; pq.emplace(0,s); vector f(N); while(pq.size()){ auto [t,u]=pq.top(); pq.pop(); if(f[u]){ continue; } f[u]=1; for(auto [v,w]:G[u]){ if(dst[v]>dst[u]+w){ dst[v]=dst[u]+w; pq.emplace(dst[v],v); } } } return dst; } vector> pfct(i64 n){ vector> res; for(i64 i=2;i*i<=n;++i){ if(n%i!=0){ continue; } i64 ex=0; while(n%i==0){ ex++,n/=i; } res.emplace_back(i,ex); } if(n!=1){ res.emplace_back(n,1); } return res; } vector ediv(i64 n){ vector res; for(i64 i=1;i*i<=n;++i){ if(n%i!=0){ continue; } res.emplace_back(i); if(i*i!=n){ res.emplace_back(n/i); } } srt(res); return res; } template struct csm2d{ int n,m; vector> a,c; csm2d(vector> a_):n(a_.size()),m(a_[0].size()),a(a_){ auto b=mvec(n,m+1,0); for(int i=0;i(n+1,m+1,0); for(int j=0;j auto runlng(T a) -> vector>{ int n=a.size(); vector> res; typename decltype(a)::value_type now=a[0]; i64 l=1; for(int i=1;i struct cmb{ vector fac,ifac; cmb(int mx=3000000):fac(mx+1,1),ifac(mx+1,1){ for(int i=1;i<=mx;++i){ fac[i]=fac[i-1]*i; } ifac[mx]/=fac[mx]; for(int i=mx;i>0;--i){ ifac[i-1]=ifac[i]*i; } } T operator()(i64 n,i64 k){ if(n<0||k<0||n; cmb Cb; string S; scn(S); int N=S.size(); //i 文字目まで来て ) を j 個使った auto dp=mvec(N+1,2,0); dp[0][0]=1; for(int i=0;i(N+1,2,0); for(int j=0;j