Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 2019;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)






// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int mcal(LL a,LL b){
    LL c = a%MOD;
    return c * modinv(b,MOD) % MOD;
}





int modPow(LL x, LL y){
    LL r = 1, a = x % MOD;
    while(y > 0){
        if((y&1) == 1) r = (r*a) % MOD;
        a = (a*a) % MOD;
        y /= 2;
    }
    return r;
}


int main() {
    int ni = 2019;

    string S;cin >> S;
    int N = S.size();
    vector<int> rui(N+1);
    rui[0] = 0;
    rep(i,N){
        LL c = S[i] -'0';
        LL tmp = modPow(10,i+1);
        
        LL kk = (c*tmp)%MOD;

        rui[i+1] = (rui[i] + kk) % MOD;
    }
    vector<vector<int>> v(2019);

// rep(i,N+1)cout << rui[i] << endl;

    rep(i,N+1){
        int m = rui[i];
        int t = (ni - m + 2019) % MOD;
        v[t].push_back(i);
    }

    vector<int> ch = rui;
    sort(all(ch));

    LL ans = 0;

    rep(i,N){
        int cc = S[i] - '0';
        int tm = (2019 - rui[i]) % MOD;
        int ttm = modPow(10,i+1);

        int vol = (ni - cc) % MOD;

        if(binary_search(all(ch),vol)){
            int xx = v[v[mcal((2019 - vol),ttm)]].size();
            int yy = upper_bound(all(v[mcal((2019 - vol),ttm)]), i) - v[v[mcal((2019 - vol),ttm)]].begin();

            if(xx <= yy)continue;
            ans += (xx - yy);
        }
    }

    cout << ans << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:93:23: error: no match for 'operator[]' (operand types are 'std::vector<std::vector<int> >' and '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'})
   93 |             int xx = v[v[mcal((2019 - vol),ttm)]].size();
      |                       ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; reference = std::vector<int>&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1147:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; const_reference = const std::vector<int>&; size_type = long unsigned int]'
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1147:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
a.cc:94:72: error: no match for 'operator[]' (operand types are 'std::vector<std::vector<int> >' and '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'})
   94 |             int yy = upper_bound(all(v[mcal((2019 - vol),ttm)]), i) - v[v[mcal((2019 - vol),ttm)]].begin();
      |                                                                        ^
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; reference = std::vector<int>&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1147:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; const_reference = const std::vector<int>&; size_type = long unsigned int]'
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1147:28: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~