alexjercan/bugnet huggingface dataset:
Problem p02702 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<ii> vii;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr(be, en) for (int i = be; i <= en; i++)
ll mod = LLONG_MAX;
ll power(ll a, ll b) {
  if (b == 0)
    return 1;
  ll ans = power(a, b / 2);
  ans = (ans * ans) % mod;
  if (b % 2)
    ans *= a;
  return ans % mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(NULL);
  cin.tie(NULL);
  string s;
  cin >> s;
  int mod = 2019;
  ll ans = 0;
  vector<vi> dp(3, vi(2020, 0));
  int toggle = 1;
  for (int i = 1; i <= s.size(); i++) {
    int curr = s[i - 1] - '0';
    for (int j = 0; j < 2019; j++)
      dp[toggle][j] = 0;
    dp[toggle][curr] = 1;
    for (int j = 0; j < 2019; j++) {
      dp[toggle][(j * 10 + curr) % mod] += dp[1 - toggle][j];
    }
    ans += dp[toggle][0];
    toggle = 1 - toggle;
  }
  cout << ans;
}

Error: MLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<ii> vii;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr(be, en) for (int i = be; i <= en; i++)
ll mod = LLONG_MAX;
ll power(ll a, ll b) {
  if (b == 0)
    return 1;
  ll ans = power(a, b / 2);
  ans = (ans * ans) % mod;
  if (b % 2)
    ans *= a;
  return ans % mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(NULL);
  cin.tie(NULL);
  string s;
  cin >> s;
  int mod = 2019;
  ll ans = 0;
  vector<vi> dp(s.size() + 2, vi(2020, 0));
  for (int i = 1; i <= s.size(); i++) {
    int curr = s[i - 1] - '0';
    dp[i][curr] = 1;
    for (int j = 0; j < 2019; j++) {
      dp[i][(j * 10 + curr) % mod] += dp[i - 1][j];
    }
    ans += dp[i][0];
  }
  cout << ans;
}
Problem p02702 (C++) — buggy submission, verdict: Time Limit Exceeded

// Patwari26
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define endl '\\n'
#define mii map<ll, ll>
#define pii pair<ll, ll>
#define vi vector<ll>
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define sz(x) (ll) x.size()
#define hell 1000000007
#define INF (1ll << 60)
#define rep(i, a, b) for (ll i = a; i <= b; i++)
#define rrep(i, a, b) for (ll i = a; i >= b; i--)
#define ios                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define time                                                                   \\
  cerr << "\\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N = 100005;
void solve() {
  string s;
  cin >> s;
  vi mm(2019, 0);
  vi mm2(2019, 0);
  ll curr = 0;
  mm[0]++;
  ll ans = 0;
  rep(i, 0, sz(s) - 1) {
    curr = (10 * curr + (s[i] - '0')) % 2019;
    ans = (ans + mm[curr]);
    ll temp = curr;
    mm[temp]++;
    rep(j, 0, 2018) mm2[(j * 10) % 2019] = mm[j];
    mm = mm2;
    // rep(j,0,2019) mm[j]=mm[]
    // cout<<ans<<endl;
    // fill_n(all(mm2),0);
  }
  cout << ans << endl;
}
signed main() {
  ios int TESTS = 1;
  // cin>>TESTS;
  while (TESTS--) {
    solve();
  }
  time return 0;
}

Error: TLE

Fixed submission:

// Patwari26
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define endl '\\n'
#define mii map<ll, ll>
#define pii pair<ll, ll>
#define vi vector<ll>
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define sz(x) (ll) x.size()
#define hell 1000000007
#define INF (1ll << 60)
#define rep(i, a, b) for (ll i = a; i <= b; i++)
#define rrep(i, a, b) for (ll i = a; i >= b; i--)
#define ios                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define time                                                                   \\
  cerr << "\\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N = 100005;
