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

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

#define SIZE_OF_ARRAY(array) sizeof(array) / sizeof(array[0])

int main() {
  long long X;
  cin >> X;
  long long year = 0;
  for (long long i = 100; i < X;) {
    i += i * 0.01;
    year++;
  }
  cout << year;
}

Error: TLE

Fixed submission:

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

#define SIZE_OF_ARRAY(array) sizeof(array) / sizeof(array[0])

int main() {
  long long X;
  cin >> X;
  int year = 0;
  for (int i = 100; i < X;) {
    i *= 1.01;
    year++;
  }
  cout << year;
}
Problem p02694 (C++) — buggy submission, verdict: Time Limit Exceeded

/**
 *    author:  Baibhav Kumar
 *    created: 24.07.2020 19:00:00
 **/

#include <bits/stdc++.h>

using namespace std;

int main() {
  long long n;
  cin >> n;
  long long rs = 100, step = 0;
  while (rs < n) {
    rs += rs / 100;
    step++;
  }
  cout << step << endl;
}


Error: TLE

Fixed submission:

/**
 *    author:  Baibhav Kumar
 *    created: 24.07.2020 19:00:00
 **/

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  int rs = 100, step = 0;
  while (rs < n) {
    rs += rs / 100;
    step++;
  }
  cout << step << endl;
}
Problem p02694 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {
  long X, deposit;
  cin >> X;
  long i = 0;
  deposit = 100;
  while (deposit < X) {
    deposit *= 1.01;
    i++;
  }

  cout << i << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  long X, deposit;
  cin >> X;
  long i = 0;
  deposit = 1;
  while (deposit < X) {
    deposit *= 1.01;
    i++;
  }

  cout << i << endl;
  return 0;
}
Problem p02694 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define PRINT(V)                                                               \\
  for (auto v : (V))                                                           \\
  cout << v << " "
const long long INF = 1LL << 60;
using namespace std;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

int main() {
  long int x;
  int cnt = 0;
  cin >> x;
  long int y = 100;

  while (y - x < 0) {
    y = y * 1.01;
    cnt++;
  }

  cout << cnt;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define PRINT(V)                                                               \\
  for (auto v : (V))                                                           \\
  cout << v << " "
const long long INF = 1LL << 60;
using namespace std;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

int main() {
  long long int x;
  int cnt = 0;
  cin >> x;
  long long int y = 100;

  while (y - x < 0) {
    y = int(y * 1.01);
    cnt++;
  }

  cout << cnt;
  return 0;
}
Problem p02694 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  long long x, y = 100, i = 0;
  cin >> x;
  for (; y < x; i++) {
    y *= 1.01;
  }
  cout << i;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int x, y = 100, i = 0;
  cin >> x;
  for (; y < x; i++) {
    y *= 1.01;
  }
  cout << i;
}
Problem p02694 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {

  long long goalNum;
  cin >> goalNum;

  long long startingNum = 100;

  int years = 0;

  while (startingNum < goalNum) {
    startingNum += startingNum / 100;
    years++;
  }
  cout << years;

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {

  int goalNum;
  cin >> goalNum;

  int startingNum = 100;

  int years = 0;

  while (startingNum < goalNum) {
    startingNum += startingNum / 100;
    years++;
  }
  cout << years;

  return 0;
}
Problem p02694 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {

  long long x;
  cin >> x;
  long long sum = 100;
  int count = 0;
  while (sum < x) {
    sum = sum * 1.01;
    count++;
  }
  cout << count << endl;
}

Error: TLE

Fixed submission:

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

int main() {

  int X;
  int count = 0;
  cin >> X;
  int a = 100;
  while (a < X) {
    a = a * 1.01;
    count++;
  }
  cout << count << endl;
}
Problem p02694 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long long X;
  cin >> X;
  int sum = 0;
  long long mon = 100;
  while (mon < X) {
    mon += mon / 100;
    sum++;
  }

  cout << sum << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  long long X;
  cin >> X;
  int sum = 0;
  int mon = 100;
  while (mon < X) {
    mon += mon / 100;
    sum++;
  }

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

#include <iostream>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long x, yokin;
  int i;
  cin >> x;
  yokin = 100;
  for (i = 0; yokin < x; i++) {
    yokin = yokin * 1.01;
  }

  cout << i << "\\n";
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x, yokin, i;
  cin >> x;
  yokin = 100;
  for (i = 0; yokin < x; i++) {
    yokin = yokin * 1.01;
  }

  cout << i << "\\n";
  return 0;
}
Problem p02694 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x, s = 100;
  cin >> x;

  long long y = 0;
  while (s > 0) {
    if (s >= x) {
      break;
    }
    s += s / 100;
    y++;
  }
  cout << y << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, s = 100;
  cin >> x;

  int y = 0;
  while (true) {
    if (s >= x) {
      break;
    }
    s += s / 100;
    y++;
  }
  cout << y << endl;
}
Problem p02694 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int64_t X;
  cin >> X;

  int64_t sum = 100;
  int year = 0;
  while (sum < X) {
    sum = sum * 1.01;
    year++;
  }

  cout << year << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  int X;
  cin >> X;

  int sum = 100;
  int year = 0;
  while (sum < X) {
    sum = sum * 101 / 100;
    year++;
  }

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

