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

#include <bits/stdc++.h>
#define LLI long long int
#define pii pair<int, int>
#define fst first
#define sec second
#define ULTRA 2134567890
#define de(x) if (x != 0 && MODE == x)
#define MODE 0
using namespace std;

char S[200007];
int cnt[2019] = {};

int main() {
  int i, j;

  scanf("%s", S);

  int N = strlen(S);

  LLI ans = 0;
  int r = 0;
  int mul = 1;
  for (i = N - 1; i >= 0; i--) {
    r = (r + mul * (S[i] - '0')) % 2019;
    mul = mul * 10 % 2019;

    de(1) printf("r = %d\\n", r);

    if (r == 0) {
      ans += cnt[r] + 1;
    } else {
      ans += cnt[r];
    }

    cnt[r]++;
  }

  printf("%lld\\n", ans);

  return 0;
}

//
//          ___ ___  __________  __________
//         /////\\  \\/\\   ______\\/\\\\\\\\\\\\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \\ \\  \\ \\  \\_____/\\ \\\\\\\\_____/      New Empire of CHSH ...
//       ////   \\ \\  \\ \\  \\      \\ \\\\\\\\\\\\\\\\\\\\\\
//      ////__   \\ \\  \\ \\  \\      \\ \\\\\\\\_____/
//     ///////\\   \\ \\  \\ \\  \\______\\ \\\\\\\\_______   ________
//    ////____/    \\ \\__\\ \\___   ___\\ \\\\\\\\\\\\\\\\\\\\\\ _\\  ___  \\_
//   /__/           \\/__/\\/__/\\  \\__/\\ \\\\\\\\_____//\\  .\\_/\\_  \\
//                           \\ \\  \\   \\ \\\\\\\\\\\\\\\\\\\\\\\\  \\_\\/_\\  \\
// ... with the AC Power of   \\ \\  \\   \\ \\\\\\\\_____/ \\   _____  \\
//   The Great Tsundere Doggy. \\ \\  \\   \\ \\\\\\\\     \\ \\  \\  \\ \\  \\
//                              \\ \\__\\   \\ \\\\\\\\\\\\\\\\\\\\ \\__\\  \\ \\__\\
//                               \\/__/    \\/________/\\/__/   \\/__/
//


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define LLI long long int
#define pii pair<int, int>
#define fst first
#define sec second
#define ULTRA 2134567890
#define de(x) if (x != 0 && MODE == x)
#define MODE 0
using namespace std;

char S[107];
int cnt[2019] = {};

int main() {
  int i, j;

  scanf("%s", S);

  int N = strlen(S);

  LLI ans = 0;
  int r = 0;
  int mul = 1;
  for (i = N - 1; i >= 0; i--) {
    r = (r + mul * (S[i] - '0')) % 2019;
    mul = mul * 10 % 2019;

    de(1) printf("r = %d\\n", r);

    if (r == 0) {
      ans += cnt[r] + 1;
    } else {
      ans += cnt[r];
    }

    cnt[r]++;
  }

  printf("%lld\\n", ans);

  return 0;
}

//
//          ___ ___  __________  __________
//         /////\\  \\/\\   ______\\/\\\\\\\\\\\\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \\ \\  \\ \\  \\_____/\\ \\\\\\\\_____/      New Empire of CHSH ...
//       ////   \\ \\  \\ \\  \\      \\ \\\\\\\\\\\\\\\\\\\\\\
//      ////__   \\ \\  \\ \\  \\      \\ \\\\\\\\_____/
//     ///////\\   \\ \\  \\ \\  \\______\\ \\\\\\\\_______   ________
//    ////____/    \\ \\__\\ \\___   ___\\ \\\\\\\\\\\\\\\\\\\\\\ _\\  ___  \\_
//   /__/           \\/__/\\/__/\\  \\__/\\ \\\\\\\\_____//\\  .\\_/\\_  \\
//                           \\ \\  \\   \\ \\\\\\\\\\\\\\\\\\\\\\\\  \\_\\/_\\  \\
// ... with the AC Power of   \\ \\  \\   \\ \\\\\\\\_____/ \\   _____  \\
//   The Great Tsundere Doggy. \\ \\  \\   \\ \\\\\\\\     \\ \\  \\  \\ \\  \\
//                              \\ \\__\\   \\ \\\\\\\\\\\\\\\\\\\\ \\__\\  \\ \\__\\
//                               \\/__/    \\/________/\\/__/   \\/__/
//