Language: C++

#pragma GCC optimize("O3")

#include<iostream>

using namespace std;
typedef unsigned int ll;

#define REP(i,n) for(ll i=0;i<n;i++)
#define MOD 1000000007 //10^9+7:合同式の法

template<ll mod> class modint{
public:
    ll val=0;
    //コンストラクタ
    modint(ll x=0){while(x<0)x+=mod;val=x%mod;}
    //コピーコンストラクタ
    modint(const modint &r){val=r.val;}
    //算術演算子
    modint operator -(){return modint(-val);} //単項
    modint operator +(const modint &r){return modint(*this)+=r;}
    modint operator -(const modint &r){return modint(*this)-=r;}
    modint operator *(const modint &r){return modint(*this)*=r;}
    modint operator /(const modint &r){return modint(*this)/=r;}
    //代入演算子
    modint &operator +=(const modint &r){
        val+=r.val;
        if(val>=mod)val-=mod;
        return *this;
    }
    modint &operator -=(const modint &r){
        if(val<r.val)val+=mod;
        val-=r.val;
        return *this;
    }
    modint &operator *=(const modint &r){
        val=val*r.val%mod;
        return *this;
    }
    modint &operator /=(const modint &r){
        ll a=r.val,b=mod,u=1,v=0;
        while(b){
            ll t=a/b;
            a-=t*b;swap(a,b);
            u-=t*v;swap(u,v);
        }
        val=val*u%mod;
        if(val<0)val+=mod;
        return *this;
    }
    //等価比較演算子
    bool operator ==(const modint& r){return this->val==r.val;}
    bool operator <(const modint& r){return this->val<r.val;}
    bool operator !=(const modint& r){return this->val!=r.val;}
};

using mint = modint<MOD>;

//入出力ストリーム
istream &operator >>(istream &is,mint& x){//xにconst付けない
    ll t;is >> t;
    x=t;
    return (is);
}
ostream &operator <<(ostream &os,const mint& x){
    return os<<x.val;
}

//累乗
mint modpow(const mint &a,ll n){
    if(n==0)return 1;
    mint t=modpow(a,n/2);
    t=t*t;
    if(n&1)t=t*a;
    return t;
}

//二項係数の計算
mint fac[MAXR+1],finv[MAXR+1],inv[MAXR+1];
//テーブルの作成
void COMinit() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    FOR(i,2,MAXR){
        fac[i]=fac[i-1]*mint(i);
        inv[i]=-inv[MOD%i]*mint(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}
//演算部分
mint COM(ll n,ll k){
    if(n<k)return 0;
    if(n<0 || k<0)return 0;
    return fac[n]*finv[k]*finv[n-k];
}


ll s[2001],t[2001],n,m={0};
mint dp[2001][2001]={0};

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>m;
    REP(i,n){cin>>s[i];}
    REP(i,m){cin>>t[i];}
    REP(i,n+1){dp[i][0]=1;}
    REP(i,m+1){dp[0][i]=1;}
    REP(i,n){
        REP(j,m){
            if(s[i]==t[j]){
                dp[i+1][j+1]+=(dp[i+1][j]+dp[i][j+1]);
            }else{
                dp[i+1][j+1]+=(dp[i+1][j]+dp[i][j+1]-dp[i][j]);
            }
        }
    }
    cout<<dp[n][m]<<"\n";
}

Compiler output:
a.cc:78:10: error: 'MAXR' was not declared in this scope
   78 | mint fac[MAXR+1],finv[MAXR+1],inv[MAXR+1];
      |          ^~~~
a.cc:78:23: error: 'MAXR' was not declared in this scope
   78 | mint fac[MAXR+1],finv[MAXR+1],inv[MAXR+1];
      |                       ^~~~
a.cc:78:35: error: 'MAXR' was not declared in this scope
   78 | mint fac[MAXR+1],finv[MAXR+1],inv[MAXR+1];
      |                                   ^~~~
a.cc: In function 'void COMinit()':
a.cc:81:5: error: 'fac' was not declared in this scope
   81 |     fac[0]=fac[1]=1;
      |     ^~~
a.cc:82:5: error: 'finv' was not declared in this scope
   82 |     finv[0]=finv[1]=1;
      |     ^~~~
a.cc:83:5: error: 'inv' was not declared in this scope; did you mean 'int'?
   83 |     inv[1]=1;
      |     ^~~
      |     int
a.cc:84:9: error: 'i' was not declared in this scope
   84 |     FOR(i,2,MAXR){
      |         ^
a.cc:84:13: error: 'MAXR' was not declared in this scope
   84 |     FOR(i,2,MAXR){
      |             ^~~~
a.cc:84:5: error: 'FOR' was not declared in this scope
   84 |     FOR(i,2,MAXR){
      |     ^~~
a.cc: In function 'mint COM(ll, ll)':
a.cc:94:12: error: 'fac' was not declared in this scope
   94 |     return fac[n]*finv[k]*finv[n-k];
      |            ^~~
a.cc:94:19: error: 'finv' was not declared in this scope
   94 |     return fac[n]*finv[k]*finv[n-k];
      |                   ^~~~