Language: C++

#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

//  unordered_set<string> results;
//  for (ll i = 2019; i <= 200000; i *= 2019) {
//    results.emplace(to_string(i));
//  }

  string S;
  cin >> S;
  ll result = 0;
  REP(i, 0, S.size() - 4) {
    REP (j, 4, 7) {
      if (i + j > S.size()) {
        continue;
      }
      string sub = S.substr(i, j);
//      if (results.find(sub) != results.end()) {
      if (atoi(sub.c_str()) % 2019 == 0) {
//        cout << i << "," << j << endl;
        result++;
      }
    }
  }
  cout << result << endl;

  return 0;
}
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

//  unordered_set<string> results;
//  for (ll i = 2019; i <= 200000; i *= 2019) {
//    results.emplace(to_string(i));
//  }

  string S;
  cin >> S;
  ll result = 0;
  REP(i, 0, S.size() - 4) {
    REP (j, 4, 7) {
      if (i + j > S.size()) {
        continue;
      }
      string sub = S.substr(i, j);
//      if (results.find(sub) != results.end()) {
      if (atoi(sub.c_str()) % 2019 == 0) {
//        cout << i << "," << j << endl;
        result++;
      }
    }
  }
  cout << result << endl;

  return 0;
}


Compiler output:
a.cc:114:14: error: redefinition of 'constexpr const ll kMod'
  114 | constexpr ll kMod = 1e9 + 7;
      |              ^~~~
a.cc:31:14: note: 'constexpr const ll kMod' previously defined here
   31 | constexpr ll kMod = 1e9 + 7;
      |              ^~~~
a.cc:116:4: error: redefinition of 'll gcd(ll, ll)'
  116 | ll gcd(ll a, ll b) {
      |    ^~~
a.cc:33:4: note: 'll gcd(ll, ll)' previously defined here
   33 | ll gcd(ll a, ll b) {
      |    ^~~
a.cc:129:4: error: redefinition of 'll lcm(ll, ll)'
  129 | ll lcm(ll a, ll b) {
      |    ^~~
a.cc:46:4: note: 'll lcm(ll, ll)' previously defined here
   46 | ll lcm(ll a, ll b) {
      |    ^~~
a.cc:133:6: error: redefinition of 'void init()'
  133 | void init() {
      |      ^~~~
a.cc:50:6: note: 'void init()' previously defined here
   50 | void init() {
      |      ^~~~
a.cc:139:5: error: redefinition of 'int main()'
  139 | int main() {
      |     ^~~~
a.cc:56:5: note: 'int main()' previously defined here
   56 | int main() {
      |     ^~~~