Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef __int128_t ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

ll Mod;

VVI matproduct(VVI a,VVI b){
  if(a[0].size()!=b.size()) cout<<a[0].size()<<" "<<b.size()<<endl;
    VVI w(a.size(),VI(b[0].size(),0));
    for(ll i=0;i<a.size();i++){
      for(ll j=0;j<b[0].size();j++){
        for(ll k=0;k<a[0].size();k++){
          w[i][j]+=a[i][k]*b[k][j];
          w[i][j]%=Mod;
        }
      }
    }
    return w;
}

VVI square(VVI a){
  return matproduct(a,a);
}

int main(){
  ll i,j;
  long long l,a,b,m;
  cin>>l>>a>>b>>m;

  Mod=m;

  ll k=1;
  ll d[19];
  ll ke[19];
  for(i=1;i<19;i++){
    d[i]=max((k*10-1-a+b)/b,0ll)-max((k-1-a+b)/b,0ll);
    k*=10;
    ke[i]=k;
  }

  for(i=1;i<19;i++){
    if(d[i]<l) l-=d[i];
    else {
      d[i]=l;
      l=0;
    }
    d[i]+=Mod;
    d[i]%=Mod;
    ke[i]%=Mod;
  }


  VVI ans(1,VI(3));
  ans[0][0]=0;
  ans[0][1]=a;
  ans[0][2]=1;

  for(i=1;i<19;i++){
      VVI w(3,VI(3,0));
      w[0][0]=ke[i];
      w[1][0]=1;
      w[1][1]=1;
      w[2][1]=b;
      w[2][2]=1;

      for(j=0;j<60;j++){
        if((d[i]>>j)&1) ans=matproduct(ans,w);
        w=square(w);
      }
  }

  cout<<(long long) ans[0][0]<<endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:13: error: no matching function for call to 'max(ll, long long int)'
   43 |     d[i]=max((k*10-1-a+b)/b,0ll)-max((k-1-a+b)/b,0ll);
      |          ~~~^~~~~~~~~~~~~~~~~~~~
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:   template argument deduction/substitution failed:
a.cc:43:13: note:   deduced conflicting types for parameter 'const _Tp' ('__int128' and 'long long int')
   43 |     d[i]=max((k*10-1-a+b)/b,0ll)-max((k-1-a+b)/b,0ll);
      |          ~~~^~~~~~~~~~~~~~~~~~~~
/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, 2 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:   candidate expects 1 argument, 2 provided
/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:   template argument deduction/substitution failed:
a.cc:43:13: note:   mismatched types 'std::initializer_list<_Tp>' and '__int128'
   43 |     d[i]=max((k*10-1-a+b)/b,0ll)-max((k-1-a+b)/b,0ll);
      |          ~~~^~~~~~~~~~~~~~~~~~~~
a.cc:43:37: error: no matching function for call to 'max(ll, long long int)'
   43 |     d[i]=max((k*10-1-a+b)/b,0ll)-max((k-1-a+b)/b,0ll);
      |                                  ~~~^~~~~~~~~~~~~~~~~
/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:   template argument deduction/substitution failed:
a.cc:43:37: note:   deduced conflicting types for parameter 'const _Tp' ('__int128' and 'long long int')
   43 |     d[i]=max((k*10-1-a+b)/b,0ll)-max((k-1-a+b)/b,0ll);
      |                                  ~~~^~~~~~~~~~~~~~~~~
/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, 2 provided
/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:   candidate expects 1 argument, 2 provided
/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:   template argument deduction/substitution failed:
a.cc:43:37: note:   mismatched types 'std::initializer_list<_Tp>' and '__int128'
   43 |     d[i]=max((k*10-1-a+b)/b,0ll)-max((k-1-a+b)/b,0ll);
      |                                  ~~~^~~~~~~~~~~~~~~~~