void solve() {
  string s;
  cin >> s;
  mii mm;
  mii mm2;
  ll curr = 0;
  mm[0]++;
  ll ans = 0;
  rep(i, 0, sz(s) - 1) {
    curr = (10 * curr + (s[i] - '0')) % 2019;
    ans = (ans + mm[curr]);
    ll temp = curr;
    mm[temp]++;
    for (auto i : mm) {
      mm2[(i.F * 10) % 2019] = i.S;
    }
    mm = mm2;
    mm2.clear();
  }
  cout << ans << endl;
}
signed main() {
  ios int TESTS = 1;
  // cin>>TESTS;
  while (TESTS--) {
    solve();
  }
  time return 0;
}
Problem p02702 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void) {
  string s;
  cin >> s;
  int l = s.length();
  int r[2019] = {0};
  ll t = 0, p = 1;
  r[0]++;
  for (int i = l - 1; i >= 0; i--) {
    char a = s[i];
    t = t % 2019 + p * (int)(a - '0') % 2019;
    r[t % 2019]++;
    p = p * 10 % 2019;
  }
  ll c = 0;
  for (int i = 0; i < 2019; i++) {
    int m = r[i];
    c += m * (m - 1) / 2;
  }
  cout << c << endl;
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void) {
  string s;
  cin >> s;
  int l = s.length();
  int r[2019] = {0};
  ll t = 0;
  r[0]++;
  for (int i = l - 1; i >= 0; i--) {
    char a = s[i];
    if (i == l - 1)
      t = (int)(a - '0') % 2019;
    else
      t = t % 2019 + (int)pow(10, l - i - 1) * (int)(a - '0') % 2019;
    r[t % 2019]++;
  }
  ll c = 0;
  for (int i = 0; i < 2019; i++) {
    int m = r[i];
    c += m * (m - 1) / 2;
  }
  cout << c << endl;
  return 0;
}
Problem p02702 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <climits>
#include <cstring>
#include <iostream>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>

// usings
using namespace std;

// type def
typedef long long int64;
typedef pair<int, int> ii;

// consts
const int mod = 1e9 + 7;

// methods
template <typename T> bool chmax(T &source, const T &compare_to) {
  if (source < compare_to) {
    source = compare_to;
    return true;
  }
  return false;
}

int modpow(int64 base, int n) {
  int64 ret = 1;
  while (n) {
    if (n & 1)
      ret = ret * base % mod;
    base = base * base % mod;
    n >>= 1;
  }
  return ret;
}

class Solution {
private:
public:
  int solve(string &s) {
    int n = s.size(), ret = 0, p0 = 1;
    int64 sum = 0;
    unordered_map<int, int> cnt;
    cnt[0] = 1;
    for (int i = n - 1; i >= 0; --i) {
      int cur = s[i] - '0';
      (sum += cur * p0 % 2019) %= 2019;
      (p0 *= 10) %= 2019;
      ret += cnt[sum];
      ++cnt[sum];
    }
    return ret;
  }
};

int main() {
  string s;
  cin >> s;
  Solution sol;
  auto ret = sol.solve(s);
  cout << ret << endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <climits>
#include <cstring>
#include <iostream>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>

// usings
using namespace std;

// type def
typedef long long int64;
typedef pair<int, int> ii;

// consts
const int mod = 1e9 + 7;

// methods
template <typename T> bool chmax(T &source, const T &compare_to) {
  if (source < compare_to) {
    source = compare_to;
    return true;
  }
  return false;
}

int modpow(int64 base, int n) {
  int64 ret = 1;
  while (n) {
    if (n & 1)
      ret = ret * base % mod;
    base = base * base % mod;
    n >>= 1;
  }
  return ret;
}

int dp[200000];

class Solution {
private:
public:
  int solve(string &s) {
    int n = s.size(), ret = 0;
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < n; ++i) {
      int cur = s[i] - '0';
      dp[i] = cur;
      for (int j = i - 1; j >= 0; --j) {
        dp[j] = (dp[j] * 10 + cur) % 2019;
        if (dp[j] == 0)
          ++ret;
      }
    }
    return ret;
  }
};

int main() {
  string s;
  cin >> s;
  Solution sol;
  auto ret = sol.solve(s);
  cout << ret << endl;
}
Problem p02702 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef tree<ii, null_type, less<ii>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set;

int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  string s;
  cin >> s;
  int n = s.size();
  vector<ll> ct(2019, 0);
  ll ret = 0, mul = 1;
  int now = 0;
  ct[0] = 1;
  for (int i = n - 1; i >= 0; i--) {
    now = (now + (s[i] - '0') * mul) % 2019;
    ret += ct[now]++;
    mul = (mul * 10) % 2019;
  }
  cout << ret << "\\n";
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef tree<ii, null_type, less<ii>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set;

