Problem p02702 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i, a, b) for (int i = a, almo5t = b; i < almo5t; ++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI acos(-1)
#define MOD 1000000007
#define FIN                                                                    \\
  std::ios_base::sync_with_stdio(false);                                       \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)

const int N = 0;

typedef long long int ll;

using namespace std;

int main() {
  FIN;
  // freopen("../input.txt", "r", stdin);freopen("../output.txt", "w", stdout);
  string s;
  cin >> s;
  ll modulo[2020];
  fore(i, 0, 2020) modulo[i] = 0;
  modulo[0] = 1;
  ll temp = 0;
  ll mod10 = 1;
  ll ans = 0;
  fore(i, 0, s.size()) {
    int pos = s.size() - 1 - i;
    temp += ((s[pos] - '0') * mod10) % 2019;
    temp %= 2019;
    mod10 = ((mod10 % 2019) * 10) % 2019;
    modulo[temp]++;
    if (modulo[temp] >= 2) {
      ans += modulo[temp] - 1;
    }
    // cout<<temp<<"\\n";
  }
  cout << ans;
  return 0;
}

// ============== Notes =============== //
// common bugs
// - remove reader
// - fastio
// - int overflow (especially intermediate expressionns)
// - array bounds (indices bigger than MAXN?, is MAXN correct?)
// - special cases (n=1, graph not connected?)
// - re-initialize efficiently between test cases

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i, a, b) for (int i = a, almo5t = b; i < almo5t; ++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI acos(-1)
#define MOD 1000000007
#define FIN                                                                    \\
  std::ios_base::sync_with_stdio(false);                                       \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)

const int N = 0;

typedef long long int ll;

using namespace std;

int main() {
  FIN;
  // freopen("../input.txt", "r", stdin);freopen("../output.txt", "w", stdout);
  string s;
  cin >> s;
  ll modulo[2000];
  fore(i, 0, 2000) modulo[i] = 0;
  modulo[0] = 1;
  ll temp = 0;
  ll mod10 = 1;
  ll ans = 0;
  fore(i, 0, s.size()) {
    int pos = s.size() - 1 - i;
    temp += ((s[pos] - '0') * mod10) % 2019;
    temp %= 2019;
    mod10 = ((mod10 % 2019) * 10) % 2019;
    modulo[temp]++;
    if (modulo[temp] >= 2) {
      ans += modulo[temp] - 1;
    }
    // cout<<temp<<"\\n";
  }
  cout << ans;
  return 0;
}

// ============== Notes =============== //
// common bugs
// - remove reader
// - fastio
// - int overflow (especially intermediate expressionns)
// - array bounds (indices bigger than MAXN?, is MAXN correct?)
// - special cases (n=1, graph not connected?)
// - re-initialize efficiently between test cases