Language: C++

//26/04/2020
#include<bits/stdc++.h>
#include<cmath>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define debug printf("Debug\n");
#define en '\n'


#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 2019

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};

//Algos
template<typename T> using Pbds=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

//Number Theory
template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

//Geometry
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan2( double(y1-y2) , double(x1-x2));}


/*Containers*/
vector<ll>v;
deque<ll>dq;
stack<ll>stk;
map<ll,ll>mp;
unordered_map<ll,ll>ump;
set<ll>st;
multiset<ll>mst;
unordered_set<ll>ust;
unordered_multiset<ll>umst;
priority_queue<ll,deque<ll>,greater<ll>>pq;
Pbds<ll>ost;

string s;
ll c[200005];
ll len;
ll cum[2020][200005];

int main(){
    _fastio
    cin>>s;
    len=s.length();
    reverse(s.begin(),s.end());

    ll su=0;
    ll p=1;
    for(ll i=0;i<len;i++){
        ll d=s[i]-'0';
        ll x=(d%mod*p%mod)%mod;
        su=(su%mod+x%mod)%mod;
        p*=10;
        p%=mod;
        c[i+1]=su;
    }

    for(ll i=0;i<=2020;i++){
        for(ll j=1;j<=len;j++){
            if(c[j]==i){
                cum[i][j]=cum[i][j-1]+1;
            }
            else cum[i][j]=cum[i][j-1];
        }
    }


    ll ans=0;
    for(ll i=0;i<=2018;i++){
        ll x=cum[i][len];
        if(x>=1&&i>0) ans+=(x-1);
        else ans+=x;
    }

    cout<<ans<<en;

    return 0;
}


