Language: C++

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 2019;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    string s;
    cin >> s;
    reverse(all(s));
    ll n = s.size();
    ll ten = 1;
    ll now = 0;
    unordered_map<ll, ll> mp{0, 0};
    rep(i, n) {
        now = (now + (s[i] - '0') * ten) % 2019;
        ten *= 10;
        ten %= 2019;
        mp[now]++;
    }
    ll ans = 0;
    each(e, mp) {
        ans += e.second * (e.second - 1) / 2;
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Compiler output:
In file included from /usr/include/c++/14/bits/hashtable.h:35,
                 from /usr/include/c++/14/bits/unordered_map.h:33,
                 from /usr/include/c++/14/unordered_map:41,
                 from /usr/include/c++/14/functional:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'void std::__detail::_Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_M_insert_range(_InputIterator, _InputIterator, const _NodeGetter&, std::true_type) [with _InputIterator = int; _NodeGetter = std::__detail::_AllocNode<std::allocator<std::__detail::_Hash_node<std::pair<const long long int, long long int>, false> > >; _Key = long long int; _Value = std::pair<const long long int, long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<long long int>; _Hash = std::hash<long long int>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<false, false, true>; std::true_type = std::true_type]':
/usr/include/c++/14/bits/hashtable_policy.h:1003:26:   required from 'void std::__detail::_Insert_base<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::insert(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = long long int; _Value = std::pair<const long long int, long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<long long int>; _Hash = std::hash<long long int>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<false, false, true>]'
 1003 |           return _M_insert_range(__first, __last, __node_gen, __unique_keys{});
      |                  ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable.h:1278:21:   required from 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable(_InputIterator, _InputIterator, size_type, const _Hash&, const _Equal&, const allocator_type&, std::true_type) [with _InputIterator = int; _Key = long long int; _Value = std::pair<const long long int, long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<long long int>; _Hash = std::hash<long long int>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<false, false, true>; size_type = long unsigned int; allocator_type = std::allocator<std::pair<const long long int, long long int> >; std::true_type = std::true_type]'
 1278 |       { this->insert(__f, __l); }
      |         ~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/hashtable.h:577:23:   required from 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable(_InputIterator, _InputIterator, size_type, const _Hash&, const key_equal&, const allocator_type&) [with _InputIterator = int; _Key = long long int; _Value = std::pair<const long long int, long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<long long int>; _Hash = std::hash<long long int>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<false, false, true>; size_type = long unsigned int; key_equal = std::equal_to<long long int>; allocator_type = std::allocator<std::pair<const long long int, long long int> >]'
  577 |                      __unique_keys{})
      |                                     ^
/usr/include/c++/14/bits/unordered_map.h:184:4:   required from 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(_InputIterator, _InputIterator, size_type, const hasher&, const key_equal&, const allocator_type&) [with _InputIterator = int; _Key = long long int; _Tp = long long int; _Hash = std::hash<long long int>; _Pred = std::equal_to<long long int>; _Alloc = std::allocator<std::pair<const long long int, long long int> >; size_type = long unsigned int; hasher = std::hash<long long int>; key_equal = std::equal_to<long long int>; allocator_type = std::allocator<std::pair<const long long int, long long int> >]'
  184 |         : _M_h(__first, __last, __n, __hf, __eql, __a)
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:58:34:   required from here
   58 |     unordered_map<ll, ll> mp{0, 0};
      |                                  ^
/usr/include/c++/14/bits/hashtable_policy.h:1021:25: error: invalid type argument of unary '*' (have 'int')
 1021 |           __h._M_insert(*__first, __node_gen, __uks);
      |                         ^~~~~~~~