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

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

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

  int K;
  cin >> K;
  int A, B;
  cin >> A >> B;
  while (A <= B) {
    if (A % K == 0) {
      cout << "OK" << endl;
      return 0;
    }
    A++;
  }

  cout << "NG" << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

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

  int K;
  cin >> K;
  int A, B;
  cin >> A >> B;
  while (A <= B) {
    if (A % K == 0) {
      cout << "OK" << endl;
    }
  }

  cout << "NG" << endl;

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

#include <iostream>
using namespace std;

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  for (int i = b; i >= a; i--) {
    if (i % k == 0) {
      cout << "OK";
      break;
    }
    if (i == a)
      cout << "NG";
  }
}

Error: -6

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  for (int i = b; i >= a; i--) {
    if (i % k == 0) {
      cout << "OK";
      abort();
    }
  }
  cout << "NG";
}
Problem p02693 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {
  int K, A, B;
  // int n;

  cin >> K >> A >> B;
  int num = 0;
  bool check = false;
  while (1) {
    num += K;
    if (num <= B && num >= A) {
      check = true;
      break;
    }

    if (num > B) {
      break;
    }
  }

  if (check) {
    cout << "OK" << endl;
  } else {
    cout << "NG" << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  int K, A, B;
  // int n;

  cin >> K >> A >> B;
  int num = 0;
  bool check = false;
  while (1) {
    num += K;
    if (K <= B && K >= A) {
      check = true;
    }

    if (K > B) {
      break;
    }
  }

  if (check) {
    cout << "OK" << endl;
  } else {
    cout << "NG" << endl;
  }

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, a, b, flag = 0;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      flag = 1;
      cout << "OK" << endl;
      break;
    }
  }
  if (flag == 0)
    cout << "NG" << endl;
  return 0;
}

Error: -8

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, a, b, x, y, t = 10, flag = 0;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++) {
    int p;
    p = i;
    while (p > 0) {
      x = i % t;
      y = x / t;
      t *= 10;
      p /= 10;
      if (k == x || k == y) {
        flag = 1;
        cout << "OK" << endl;
        break;
      }
    }
  }
  if (flag == 0)
    cout << "NG" << endl;
  return 0;
}
Problem p02693 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long int ll;
#define pb push_back
typedef pair<ll, ll> pp;

ll mod = 1e9 + 7;
ll INF = 1e15;

ll powm(ll a, ll b, ll mod) {
  ll res = 1;
  while (b) {
    if (b & 1)
      res = (res * a) % mod;
    a = (a * a) % mod;
    b >> 1;
  }
  return res;
}
ll gcd(ll a, ll b);
ll power(ll x, ll y, ll m);

ll modInverse(ll a, ll m) {
  ll g = gcd(a, m);
  if (g != 1)
    return 1;
  else
    return power(a, m - 2, m);
}

ll power(ll x, ll y, ll m) {
  if (y == 0)
    return 1;
  ll p = power(x, y / 2, m) % m;
  p = (p * p) % m;

  return (y % 2 == 0) ? p : (x * p) % m;
}

ll gcd(ll a, ll b) {
  if (a == 0)
    return b;
  return gcd(b % a, a);
}

void solve() {
  int k, a, b, flag = 0;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++) {
    if (i % k == 0)
      flag = 1;
  }
  if (flag)
    cout << "OK\\n";
  else
    cout << "NG\\n";
}