const int mod = 2019;
const int mx = 2e5 + 77;
bool lst[mx][mod];
int SI[mx];

int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  char S[mx];
  scanf("%s", &S);
  int n = strlen(S);
  for (int i = 0; i < n; i++)
    SI[i] = S[i] - '0';
  ll ret = 0;
  for (int i = 0; i < n; i++) {
    int r = 0, p = 0;
    for (int j = i; j < n; j++) {
      r = (r * 10 + SI[j]) % mod;
      if (lst[j][r])
        break;
      lst[j][r] = true;
      if (!r)
        p++;
    }
    ret += ll(p) * (p + 1) / 2;
  }
  cout << ret << "\\n";
  return 0;
}
Problem p02702 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int i, j;
  string s;
  cin >> s;
  int x = 0;
  VI v(2050);
  v[0]++;
  ll ans = 0;
  VI r(205050);
  r[0] = 1;
  for (i = 1; i < 205050; i++) {
    r[i] = r[i - 1] * 10 % 2019;
  }
  for (i = s.size() - 1; i >= 0; i--) {
    x = x + (s[i] - '0') * r[s.size() - 1 - i];
    x %= 2019;
    ans += v[x];
    v[x]++;
    // cout<<x<<endl;
  }
  cout << ans << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int i, j;
  string s;
  cin >> s;
  int x = 0;
  VI v(2050);
  v[0]++;
  ll ans = 0;
  VI r(2050);
  r[0] = 1;
  for (i = 1; i < 2050; i++) {
    r[i] = r[i - 1] * 10 % 2019;
  }
  for (i = s.size() - 1; i >= 0; i--) {
    x = x + (s[i] - '0') * r[s.size() - 1 - i];
    x %= 2019;
    ans += v[x];
    v[x]++;
    // cout<<x<<endl;
  }
  cout << ans << endl;
}
Problem p02702 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  string s;
  cin >> s;
  vector<int> v(2019, 0);
  v[0]++;
  ll sum = 0, r = 1, ans = 0;
  reverse(s.begin(), s.end());
  for (char c : s) {
    sum += (c - '0') * r;
    sum %= 2019;
    ans += v[sum]++;
    r *= 10;
    r %= 2019;
  }
  cout << ans;
}


Error: WA

Fixed submission:

#include <iostream>
using namespace std;

typedef unsigned long long int ll;

int main() {
  string str;
  cin >> str;
  ll count = 0;
  for (int i = 0; i < str.length() - 3; i++) {
    ll temp;
    temp = stoi(str.substr(i, 4));
    for (int j = i + 4; j < str.length(); j++) {
      temp *= 10;
      temp += int(str[j] - '0');
      if (temp < 2019)
        continue;
      if (temp % 2019 == 0)
        count++;
    }
  }
  cout << count;
}
Problem p02702 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;

const int modNum = 2019;

