Language: C++

 #include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
const int mod=2019 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}

int main() {
   string s;
   cin>>s ;
   ll k= s.size() ;
   vector<ll> a(k) ;
   for(ll i=k-1;i >=;i--){
     if(i==k-1)
     a[i]=s.at(i);
     else
     a[i]=(a[i+1]+s.at(i)*pow(10,k-1-i))%mod;  
   }
   vector<ll> b(2019) ;
   rep(i,k) b[a[i]] ++ ;

  ll ans=0 ;
  rep(j,2019) 
  ans+= b[j]*(b[j]-1) /2 ;
   
   cout<<ans <<endl;
    return 0;
}

------------------------------------

 #include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
  ll n ;
  cin >> n ;
  vector<ll> A(n)  ;
  rep(i,n) cin>> A[i] ;
  vector<ll> cnt(n) ;
  rep(i,n) cnt[A[i]] ++ ;
  ll sum=0 ;
  rep(i,n) sum+= (cnt[i]*(cnt[i]-1) )/2 ;
  rep(i,n){ 
  cout << sum-(cnt[A[i]]-1) <<endl ;
  }
   
    return 0;
}


//count関数



Compiler output:
a.cc:40:9: warning: "rep" redefined
   40 | #define rep(i,n) for (long long i = 0; i < (n); ++i)
      |         ^~~
a.cc:4:9: note: this is the location of the previous definition
    4 | #define rep(i,n) for (int i = 0; i < (n); ++i)
      |         ^~~
a.cc: In function 'int main()':
a.cc:18:21: error: expected primary-expression before ';' token
   18 |    for(ll i=k-1;i >=;i--){
      |                     ^
a.cc:22:41: error: invalid operands of types '__gnu_cxx::__promote<double>::__type' {aka 'double'} and 'const int' to binary 'operator%'
   22 |      a[i]=(a[i+1]+s.at(i)*pow(10,k-1-i))%mod;
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
      |                  |                       |
      |                  |                       const int
      |                  __gnu_cxx::__promote<double>::__type {aka double}
a.cc: At global scope:
a.cc:35:1: error: expected unqualified-id before '--' token
   35 | ------------------------------------
      | ^~
a.cc:44:10: error: redefinition of 'const ll INF'
   44 | const ll INF=1e18 ;
      |          ^~~
a.cc:8:10: note: 'const ll INF' previously defined here
    8 | const ll INF=1e18 ;
      |          ^~~
a.cc:45:13: error: redefinition of 'void chmax(ll&, ll)'
   45 | inline void chmax(ll& a,ll b){a=max(a,b);}
      |             ^~~~~
a.cc:10:13: note: 'void chmax(ll&, ll)' previously defined here
   10 | inline void chmax(ll& a,ll b){a=max(a,b);}
      |             ^~~~~
a.cc:46:13: error: redefinition of 'void chmin(ll&, ll)'
   46 | inline void chmin(ll& a,ll b){a=min(a,b);}
      |             ^~~~~
a.cc:11:13: note: 'void chmin(ll&, ll)' previously defined here
   11 | inline void chmin(ll& a,ll b){a=min(a,b);}
      |             ^~~~~
a.cc:47:5: error: redefinition of 'int main()'
   47 | int main() {
      |     ^~~~
a.cc:13:5: note: 'int main()' previously defined here
   13 | int main() {
      |     ^~~~