Language: C++

#include<bits/stdc++.h>
#include<string.h>
#include<tuple>
#define all(c) c.begin(),c.end()
#define tr(x,n) for(int i=x;x<n?i<n:i>=n;x<n?i++:i--)
#define ll long long int
#define pb push_back
#define em emplace_back
#define mp make_pair
#define mt make_tuple
#define debug(c) cout<<c<<endl;
#define isro ios_base::sync_with_stdio(false);
#define find(v,x) find(all(v),x)!=v.end()
#define rep(i, n) for(ll i = 1;i <=n; i++)
#define newline cout<<endl;
using namespace std;
typedef vector<ll>vi;
typedef vector<vi>vii;
typedef pair<ll,ll>pi;
typedef tuple<ll,ll,ll>ti;

const ll mod = 1e9 + 7;

int main(){
    isro;

    ll n, m;
    cin>>n>> m;
    vi s(n+1),t(m+1);
    rep(i, n) cin >> s[i];
    rep(i, m) cin >> t[i];
 
    vii dp(n + 1, vi(m + 1,0));
    vii sum(n + 1,vi(m + 1,0));

     for(ll i=1;i<=n;i++){
         for(ll j=1;j<=m;j++){
             if(s[i]==t[j]){
                 sum[i][j]=sum[i][j-1]+sum[i-1][j]+1;
                 sum[i][j]%=mod;
             }
             else{
                 sum[i][j]=max(sum[i][j-1]+sum[i-1][j]-sum[i-1][j-1]);
                 sum[i][j]%=mod;
             }
         }
     }    

//    cout<<sum[n][m]<<endl; 
        cout << (sum[n][m]+1)%mod << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:31: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   43 |                  sum[i][j]=max(sum[i][j-1]+sum[i-1][j]-sum[i-1][j-1]);
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included 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_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   template argument deduction/substitution failed:
a.cc:43:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   43 |                  sum[i][j]=max(sum[i][j-1]+sum[i-1][j]-sum[i-1][j-1]);
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   candidate expects 2 arguments, 1 provided