#include <iostream>
#include <set>
#include <string>
using namespace std;
int main() {
  long long X;
  long long a = 100;
  cin >> X;
  int cnt = 0;
  while (a < X) {
    a += a / 100;
    cnt++;
  }
  cout << cnt;
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <set>
#include <string>
using namespace std;
int main() {
  long long X;
  int a = 100;
  cin >> X;
  int cnt = 0;
  while (a < X) {
    a += a / 100;
    cnt++;
  }
  cout << cnt;
  return 0;
}
Problem p02694 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x;
  cin >> x;
  long long p = 100, step = 0;
  while (p < x) {
    p += p / 100;
    step++;
  }
  cout << step << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int x;
  cin >> x;
  int p = 100, step = 0;
  while (p < x) {
    p += p / 100;
    step++;
  }
  cout << step << endl;
}
Problem p02694 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long long int s;
  cin >> s;
  long long int k = 100;
  int y = 0;
  while (k < s) {
    k = k + k / 100;
    y++;
  }
  cout << y;
}


Error: TLE

Fixed submission:

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

int main() {
  int s;
  cin >> s;
  int k = 100;
  int y = 0;
  while (k < s) {
    k += k / 100;
    y++;
  }
  cout << y;
}
Problem p02694 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long X;
  cin >> X;
  long long P = 100, step = 0;
  while (P < X) {
    P += P / 100;
    step++;
  }
  cout << step << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  long long X;
  cin >> X;
  int sum = 0;
  long long mon = 100;
  while (mon < X) {
    mon = +mon / 100;
    sum++;
  }

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

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  long X;
  long Y = 100;
  long C = 0;
  cin >> X;
  while (Y < X) {
    Y += Y / 100;
    C++;
  }
  cout << (C) << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int X;
  int Y = 100;
  int C = 0;
  cin >> X;
  while (Y < X) {
    Y += Y / 100;
    C++;
  }
  cout << (C) << endl;
}
Problem p02694 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  double x;
  long i, a = 100;

  cin >> x;

  for (i = 0; a < x; i++) {
    a = a * 1.01;
  }

  cout << i << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  double x;
  int i, a = 100;

  cin >> x;

  for (i = 0; a < x; i++) {
    a = a * 1.01;
  }

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

#include <iostream>

using namespace std;

int main() {
  long x;
  cin >> x;
  long y = 0;
  long a = 100;
  while (a < x) {
    a = a + (0.01) * a;
    y++;
  }

  cout << y << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  long long x;
  cin >> x;
  long long y = 0;
  long long a = 100;
  while (a < x) {
    a = (101 % 100) * a;
    y++;
  }
  cout << y << endl;
  return 0;
}
Problem p02694 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
// #include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (int i = (a), i##formax = (b); i < i##formax; i++)
typedef long long ll;