int main() {
  string s;
  cin >> s;

  reverse(s.begin(), s.end());

  int n = s.size();

  int nowNumRemainder = 0, base = 1, remZeroCount = 0;

  vector<int> remainderCountVec(2019, 0);

  for (const char &singleNumChar : s) {
    nowNumRemainder += (int)(singleNumChar - '0') * base;
    nowNumRemainder %= modNum;

    ++remainderCountVec.at(nowNumRemainder);

    if (nowNumRemainder == 0) {
      ++remZeroCount;
    }

    base *= 10;
    base %= modNum;
  }

  long long ansCount = remZeroCount;

  for (const int &singleRemainderCount : remainderCountVec) {
    ansCount += singleRemainderCount * (singleRemainderCount - 1) / 2;
  }

  cout << ansCount << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

int main() {
  string s;
  cin >> s;

  const int n = s.size();

  // 余りのリスト
  vector<int> remainderVec = {1};

  for (int digitNum = 2; digitNum <= n; ++digitNum) {
    remainderVec.push_back(remainderVec.at(digitNum - 2) * 10 % 2019);
  }

  long long answer = 0;

  for (int endIndex = 3; endIndex < n; ++endIndex) {
    int fourDigitsNum = stoi(s.substr(endIndex - 3, 4));

    int singleRemainder = fourDigitsNum % 2019;

    if (singleRemainder == 0) {
      ++answer;
    }

    int digitNum = 4;

    for (int startIndex = endIndex - 4; startIndex >= 0; --startIndex) {
      ++digitNum;

      int startNumFirstDigit = s.at(startIndex) - '0';

      singleRemainder += remainderVec.at(digitNum - 1) * startNumFirstDigit;
      singleRemainder %= 2019;

      if (singleRemainder == 0) {
        ++answer;
      }
    }
  }

  cout << answer << endl;
}
Problem p02702 (C++) — buggy submission, verdict: Time Limit Exceeded

#include "bits/stdc++.h"

using namespace std;

using ll = long long;

#define FOR(i, l, r) for (size_t i = (l); i < (r); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n + 1)
#define INF 100000000000ULL

size_t a[2][2019];

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  memset(a, 0, sizeof(size_t) * 2 * 2019);

  size_t i;
  size_t sum = 0;
  for (i = 0;; ++i) {
    int c = getchar();
    if (c < '1' || c > '9')
      break;
    c -= '0';
    size_t cur = i % 2;
    size_t nxt = (i + 1) % 2;
    // printf("%d\\n", c);
    a[nxt][c] = 1;
    REP(j, 2019) {
      size_t k = (j * 10 + c) % 2019;
      a[nxt][k] += a[cur][j];
    }
    sum += a[nxt][0];
    memset(a[cur], 0, sizeof(size_t) * 2019);
    // REP(j, 2019) {
    //	a[cur][j] = 0;
    // }
    // printf("---\\n");
  }

  printf("%zu\\n", sum);

  return 0;
}

Error: TLE

Fixed submission:

#include "bits/stdc++.h"

using namespace std;

using ll = long long;

#define FOR(i, l, r) for (size_t i = (l); i < (r); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n + 1)
#define INF 100000000000ULL

array<size_t, 200000> a;

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  // string s;
  // s.reserve(200000);
  // cin >> s;
  // size_t sum = 0;

  // FOR(i, 0, s.length()) {
  //	size_t n = s.at(i)-'0';
  //	FOR(j, i + 1, s.length()) {
  //		n = n * 10 + (s.at(j) - '0');
  //		n %= 2019;
  //		//cout << n << endl;
  //		if (n == 0) sum++;
  //	}
  // }
  // cout << sum << endl;
  size_t sum = 0;

  size_t i;
  for (i = 0;; ++i) {
    int c = getchar();
    if (c < '0' || c > '9')
      break;
    c -= '0';
    // printf("%d\\n", c);
    REP(j, i + 1) {
      a.at(j) = (a.at(j) * 10 + c) % 2019;
      if (a.at(j) == 0)
        sum++;
    }
    // printf("---\\n");
  }

  printf("%zu\\n", sum);

  return 0;
}
Problem p02702 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>

using namespace std;

int main() {
  string s = "";
  cin >> s;
  long long int n = s.size();

  long long int t = 0;
  long long int tens = 1;

  long long int ans = 0;

  vector<long long int> mod(n);
  mod[0] = 1;
  for (int i = 1; i < n; i++) {
    mod[i] = 0;
  }

  for (int i = n - 1; i >= 0; i--) {
    int tmp = (int)(s[i] - '0');
    t = (t + tens * tmp % 2019) % 2019;
    ans += mod[t];
    mod[t]++;
    tens = tens * 10 % 2019;
  }

  cout << ans << endl;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;

  int n = s.length();

  int mod[2019];
  mod[0] = 1;

  int ans = 0;

  for (int i = 1; i < n; i++) {
    mod[i] = 0;
  }

  long long int t = 0, tens = 1;

  for (int i = n - 1; i >= 0; i--) {
    t = (t + tens * (s[i] - '0') % 2019) % 2019;
    // ans+=mod[t];
    mod[t]++;
    tens = tens * 10 % 2019;
  }
  for (int i = 0; i < 2019; i++) {
    ans += mod[i] * (mod[i] - 1) / 2019;
  }
  cout << ans << endl;
}
Problem p02702 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec) { // for debug
  ll n = vec.size();
  cout << "------------------------------------\\n";
  rep(i, n) cout << i << " " << vec.at(i) << "\\n";
  cout << "------------------------------------\\n";
}

