Language: C++

#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

 
constexpr uint_fast64_t MOD = 1e9 + 7;
 
template<class StoreT, class AddT, class MulT, StoreT MOD>
class ModInt
{
    using self_type = ModInt<StoreT, AddT, MulT, MOD>;
    StoreT i;
 
public:
    ModInt()
        : i(0)
    {}
    ModInt(StoreT i)
    {
        while(i < 0) i += MOD;
        this->i = i;
    }
 
    ModInt(const self_type& i) = default;
    constexpr self_type &operator=(const self_type& i) = default;
 
    constexpr uint_fast32_t getI() const noexcept
    {
        return i;
    }
 
    ModInt& operator +=(self_type rhs)
    {
        AddT i64 = static_cast<AddT>(i);
        StoreT a32 = static_cast<StoreT>((i64 + rhs.i) % MOD);
        i = a32;
        return *this;
    }
 
    constexpr ModInt operator +(self_type rhs) const noexcept
    {
        self_type newInt(*this);
        newInt += rhs;
        return newInt;
    }
 
    ModInt& operator -=(self_type rhs)
    {
        AddT i64 = static_cast<AddT>(i);
        StoreT a32 = static_cast<StoreT>((i64 + MOD - rhs.i) % MOD);
        i = a32;
        return *this;
    }
 
    constexpr ModInt operator -(self_type rhs) const noexcept
    {
        self_type newInt(*this);
        newInt -= rhs;
        return newInt;
    }
 
    ModInt& operator *=(self_type rhs)
    {
        MulT i64 = static_cast<MulT>(i);
        StoreT a32 = static_cast<StoreT>((i64 * rhs.i) % MOD);
        i = a32;
        return *this;
    }
 
    constexpr ModInt operator *(self_type rhs) const noexcept
    {
        self_type newInt(*this);
        newInt *= rhs;
        return newInt;
    }
 
    constexpr ModInt operator /(self_type rhs) const noexcept
    {
        self_type newInt(*this);
        self_type rhsInv = rhs.inv();
        newInt *= rhsInv;
        return newInt;
    }
 
    constexpr bool operator ==(self_type rhs) const noexcept
    {
        return i == rhs.i;
    }
 
    constexpr bool operator <(self_type rhs) const noexcept
    {
        return i < rhs.i;
    }
 
    constexpr bool operator >(self_type rhs) const noexcept
    {
        return rhs < *this;
    }
 
    constexpr ModInt pow(int n) const noexcept
    {
        ModInt a = *this;
        ModInt res = 1;
 
        while (n > 0)
        {
            if (n & 1)
            {
                res *= a;
            }
            a *= a;
            n >>= 1;
        }
        return res;
    }
 
    constexpr self_type inv() const noexcept
    {
        return pow(MOD - 2);
    }
};
 
template<class StoreT, class AddT, class MulT, StoreT MOD>
std::ostream& operator <<(std::ostream& ost, ModInt<StoreT, AddT, MulT, MOD> i)
{
    ost << i.getI();
    return ost;
}
 
using UModInt = ModInt<uint_fast32_t, uint_fast32_t, uint_fast64_t, MOD>;
using SModInt = ModInt<int_fast32_t, int_fast32_t, int_fast64_t, MOD>;
 

template<class ModIntT>
class BinomialFactory
{
    std::vector<ModIntT> stock;
    std::vector<ModIntT> inv;
 
public:
    explicit BinomialFactory(int N)
    {
        stock.resize(N + 1);
        inv.resize(N + 1);
        stock[0] = 1;
        inv[0] = 1;
        for (int i = 1; i <= N; i++)
        {
            stock[i] = stock[i - 1] * i;
            inv[i] = stock[i].inv();
        }
    }
 
    ModIntT bi(int n, int r) const
    {
        if (r == 0 || r == n) return 1;
 
        return stock[n] * inv[n - r] * inv[r];
    }
};


int main()
{
    string S;
    cin >> S;

    using mint2019 = ModInt<uint_fast32_t, uint_fast32_t, uint_fast64_t, 2019>;
    using vi = vector<int>;
    using vvi = vector<vi>;
    using vvvi = vector<vvi>;

    vvvi table(S.size()+1, vvi(2019, vi(10)));
    for (int i = 0; i < 2019; ++i)
    {
        for (int j = 1; j <= 9; ++j)
        {
            table[0][i][j] = 0;
            int ss = i;
            for (int k = 0; k <= S.size(); ++k)
            {
                ss = (i * 10 + j) % 2019;
                int add = (ss == 0);
                table[k+1][i][j] = table[k][i][j] + add;
            }
        }
    }

    int ans = 0;
    vector<int> dp;
    for (size_t i = 0; i < S.size(); i++)
    {
        int d = S[i] - '0';
        for (size_t j = 0; j < i; j++)
        {
            dp[j] = table[dp[j]][d];
            if (dp[j] == 0) ++ans;
//            cout << dp[j] << " " << ans << endl;
        }
        dp.push_back(d);
    }
 
    cout << ans << endl;
}