int main() {
  ll x;
  cin >> x;
  ll deposit = 100;
  ll year = 0;
  while (true) {
    deposit += deposit / 100;
    year++;
    if (deposit >= x)
      break;
  }
  cout << year << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
// #include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (int i = (a), i##formax = (b); i < i##formax; i++)
typedef long long ll;

int main() {
  ll x;
  cin >> x;
  ll deposit = 100;
  ll year = 0;
  while (true) {
    deposit += deposit / 100 % 10;
    year++;
    if (deposit >= x)
      break;
  }
  cout << year << endl;
  return 0;
}
Problem p02694 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long long X, ans = 100, count = 0;
  cin >> X;
  while (ans < X) {
    ans += ans / 100;
    count++;
  }

  cout << count << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  int a = 100, X;
  cin >> X;

  for (int i = 0;; i++) {
    a = a + a / 100;
    if (a >= X) {
      cout << i + 1 << endl;
      break;
    }
  }
}
Problem p02694 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int64_t X, yokin;
  cin >> X;
  yokin = 100;
  int i = 0;
  while (1) {
    if (yokin >= X)
      break;
    i++;
    yokin += (int64_t)(yokin * 0.01);
  }
  cout << i << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int X, a, yokin;
  int i = 0;
  cin >> X;
  yokin = 100;
  while (1) {
    if (yokin >= X)
      break;
    yokin += yokin / 100;
    i++;
  }
  cout << i << endl;
}
Problem p02694 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long long x;
  cin >> x;

  long long money = 100;
  long long cnt = 0;

  while (1) {
    cnt++;
    money *= 1.01;
    if (money >= x) {
      cout << cnt << endl;
      break;
    }
  }
}


Error: TLE

Fixed submission:

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

int main() {
  int x;
  cin >> x;

  int money = 100;
  int cnt = 0;

  while (1) {
    cnt++;
    money *= 1.01;
    if (money >= x) {
      cout << cnt << endl;
      break;
    }
  }
}
Problem p02694 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int x;
  cin >> x;
  long long int a = 100, b, c = 0;
  while (a < x) {
    a = a + a / 100;
    c++;
  }
  cout << c;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int x;
  cin >> x;
  int a = 100, b, c = 0;
  while (a < x) {
    a = a + a / 100;
    c++;
  }
  cout << c;
}
Problem p02694 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

signed main() {
  ll X;
  cin >> X;

  ll a = 100;
  ll cnt = 0;

  while (1) {
    cnt++;
    a = a * 1.01;
    if (X <= a)
      break;
  }

  cout << cnt << endl;
}


Error: TLE

Fixed submission:

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