void pr2d(vector<vector<ll>> vec) { // for debug
  ll h = vec.size();
  ll w = vec.at(0).size();
  cout << "------------------------------------\\n";
  rep(i, h) {
    rep(j, w) { cout << vec.at(i).at(j) << " "; }
    cout << "\\n";
  }
  cout << "------------------------------------\\n";
}

// main starts here

int main() {
  vector<vector<unsigned short>> dp(200000, vector<unsigned short>(2019, 0));
  string s;
  cin >> s;
  ll ss = s.size();
  ll x = s.at(0) - '0';
  dp[0][x] = 1;
  ll ans = 0;
  for (int i = 1; i < ss; i++) {
    x = s.at(i) - '0';
    for (int j = 0; j < 2019; j++) {
      ll y = (j * 10 + x) % 2019;
      dp[i][y] += dp[i - 1][j];
    }
    dp[i][x]++;
    ans += dp[i][0];
  }
  cout << ans << "\\n";
  return 0;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec) { // for debug
  ll n = vec.size();
  cout << "------------------------------------\\n";
  rep(i, n) cout << i << " " << vec.at(i) << "\\n";
  cout << "------------------------------------\\n";
}

void pr2d(vector<vector<ll>> vec) { // for debug
  ll h = vec.size();
  ll w = vec.at(0).size();
  cout << "------------------------------------\\n";
  rep(i, h) {
    rep(j, w) { cout << vec.at(i).at(j) << " "; }
    cout << "\\n";
  }
  cout << "------------------------------------\\n";
}

// main starts here

int main() {
  unsigned short dp[200000][2019];
  string s;
  cin >> s;
  ll ss = s.size();
  ll x = s.at(0) - '0';
  dp[0][x] = 1;
  ll ans = 0;
  for (int i = 1; i < ss; i++) {
    x = s.at(i) - '0';
    for (int j = 0; j < 2019; j++) {
      ll y = (j * 10 + x) % 2019;
      dp[i][y] += dp[i - 1][j];
    }
    dp[i][x]++;
    ans += dp[i][0];
  }
  cout << ans << "\\n";
  return 0;
}
Problem p02702 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s.size() == 4) {
    cout << 0 << endl;
    return 0;
  }
  int n = s.size();
  int mod[200000];
  mod[n - 1] = s[n - 1] - '0';
  int hoge = 1;
  for (int i = n - 2; i >= 0; i--) {
    hoge *= 10;
    hoge %= 2019;
    mod[i] = (s[i] - '0') * hoge + mod[i + 1];
    mod[i] %= 2019;
  }
  int cnt[2020] = {};
  for (int i = 0; i < n; i++) {
    cnt[mod[i]]++;
  }
  int ans = 0;
  for (int i = 0; i < 2019; i++) {
    ans += cnt[i] * (cnt[i] - 1) / 2;
  }
  ans += cnt[0];
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
string nii[66] = {"12114",  "14133",  "16152",  "18171",  "24228",  "26247",
                  "28226",  "34323",  "36342",  "38361",  "42399",  "44418",
                  "46437",  "48456",  "52494",  "54513",  "56532",  "58551",
                  "62589",  "66627",  "68646",  "72684",  "76722",  "78741",
                  "82779",  "84798",  "86817",  "88836",  "92874",  "94893",
                  "96912",  "98931",  "119121", "123159", "125178", "127197",
                  "129216", "131235", "133254", "135273", "137292", "139311",
                  "143349", "145368", "147387", "151425", "153444", "155463",
                  "157482", "163589", "165558", "167577", "169596", "171615",
                  "173634", "175653", "177672", "179671", "183729", "185748",
                  "187767", "189786", "193824", "195843", "197862", "199881"};
int main() {
  string s;
  cin >> s;
  if (s.size() == 4) {
    cout << 0 << endl;
    return 0;
  }
  if (s.size() == 5) {
    for (int i = 0; i < 32; i++) {
      if (s == nii[i]) {
        cout << 1 << endl;
        return 0;
      }
    }
    cout << 0 << endl;
    return 0;
  }
  int ans = 0;
  for (int i = 0; i < 66; i++) {
    string t = nii[i];
    for (int j = 0; j <= s.size() - t.size(); j++) {
      bool ok = true;
      for (int k = 0; k < t.size(); k++) {
        if (s[j + k] != t[k]) {
          ok = false;
          break;
        }
      }
      if (ok) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}