Compiler output:
a.cc:9:11: error: 'uint_fast64_t' does not name a type
    9 | constexpr uint_fast64_t MOD = 1e9 + 7;
      |           ^~~~~~~~~~~~~
a.cc:30:15: error: 'uint_fast32_t' does not name a type
   30 |     constexpr uint_fast32_t getI() const noexcept
      |               ^~~~~~~~~~~~~
a.cc:133:24: error: 'uint_fast32_t' was not declared in this scope
  133 | using UModInt = ModInt<uint_fast32_t, uint_fast32_t, uint_fast64_t, MOD>;
      |                        ^~~~~~~~~~~~~
a.cc:5:1: note: 'std::uint_fast32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
    4 | #include <algorithm>
  +++ |+#include <cstdint>
    5 | 
a.cc:133:39: error: 'uint_fast32_t' was not declared in this scope
  133 | using UModInt = ModInt<uint_fast32_t, uint_fast32_t, uint_fast64_t, MOD>;
      |                                       ^~~~~~~~~~~~~
a.cc:133:39: note: 'std::uint_fast32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:133:54: error: 'uint_fast64_t' was not declared in this scope
  133 | using UModInt = ModInt<uint_fast32_t, uint_fast32_t, uint_fast64_t, MOD>;
      |                                                      ^~~~~~~~~~~~~
a.cc:133:54: note: 'std::uint_fast64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:133:69: error: 'MOD' was not declared in this scope
  133 | using UModInt = ModInt<uint_fast32_t, uint_fast32_t, uint_fast64_t, MOD>;
      |                                                                     ^~~
a.cc:133:72: error: template argument 1 is invalid
  133 | using UModInt = ModInt<uint_fast32_t, uint_fast32_t, uint_fast64_t, MOD>;
      |                                                                        ^
a.cc:133:72: error: template argument 2 is invalid
a.cc:133:72: error: template argument 3 is invalid
a.cc:133:72: error: template argument 4 is invalid
a.cc:134:24: error: 'int_fast32_t' was not declared in this scope
  134 | using SModInt = ModInt<int_fast32_t, int_fast32_t, int_fast64_t, MOD>;
      |                        ^~~~~~~~~~~~
a.cc:134:38: error: 'int_fast32_t' was not declared in this scope
  134 | using SModInt = ModInt<int_fast32_t, int_fast32_t, int_fast64_t, MOD>;
      |                                      ^~~~~~~~~~~~
a.cc:134:52: error: 'int_fast64_t' was not declared in this scope
  134 | using SModInt = ModInt<int_fast32_t, int_fast32_t, int_fast64_t, MOD>;
      |                                                    ^~~~~~~~~~~~
a.cc:134:66: error: 'MOD' was not declared in this scope
  134 | using SModInt = ModInt<int_fast32_t, int_fast32_t, int_fast64_t, MOD>;
      |                                                                  ^~~
a.cc:134:69: error: template argument 1 is invalid
  134 | using SModInt = ModInt<int_fast32_t, int_fast32_t, int_fast64_t, MOD>;
      |                                                                     ^
a.cc:134:69: error: template argument 2 is invalid
a.cc:134:69: error: template argument 3 is invalid
a.cc:134:69: error: template argument 4 is invalid
a.cc: In function 'int main()':
a.cc:171:29: error: 'uint_fast32_t' was not declared in this scope
  171 |     using mint2019 = ModInt<uint_fast32_t, uint_fast32_t, uint_fast64_t, 2019>;
      |                             ^~~~~~~~~~~~~
a.cc:171:29: note: 'std::uint_fast32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:171:59: error: 'uint_fast64_t' was not declared in this scope
  171 |     using mint2019 = ModInt<uint_fast32_t, uint_fast32_t, uint_fast64_t, 2019>;
      |                                                           ^~~~~~~~~~~~~
a.cc:171:59: note: 'std::uint_fast64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:171:78: error: template argument 1 is invalid
  171 |     using mint2019 = ModInt<uint_fast32_t, uint_fast32_t, uint_fast64_t, 2019>;
      |                                                                              ^
a.cc:171:78: error: template argument 3 is invalid
a.cc:171:78: note: invalid template non-type parameter
a.cc:199:35: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} in assignment
  199 |             dp[j] = table[dp[j]][d];
      |                                   ^