int main(void) {
  unsigned long X, N;

  cin >> X;
  unsigned long long m = 100;
  unsigned long cnt = 0;
  for (unsigned long i = 1; i <= 1000000000000000000; i++) {
    m = (m * 101) / 100;
    if (X <= m) {
      cnt = i;
      break;
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p02694 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

long long X;
long long money = 100;

int main() {
  cin >> X;
  int cnt = 0;
  while (X > money) {
    money = money * 1.01;
    cnt++;
  }
  cout << cnt;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int X;
int money = 100;

int main() {
  cin >> X;
  int cnt = 0;
  while (X > money) {
    money = money * 1.01;
    cnt++;
  }
  cout << cnt;
}
Problem p02695 (C++) — buggy submission, verdict: Runtime Error

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// const ll INF = 1e18;
// const ll MOD = 1e9+7;
// const double pi = 3.14159265358979;
using vl = vector<ll>;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (ll i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (ll i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (ll i = ((int)(n)); i > 0; --i)
#define all(x) (x).begin(), (x).end()

ll N, M, Q;

vector<vl> v;
vl history;

void dfs(ll dep, ll x) {
  if (dep == N) {
    vl copied = history;
    v.push_back(copied);
    return;
  } else {
    for (ll i = x; i <= M; i++) {
      history[dep] = i;
      dfs(dep + 1, i);
    }
  }
}

int Main() {
  cin >> N >> M >> Q;
  vl a(Q);
  vl b(Q);
  vl c(Q);
  vl d(Q);

  rep(i, Q) {
    cin >> a[i];
    cin >> b[i];
    cin >> c[i];
    cin >> d[i];
  }

  history.resize(N);
  dfs(0, 1);
  //
  //    for (auto &e: v) {
  //        for (auto u: e) {
  //            cout << u << " ";
  //        }
  //        cout << endl;
  //    }
  //
  ll ans = 0;
  for (auto &e : v) {
    ll sum = 0;
    rep(i, Q) {
      if (e[b[i] - 1] - e[a[i] - 1] == c[i]) {
        sum += d[i];
      }
    }
    ans = max(ans, sum);
  }

  cout << ans << endl;

  return 0;
}

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


Error: -6
munmap_chunk(): invalid pointer


Fixed submission:

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// const ll INF = 1e18;
// const ll MOD = 1e9+7;
// const double pi = 3.14159265358979;
using vl = vector<ll>;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (ll i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (ll i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (ll i = ((int)(n)); i > 0; --i)
#define all(x) (x).begin(), (x).end()

ll N, M, Q;

int Main() {
  cin >> N >> M >> Q;
  vl a(Q);
  vl b(Q);
  vl c(Q);
  vl d(Q);

  rep(i, Q) {
    cin >> a[i];
    cin >> b[i];
    cin >> c[i];
    cin >> d[i];
  }

  vector<vl> v;

  ll depth = 1;

  vl history(N);

  queue<ll> q;

  reps(z, M - N) {
    q.push(z);
    history[depth] = z;
    while (!q.empty()) {
      ll now = q.front();
      q.pop();
      depth++;
      history[depth] = now;
      if (depth == N) {
        vl copied = history;
        v.push_back(copied);
        q.pop();
      } else {
        for (ll i = now + 1; i <= M; i++) {
          q.push(i);
        }
      }
    }
  }

  //    vl A(N);
  //    reps(j, M-N) {
  //        A[0] = j;
  //        reps(i, N-1) {
  //            A[i] = i+1+M-N;
  //        }
  //    }

  //    v.push_back(A);

  ll ans = 0;
  for (auto &e : v) {
    ll sum = 0;
    rep(i, Q) {
      if (e[b[i]] - e[a[i]] == c[i]) {
        sum += d[i];
      }
    }
    ans = max(ans, sum);
  }

  cout << ans << endl;

  return 0;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  Main();
  return 0;
}
Problem p02695 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  ll N, M, Q, ans = 0;
  cin >> N >> M >> Q;
  vector<ll> a(Q, 0);
  vector<ll> b(Q, 0);
  vector<ll> c(Q, 0);
  vector<ll> d(Q, 0);
  vector<ll> A(11, 1);

  for (int i = 0; i < Q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }

  for (int i = 1; i <= M; i++) {
    A[1] = i;
    for (int j = i; j <= M; j++) {
      A[2] = j;
      for (int k = j; k <= M; k++) {
        A[3] = k;
        for (int l = k; l <= M; l++) {
          A[4] = l;
          for (int m = l; m <= M; m++) {
            A[5] = m;
            for (int n = m; n <= M; n++) {
              A[6] = n;
              for (int o = n; o <= M; o++) {
                A[7] = o;
                for (int p = o; p <= M; p++) {
                  A[8] = p;
                  for (int q = p; q <= M; q++) {
                    A[9] = q;
                    for (int r = q; r <= M; r++) {
                      A[10] = r;
                      ll tmp_ans = 0;
                      for (int num = 0; num < Q; num++) {
                        if (A[b[num]] - A[a[num]] == c[num])
                          tmp_ans += d[num];
                      }
                      ans = max(ans, tmp_ans);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
}


Error: -6
Fatal glibc error: malloc assertion failure in sysmalloc: (old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)


Fixed submission:

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

int main() {
  ll N, M, Q, ans = 0;
  cin >> N >> M >> Q;
  vector<ll> a(Q, 0);
  vector<ll> b(Q, 0);
  vector<ll> c(Q, 0);
  vector<ll> d(Q, 0);
  vector<ll> A(Q + 1, 1);

  for (int i = 0; i < Q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }

  for (int i = 1; i <= 10; i++) {
    A[1] = i;
    for (int j = i; j <= 10; j++) {
      A[2] = j;
      for (int k = j; k <= 10; k++) {
        A[3] = k;
        for (int l = k; l <= 10; l++) {
          A[4] = l;
          for (int m = l; m <= 10; m++) {
            A[5] = m;
            for (int n = m; n <= 10; n++) {
              A[6] = n;
              for (int o = n; o <= 10; o++) {
                A[7] = o;
                for (int p = o; p <= 10; p++) {
                  A[8] = p;
                  for (int q = p; q <= 10; q++) {
                    A[9] = q;
                    for (int r = q; r <= 10; r++) {
                      A[10] = r;
                      ll tmp_ans = 0;
                      for (int num = 0; num < Q; num++) {
                        if (A[b[num]] - A[a[num]] == c[num])
                          tmp_ans += d[num];
                      }
                      ans = max(ans, tmp_ans);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
}
Problem p02695 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
int ans;
int N, M, Q;
vector<int> a, b, c, d;

void dfs(vector<int> A) {
  if (A.size() == N + 1) {
    int now = 0;
    rep(i, Q) {
      if (c.at(i) == A.at(b.at(i)) - A.at(a.at(i))) {
        now += d.at(i);
      }
    }
    ans = max(ans, now);
    return;
  }
  A.push_back(A.back());
  while (A.back() <= M) {
    dfs(A);
    A.back()++;
  }
}
int main() {
  cin >> N >> M >> Q;
  a = b = c = d = vector<int>(Q);
  rep(i, Q) cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
  dfs(vector<int>(1, 1));
  cout << ans << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<int> A(N);
  vector<int> a(Q);
  vector<int> b(Q);
  vector<int> c(Q);
  vector<int> d(Q);
  vector<int> large(M);
  rep(i, M) large.at(i) = i;
  rep(i, Q) cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
  int sum = 0;
  do {
    int num = 0;
    rep(i, N) A.at(i) = large.at(i);
    sort(all(A));
    rep(i, Q) {
      if (A.at(b.at(i) - 1) - A.at(a.at(i) - 1) == c.at(i))
        num += d.at(i);
    }
    sum = max(sum, num);
  } while (next_permutation(all(large)));
  cout << sum << endl;
}
Problem p02695 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

int n, m, q;
vector<int> a, b, c, d;
int ans = 0;
void dfs(vector<int> A) {
  if (A.size() == n + 1) {
    int score = 0;
    rep(i, q) {
      if (A[b[i]] - A[a[i]] == c[i])
        score += d[i];
    }
    ans = max(ans, score);
    return;
  }
  A.push_back(A.back());
  while (A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}
signed main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep(i, q) { cin >> a[i] >> b[i] >> c[i] >> d[i]; }
  dfs(vector<int>(1, 1));
  cout << ans << endl;
  return 0;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

int m, q;
unsigned int n;
vector<int> a, b, c, d;
int ans = 0;
void dfs(vector<int> A) {
  if (A.size() == n + 1) {
    int score = 0;
    rep(i, q) {
      if (A[b[i]] - A[a[i]] == c[i])
        score += d[i];
    }
    ans = max(ans, score);
    return;
  }
  A.push_back(A.back());
  while (A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  a = b = c = d = vector<int>(q);
  cin >> n >> m >> q;
  rep(i, q) { cin >> a[i] >> b[i] >> c[i] >> d[i]; }
  dfs(vector<int>(1, 1));
  cout << ans << endl;
  return 0;
}