Compiler output:
/tmp/cc54bkb8.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x681): relocation truncated to fit: R_X86_64_PC32 against symbol `guard variable for __gnu_pbds::detail::bin_search_tree_set<long long, __gnu_pbds::null_type, std::less<long long>, __gnu_pbds::detail::tree_traits<long long, __gnu_pbds::null_type, std::less<long long>, __gnu_pbds::tree_order_statistics_node_update, __gnu_pbds::rb_tree_tag, std::allocator<char> >, std::allocator<char> >::s_node_allocator' defined in .bss._ZGVN10__gnu_pbds6detail19bin_search_tree_setIxNS_9null_typeESt4lessIxENS0_11tree_traitsIxS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_E16s_node_allocatorE[_ZGVN10__gnu_pbds6detail19bin_search_tree_setIxNS_9null_typeESt4lessIxENS0_11tree_traitsIxS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_E16s_node_allocatorE] section in /tmp/cc54bkb8.o
a.cc:(.text+0x68f): relocation truncated to fit: R_X86_64_PC32 against symbol `guard variable for __gnu_pbds::detail::bin_search_tree_set<long long, __gnu_pbds::null_type, std::less<long long>, __gnu_pbds::detail::tree_traits<long long, __gnu_pbds::null_type, std::less<long long>, __gnu_pbds::tree_order_statistics_node_update, __gnu_pbds::rb_tree_tag, std::allocator<char> >, std::allocator<char> >::s_node_allocator' defined in .bss._ZGVN10__gnu_pbds6detail19bin_search_tree_setIxNS_9null_typeESt4lessIxENS0_11tree_traitsIxS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_E16s_node_allocatorE[_ZGVN10__gnu_pbds6detail19bin_search_tree_setIxNS_9null_typeESt4lessIxENS0_11tree_traitsIxS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_E16s_node_allocatorE] section in /tmp/cc54bkb8.o
a.cc:(.text+0x699): relocation truncated to fit: R_X86_64_PC32 against symbol `__gnu_pbds::detail::bin_search_tree_set<long long, __gnu_pbds::null_type, std::less<long long>, __gnu_pbds::detail::tree_traits<long long, __gnu_pbds::null_type, std::less<long long>, __gnu_pbds::tree_order_statistics_node_update, __gnu_pbds::rb_tree_tag, std::allocator<char> >, std::allocator<char> >::s_node_allocator' defined in .bss._ZN10__gnu_pbds6detail19bin_search_tree_setIxNS_9null_typeESt4lessIxENS0_11tree_traitsIxS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_E16s_node_allocatorE[_ZN10__gnu_pbds6detail19bin_search_tree_setIxNS_9null_typeESt4lessIxENS0_11tree_traitsIxS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_E16s_node_allocatorE] section in /tmp/cc54bkb8.o
a.cc:(.text+0x6b0): relocation truncated to fit: R_X86_64_PC32 against symbol `__gnu_pbds::detail::bin_search_tree_set<long long, __gnu_pbds::null_type, std::less<long long>, __gnu_pbds::detail::tree_traits<long long, __gnu_pbds::null_type, std::less<long long>, __gnu_pbds::tree_order_statistics_node_update, __gnu_pbds::rb_tree_tag, std::allocator<char> >, std::allocator<char> >::s_node_allocator' defined in .bss._ZN10__gnu_pbds6detail19bin_search_tree_setIxNS_9null_typeESt4lessIxENS0_11tree_traitsIxS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_E16s_node_allocatorE[_ZN10__gnu_pbds6detail19bin_search_tree_setIxNS_9null_typeESt4lessIxENS0_11tree_traitsIxS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_E16s_node_allocatorE] section in /tmp/cc54bkb8.o
/tmp/cc54bkb8.o: in function `__gnu_pbds::detail::bin_search_tree_set<long long, __gnu_pbds::null_type, std::less<long long>, __gnu_pbds::detail::tree_traits<long long, __gnu_pbds::null_type, std::less<long long>, __gnu_pbds::tree_order_statistics_node_update, __gnu_pbds::rb_tree_tag, std::allocator<char> >, std::allocator<char> >::~bin_search_tree_set()':
a.cc:(.text._ZN10__gnu_pbds6detail19bin_search_tree_setIxNS_9null_typeESt4lessIxENS0_11tree_traitsIxS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_ED2Ev[_ZN10__gnu_pbds6detail19bin_search_tree_setIxNS_9null_typeESt4lessIxENS0_11tree_traitsIxS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_ED5Ev]+0x39): relocation truncated to fit: R_X86_64_PC32 against symbol `__gnu_pbds::detail::bin_search_tree_set<long long, __gnu_pbds::null_type, std::less<long long>, __gnu_pbds::detail::tree_traits<long long, __gnu_pbds::null_type, std::less<long long>, __gnu_pbds::tree_order_statistics_node_update, __gnu_pbds::rb_tree_tag, std::allocator<char> >, std::allocator<char> >::s_node_allocator' defined in .bss._ZN10__gnu_pbds6detail19bin_search_tree_setIxNS_9null_typeESt4lessIxENS0_11tree_traitsIxS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_E16s_node_allocatorE[_ZN10__gnu_pbds6detail19bin_search_tree_setIxNS_9null_typeESt4lessIxENS0_11tree_traitsIxS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_E16s_node_allocatorE] section in /tmp/cc54bkb8.o
/tmp/cc54bkb8.o: in function `__gnu_pbds::detail::bin_search_tree_set<long long, __gnu_pbds::null_type, std::less<long long>, __gnu_pbds::detail::tree_traits<long long, __gnu_pbds::null_type, std::less<long long>, __gnu_pbds::tree_order_statistics_node_update, __gnu_pbds::rb_tree_tag, std::allocator<char> >, std::allocator<char> >::bin_search_tree_set()':
a.cc:(.text._ZN10__gnu_pbds6detail19bin_search_tree_setIxNS_9null_typeESt4lessIxENS0_11tree_traitsIxS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_EC2Ev[_ZN10__gnu_pbds6detail19bin_search_tree_setIxNS_9null_typeESt4lessIxENS0_11tree_traitsIxS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_EC5Ev]+0x34): relocation truncated to fit: R_X86_64_PC32 against symbol `__gnu_pbds::detail::bin_search_tree_set<long long, __gnu_pbds::null_type, std::less<long long>, __gnu_pbds::detail::tree_traits<long long, __gnu_pbds::null_type, std::less<long long>, __gnu_pbds::tree_order_statistics_node_update, __gnu_pbds::rb_tree_tag, std::allocator<char> >, std::allocator<char> >::s_node_allocator' defined in .bss._ZN10__gnu_pbds6detail19bin_search_tree_setIxNS_9null_typeESt4lessIxENS0_11tree_traitsIxS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_E16s_node_allocatorE[_ZN10__gnu_pbds6detail19bin_search_tree_setIxNS_9null_typeESt4lessIxENS0_11tree_traitsIxS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_E16s_node_allocatorE] section in /tmp/cc54bkb8.o
/tmp/cc54bkb8.o: in function `__gnu_pbds::detail::bin_search_tree_set<long long, __gnu_pbds::null_type, std::less<long long>, __gnu_pbds::detail::tree_traits<long long, __gnu_pbds::null_type, std::less<long long>, __gnu_pbds::tree_order_statistics_node_update, __gnu_pbds::rb_tree_tag, std::allocator<char> >, std::allocator<char> >::clear_imp(__gnu_pbds::detail::rb_tree_node_<long long, unsigned long, std::allocator<char> >*)':
a.cc:(.text._ZN10__gnu_pbds6detail19bin_search_tree_setIxNS_9null_typeESt4lessIxENS0_11tree_traitsIxS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_E9clear_impEPNS0_13rb_tree_node_IxmS8_EE[_ZN10__gnu_pbds6detail19bin_search_tree_setIxNS_9null_typeESt4lessIxENS0_11tree_traitsIxS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_E9clear_impEPNS0_13rb_tree_node_IxmS8_EE]+0x41): relocation truncated to fit: R_X86_64_PC32 against symbol `__gnu_pbds::detail::bin_search_tree_set<long long, __gnu_pbds::null_type, std::less<long long>, __gnu_pbds::detail::tree_traits<long long, __gnu_pbds::null_type, std::less<long long>, __gnu_pbds::tree_order_statistics_node_update, __gnu_pbds::rb_tree_tag, std::allocator<char> >, std::allocator<char> >::s_node_allocator' defined in .bss._ZN10__gnu_pbds6detail19bin_search_tree_setIxNS_9null_typeESt4lessIxENS0_11tree_traitsIxS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_E16s_node_allocatorE[_ZN10__gnu_pbds6detail19bin_search_tree_setIxNS_9null_typeESt4lessIxENS0_11tree_traitsIxS2_S4_NS_33tree_order_statistics_node_updateENS_11rb_tree_tagESaIcEEES8_E16s_node_allocatorE] section in /tmp/cc54bkb8.o
collect2: error: ld returned 1 exit status