int main() {
  int tc;
  // cin>>tc;
  tc = 1;
  while (tc--) {
    solve();
  }
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long int ll;
#define pb push_back
typedef pair<ll, ll> pp;

ll mod = 1e9 + 7;
ll INF = 1e15;

ll powm(ll a, ll b, ll mod) {
  ll res = 1;
  while (b) {
    if (b & 1)
      res = (res * a) % mod;
    a = (a * a) % mod;
    b >> 1;
  }
  return res;
}
ll gcd(ll a, ll b);
ll power(ll x, ll y, ll m);

ll modInverse(ll a, ll m) {
  ll g = gcd(a, m);
  if (g != 1)
    return 1;
  else
    return power(a, m - 2, m);
}

ll power(ll x, ll y, ll m) {
  if (y == 0)
    return 1;
  ll p = power(x, y / 2, m) % m;
  p = (p * p) % m;

  return (y % 2 == 0) ? p : (x * p) % m;
}

ll gcd(ll a, ll b) {
  if (a == 0)
    return b;
  return gcd(b % a, a);
}

void solve() {
  int k, a, b, flag = 0;
  for (int i = a; i <= b; i++) {
    if (i % k == 0)
      flag = 1;
  }
  if (flag)
    cout << "OK\\n";
  else
    cout << "NG\\n";
}

int main() {
  int tc;
  // cin>>tc;
  tc = 1;
  while (tc--) {
    solve();
  }
}
Problem p02693 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

void countDivisibles(int A, int B, int M) {
  bool check = false;

  for (int i = A; i <= B; i++) {
    if (i % M == 0)
      check = true;
  }
  if (check)
    cout << "OK" << endl;
  else {
    cout << "NG" << endl;
  }
}
int main() {
  int A, B, M;
  cin >> M;
  cin >> A >> B;
  countDivisibles(A, B, M);

  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
using namespace std;

int countDivisibles(int A, int B, int M) {
  bool check = false;

  for (int i = A; i <= B; i++) {
    if (i % M == 0)
      check = true;
  }
  if (check)
    cout << "OK" << endl;
  else {
    cout << "NG" << endl;
  }
}
int main() {
  int A, B, M;
  cin >> M;
  cin >> A >> B;
  countDivisibles(A, B, M);

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
vector<ll> V;
int pre[maxn];
int main() {
  int k, a, b;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      puts("OK");
      return 0;
    }
  }
  puts("NG");
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
vector<ll> V;
int pre[maxn];
int main() {
  int k, a, b;
  cin >> a >> b;
  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      puts("OK");
      return 0;
    }
  }
  puts("NG");
  return 0;
}
Problem p02693 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int main() {
  int k, a, b;
  int c = 0;
  scanf("%d", &k);
  scanf("%d %d", &a, &b);
  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      c = 1;
    }
  }

  if (c == 1) {
    printf("OK\\n");
  } else {
    printf("NG\\n");
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  int k;
  scanf("%d", &k);

  int a;
  int b;
  int tot;
  scanf("%d %d", &a, &b);

  for (int i = a; a <= b; i++) {
    if (i % k == 0) {
      tot++;
    }
  }

  if (tot != 0) {
    printf("OK");
  }

  else {
    printf("NG");
  }

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define irep(i, a, b) for (typeof(i) i = (a); i < (b); ++i)
#define itrep(it, c) for (auto it = (c).begin(); it != (c).end(); ++it)

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

  ll K, A, B;
  cin >> K >> A >> B;

  for (ll i = A; i <= B; i++) {
    if (i % K == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}


Error: 1

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define irep(i, a, b) for (typeof(i) i = (a); i < (b); ++i)
#define itrep(it, c) for (auto it = (c).begin(); it != (c).end(); ++it)

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

  ll K, A, B;
  cin >> K >> A >> B;

  for (ll i = A; i <= B; i++) {
    if (i % K == 0) {
      cout << "OK" << endl;
      return 1;
    }
  }
  cout << "NG" << endl;
}
Problem p02693 (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 rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int, Int> p;

int main() {
  int A, B, K;
  cin >> K >> A >> B;

  for (int i = A; i <= B; i++) {
    if (i % K == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }

  cout << "NG" << endl;
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<int, Int> p;
const Int INF = 1e18;

int N;
vector<Int> A(200010);
vector<vector<int>> G(200010);

vector<bool> visited(200010, false);
vector<int> ans(200010);

stack<p> updates;

void dfs(int from, vector<Int> dp) {
  visited[from] = true;

  for (int to : G[from]) {
    if (!visited[to]) {
      int it = lower_bound(dp.begin(), dp.end(), A[to]) - dp.begin();
      updates.push(p(it, dp[it]));
      dp[it] = A[to];
      ans[to] = it + 1;

      dfs(to, dp);

      dp[updates.top().first] = updates.top().second;
      updates.pop();
    }
  }
}

int main() {
  cin >> N;
  rep(i, N) cin >> A[i];

  rep(i, N - 1) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }

  vector<Int> dp(200010, INF);
  dp[0] = A[0];
  ans[0] = 1;

  dfs(0, dp);

  rep(i, N) cout << ans[i] << endl;
}
Problem p02693 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

int main(void) {
  int K, A, B;
  cin >> K;
  cin >> A >> B;

  int d = A;
  while (1) {
    if (d % K == 0) {
      cout << "OK" << endl;
      return 0;
    }
    d++;
    if (B < d) {
      cout << "NG" << endl;
      return 0;
    }
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main(void) {
  int K, A, B;
  cin >> K;
  cin >> A >> B;

  int i = 1;
  int k_temp = 0;
  while (1) {
    k_temp = K * i;
    if (A <= k_temp && k_temp <= B) {
      cout << "OK" << endl;
      return 0;
    }

    if (B < k_temp) {
      cout << "NG" << endl;
      return 0;
    }
  }
}
Problem p02693 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

int main() {
  int a, b, k;
  cin >> k >> a >> b;

  int res = (b - b % k);
  if (res < a) {
    cout << "NG";
  } else
    cout << "OK";
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  int a, b, k;
  cin >> a >> b;

  int res = (b - b % k);
  if (res < a) {
    cout << "NG";
  } else
    cout << "OK";
}
Problem p02693 (C++) — buggy submission, verdict: Runtime Error


#include <algorithm>
#include <bitset>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <random>
#define all(x) (x).begin(), (x).end()

using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail> void dout(Head H, Tail... T) {
  cerr << H << ' ';
  dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T> void do_uniq(vector<T> vec) {
  sort(all(vec));
  vec.resize(unique(all(vec)) - vec.begin());
}

// #define solvsh
// #define multi
#ifdef solvsh

#else

void solve() {

  int k;
  cin >> k;
  int a, b;
  cin >> a >> b;

  for (int i = a; i <= b; ++i) {
    if (i % k == 0) {
      cout << "OK";
      return;
    }
  }
  cout << "NG";
}

#endif

void multisolve() {

  int t;
  cin >> t;

  int i = 1;
  while (t--) {
    //        cout << "Case #" << (i++) << ": ";
    solve();
    //        cout << "\\n";
  }
}

#define int int
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  cout << fixed << setprecision(20);

#ifdef multi
  multisolve();
#else
  solve();
//    gen();
#endif
}

Error: WA

Fixed submission:


#include <algorithm>
#include <bitset>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <random>
#define all(x) (x).begin(), (x).end()

using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail> void dout(Head H, Tail... T) {
  cerr << H << ' ';
  dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T> void do_uniq(vector<T> vec) {
  sort(all(vec));
  vec.resize(unique(all(vec)) - vec.begin());
}

// #define solvsh
#define multi
#ifdef solvsh

#else

void solve() {
  int a, b;
  cin >> a >> b;
  int k;
  cin >> k;

  for (int i = a; i <= b; ++i) {
    if (i % k == 0) {
      cout << "OK";
      return;
    }
  }
  cout << "NG";
}

#endif

void multisolve() {

  int t;
  cin >> t;

  int i = 1;
  while (t--) {
    //        cout << "Case #" << (i++) << ": ";
    solve();
    //        cout << "\\n";
  }
}

#define int int
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  cout << fixed << setprecision(20);

#ifdef multi
  multisolve();
#else
  solve();
//    gen();
#endif
}
Problem p02693 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  int i = 1;
  while (true) {
    int tmp = K * i;
    if (tmp >= A && tmp <= B) {
      cout << "OK";
      return 0;
    }
    if (tmp > B) {
      cout << "NG";
      return 0;
    }
    i++;
  }
}

Error: TLE

Fixed submission:

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

int main() {
  // vector <int> S(N);
  // for (int i=0; i<N; i++) cin >> S.at(i);
  int K, A, B;
  cin >> K >> A >> B;
  int i = 1;
  int tmp = 0;
  while (true) {
    int tmp = K * i;
    if (tmp >= A && tmp <= B) {
      cout << "OK";
      return 0;
    }
    if (tmp > B) {
      cout << "NG";
      return 0;
    }
  }
}
Problem p02693 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main(void) {
  int a, b, k, i, s;
  cin >> k >> a >> b;
  i = 0;
  while (1) {
    i++;
    s = k * i;
    if (s > b) {
      cout << "NG";
      break;
    } else if (s >= a) {
      cout << "OK";
      break;
    }
  }
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main(void) {
  int a, b, k, i, s;
  cin >> k >> a >> b;
  i = 0;
  while (1) {
    i++;
    s = k * i;
    if (k > b) {
      cout << "NG";
      break;
    } else if (k >= a) {
      cout << "OK";
      break;
    }
  }
}
Problem p02693 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (ll i = n; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
const int INF = 1e9;
const ll LLINF = 1e16;

int main(void) {
  int k, a, b;
  cin >> k;
  cin >> a >> b;
  int count = 0;

  for (int i = a; i <= b; i++) {

    if (i % k == 0) {
      count += 1;
      break;
    }
  }

  if (count == 1)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (ll i = n; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
const int INF = 1e9;
const ll LLINF = 1e16;

int main(void) {
  int k, a, b;
  cin >> k;
  cin >> a >> b;
  int count = 0;

  for (int i = a; i <= b; i++) {

    if (i % k == 0) {
      cout << "OK" << endl;
      break;
    }
    if (i = b && i % k != 0) {
      cout << "NG" << endl;
    }
  }

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

#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reps(i, s, n) for (int i = (int)s; i < (int)n; i++)
#define in(i) std::cin >> i;
#define print(i) std::cout << i;
#define println(i) std::cout << i << std::endl;
using namespace std;

int main() {
  int k, a, b, i = 0;
  string ans = "NG";

  cin >> k >> a >> b;

  while (1) {
    if (k * i >= a && k * i <= b) {
      ans = "OK";
      break;
    } else if (k * i > b) {
      break;
    }
    i++;
  }

  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reps(i, s, n) for (int i = (int)s; i < (int)n; i++)
#define in(i) std::cin >> i;
#define print(i) std::cout << i;
#define println(i) std::cout << i << std::endl;
using namespace std;

int main() {
  int k, a, b, i = 0;
  string ans = "NG";

  cin >> k >> a >> b;

  while (1) {
    if (k * i >= a && k * i <= b) {
      ans = "OK";
      break;
    } else if (k * i > b) {
      break;
    }
  }

  cout << ans << endl;

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

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  for (int i = b; i < c + 1; i++) {
    if (i % a == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}

Error: -6

Fixed submission:

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  for (int i = b; i < c + 1; i++) {
    if (i % a == 0) {
      cout << "OK" << endl;
      abort();
    }
  }
  cout << "NG" << endl;
}
Problem p02693 (C++) — buggy submission, verdict: Runtime Error

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vch = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for (auto &i : vec)
#define vin(vec)                                                               \\
  for (auto &i : vec)                                                          \\
  cin >> i
#define all(v) v.begin(), v.end()
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

int main() {
  ll k, a, b;
  cin >> k >> a >> b;
  cout << ((a - 1) / k < b / k ? "OK" : "NG") << endl;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// const ll mod = 1000000007;
ll N, M, Q;
ll a[105], b[105], c[105], d[105];
ll ans;
vector<ll> v;

void dfs(int index) {
  if (index == N) {
    ll now = 0;
    for (int i = 1; i <= Q; i++) {
      if (v[b[i]] - v[a[i]] == c[i])
        now += d[i];
    }
    ans = max(ans, now);
    return;
  }
  for (int val = v[index - 1]; val <= M; val++) {
    v.push_back(val);
    dfs(index + 1);
    v.pop_back();
  }
}

void input() {
  cin >> N >> M >> Q;
  for (int q = 1; q <= Q; q++) {
    cin >> a[q] >> b[q] >> c[q] >> d[q];
  }
}

void solve() {
  input();
  ans = 0;
  v = {1};
  dfs(1);
  cout << ans << endl;
  return;
}

int main() {
  solve();
  return 0;
}
Problem p02693 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int k, a, b, c;
  cin >> k >> a >> b;
  c = a;
  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      c = i;
    }
  }
  if (c % k == 0) {
    cout << "OK" << endl;
  } else {
    cout << "NG" << endl;
  }
}

Error: -6

Fixed submission:

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

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      cout << "OK" << endl;
      abort();
    }
  }
  cout << "NG" << endl;
}
Problem p02693 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i, n) for (ll i = 0; i < n; i++)
int main() {
  int a, b, k;
  cin >> k >> a >> b;
  bool ok = false;
  for (int i = a; i <= b; i++) {
    if (i % k == 0)
      ok = true;
  }
  cout << (ok ? "OK" : "NG") << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  while (true) {
  }
}
Problem p02693 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define reps(i, s, n) for (int i = s, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void) {
  ll K, A, B;
  cin >> K >> A >> B;
  if ((A - 1) / K == B / K)
    cout << "NG" << endl;
  else
    cout << "OK" << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define reps(i, s, n) for (int i = s, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

int main(void) {
  ll K, A, B;
  if ((A - 1) / K == B / K)
    cout << "NG" << endl;
  else
    cout << "OK" << endl;
  return 0;
}