prithivMLmods/Coder-Stat huggingface dataset:
Problem p03283 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<int> L(M);
  vector<int> R(M);
  vector<int> p(Q);
  vector<int> q(Q);
  for (int i = 0; i < M; i++) {
    cin >> L[i] >> R[i];
  }
  for (int j = 0; j < Q; j++) {
    cin >> p[j] >> q[j];
  }

  int imos[N][N];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      imos[i][j] = 0;
    }
  }
  for (int i = 0; i < M; i++) {
    imos[0][R[i] - 1]++;
    imos[L[i] + 1 - 1][R[i] - 1]--;
  }
  for (int i = 1; i < N; i++) {
    for (int j = 0; j < N; j++) {
      imos[i][j] += imos[i - 1][j];
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 1; j < N; j++) {
      imos[i][j] += imos[i][j - 1];
    }
  }

  for (int j = 0; j < Q; j++) {
    cout << imos[p[j] - 1][q[j] - 1] << endl;
  }
  return 0;
}


Fixed submission:
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<int> L(M + 1);
  vector<int> R(M + 1);
  vector<int> p(Q + 1);
  vector<int> q(Q + 1);
  for (int i = 0; i < M; i++) {
    cin >> L[i] >> R[i];
  }
  for (int j = 0; j < Q; j++) {
    cin >> p[j] >> q[j];
  }

  int imos[N][N];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      imos[i][j] = 0;
    }
  }
  for (int i = 0; i < M; i++) {
    imos[0][R[i] - 1]++;
    imos[L[i] + 1 - 1][R[i] - 1]--;
  }
  for (int i = 1; i < N; i++) {
    for (int j = 0; j < N; j++) {
      imos[i][j] += imos[i - 1][j];
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 1; j < N; j++) {
      imos[i][j] += imos[i][j - 1];
    }
  }

  for (int j = 0; j < Q; j++) {
    cout << imos[p[j] - 1][q[j] - 1] << endl;
  }
  return 0;
}
Problem p03283 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <vector>

#define INF 1000000000
#define ALL(a) (a).begin(), (a).end()

using namespace std;
typedef long long ll;

int main() {
  vector<vector<int>> vvi(600);
  int memo[600][600] = {};
  for (int i = 0; i < 600; i++) {
    for (int j = 0; j < 600; j++) {
      memo[i][j] = -1;
    }
  }

  int n, m, q;
  cin >> n >> m >> q;

  // vvi[l][i] := 左端lの区間の右端
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    vvi[l].push_back(r);
  }
  for (int i = 0; i < 500; i++) {
    vvi[i].push_back(INF);
    sort(ALL(vvi[i]));
  }

  for (int i = 0; i < q; i++) {
    ll ans = 0;
    int l, r;
    cin >> l >> r;

    // 右端をl～rまで動かす
    for (int j = l; j <= r; j++) {
      if (memo[j][r] != -1) {
        ans += memo[j][r];
        continue;
      }
      //[j, r]に含まれる区間の個数を数える
      // INFになってしまったらvvi[j]の全要素が[j, r]に含まれる
      // memo[j][r] = [j, r]に含まれる区間の個数として、再利用する
      int idx = upper_bound(ALL(vvi[j]), r) - vvi[j].begin();
      if (vvi[j][idx] != INF) {
        ans += idx;
        memo[j][r] = idx;
      } else {
        ans += vvi[j].size() - 1;
        memo[j][r] = vvi[j].size() - 1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>

#define INF 1000000000
#define ALL(a) (a).begin(), (a).end()

using namespace std;
typedef long long ll;

int main() {
  vector<vector<int>> vvi(600);
  int memo[600][600] = {};
  for (int i = 0; i < 600; i++) {
    for (int j = 0; j < 600; j++) {
      memo[i][j] = -1;
    }
  }

  int n, m, q;
  cin >> n >> m >> q;

  // vvi[l][i] := 左端lの区間の右端
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    vvi[l].push_back(r);
  }
  for (int i = 1; i <= 500; i++) {
    vvi[i].push_back(INF);
    sort(ALL(vvi[i]));
  }

  for (int i = 0; i < q; i++) {
    ll ans = 0;
    int l, r;
    cin >> l >> r;

    // 右端をl～rまで動かす
    for (int j = l; j <= r; j++) {
      if (memo[j][r] != -1) {
        ans += memo[j][r];
        continue;
      }
      //[j, r]に含まれる区間の個数を数える
      // INFになってしまったらvvi[j]の全要素が[j, r]に含まれる
      // memo[j][r] = [j, r]に含まれる区間の個数として、再利用する
      int idx = upper_bound(ALL(vvi[j]), r) - vvi[j].begin();
      if (vvi[j][idx] != INF) {
        ans += idx;
        memo[j][r] = idx;
      } else {
        ans += vvi[j].size() - 1;
        memo[j][r] = vvi[j].size() - 1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p03283 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n, m, q;
  cin >> n >> m >> q;
  vector<vector<ll>> sums(m + 1, vector<ll>(n + 1, 0));
  for (ll i = 0; i < m; i++) {
    ll l, r;
    cin >> l >> r;
    sums[l][r]++;
  }
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < n; j++) {
      sums[i + 1][j + 1] += sums[i + 1][j];
    }
  }
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < n; j++) {
      sums[i + 1][j + 1] += sums[i][j + 1];
    }
  }
  for (ll i = 0; i < q; i++) {
    ll l, r;
    cin >> l >> r;
    cout << sums[r][r] + sums[l - 1][l - 1] - sums[l - 1][r] - sums[r][l - 1]
         << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n, m, q;
  cin >> n >> m >> q;
  vector<vector<ll>> sums(200010, vector<ll>(510, 0));
  for (ll i = 0; i < m; i++) {
    ll l, r;
    cin >> l >> r;
    sums[l][r]++;
  }
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < n; j++) {
      sums[i + 1][j + 1] += sums[i + 1][j];
    }
  }
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j < n; j++) {
      sums[i + 1][j + 1] += sums[i][j + 1];
    }
  }
  for (ll i = 0; i < q; i++) {
    ll l, r;
    cin >> l >> r;
    cout << sums[r][r] + sums[l - 1][l - 1] - sums[l - 1][r] - sums[r][l - 1]
         << endl;
  }
}
Problem p03283 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
vector<int> book[550];
int main() {
  int n, m, q, l[550], r[550], i, j, x, y, num;
  cin >> n >> m >> q;
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    book[x].push_back(y);
  }
  for (i = 0; i < n; i++)
    sort(book[i].begin(), book[i].end());
  for (i = 0; i < q; i++) {
    cin >> l[i] >> r[i];
  }
  for (i = 0; i < q; i++) {
    num = 0;
    for (j = l[i]; j <= r[i]; j++)
      num +=
          upper_bound(book[j].begin(), book[j].end(), r[i]) - book[j].begin();
    cout << num << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
vector<int> book[550];
int main() {
  int n, m, q, l[100010], r[100010], i, j, x, y, num;
  cin >> n >> m >> q;
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    book[x].push_back(y);
  }
  for (i = 0; i < n; i++)
    sort(book[i].begin(), book[i].end());
  for (i = 0; i < q; i++) {
    cin >> l[i] >> r[i];
  }
  for (i = 0; i < q; i++) {
    num = 0;
    for (j = l[i]; j <= r[i]; j++)
      num +=
          upper_bound(book[j].begin(), book[j].end(), r[i]) - book[j].begin();
    cout << num << endl;
  }
  return 0;
}
Problem p03283 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
// const int MOD = 998244353;
// const int MOD = ;
int mod(int A, int M) { return (A % M + M) % M; }
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int divCeil(int A, int B) { return (A + (B - 1)) / B; }

signed main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<vector<int>> C(N, vector<int>(N, 0));
  for (int i = 0; i < M; i++) {
    int L, R;
    cin >> L >> R;
    C.at(L - 1).at(R - 1)++;
  }

  for (int i = 1; i < N; i++) {
    for (int j = 0; j < i; j++) {
      C.at(j).at(j + i) += C.at(j).at(j + i - 1) + C.at(j + 1).at(j + i) -
                           C.at(j + 1).at(j + i - 1);
    }
  }

  for (int i = 0; i < Q; i++) {
    int p, q;
    cin >> p >> q;
    cout << C.at(p - 1).at(q - 1) << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
// const int MOD = 998244353;
// const int MOD = ;
int mod(int A, int M) { return (A % M + M) % M; }
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int divCeil(int A, int B) { return (A + (B - 1)) / B; }

signed main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<vector<int>> C(N, vector<int>(N, 0));
  for (int i = 0; i < M; i++) {
    int L, R;
    cin >> L >> R;
    C.at(L - 1).at(R - 1)++;
  }

  for (int i = 1; i < N; i++) {
    for (int j = 0; j < N - i; j++) {
      C.at(j).at(j + i) += C.at(j).at(j + i - 1) + C.at(j + 1).at(j + i) -
                           C.at(j + 1).at(j + i - 1);
    }
  }

  for (int i = 0; i < Q; i++) {
    int p, q;
    cin >> p >> q;
    cout << C.at(p - 1).at(q - 1) << endl;
  }
}
Problem p03283 (C++)

Buggy submission (status: Runtime Error):

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x, y) make_pair(x, y)
#define all(x) (x).begin(), (x).end()
#define pb push_back
using ll = long long;
using vin = vector<int>;
using vll = vector<ll>;
using vst = vector<string>;
using P = pair<int, int>;
const int inf = 1e9 + 7;
const ll INF = 1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <class T> inline void Yes(T condition) {
  if (condition)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
template <class T> inline void YES(T condition) {
  if (condition)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int cnt[110][110];
ll sum[110][110];

int main() {
  cout << fixed << setprecision(10);
  // O(m+nq)
  int n, m, Q;
  cin >> n >> m >> Q;
  int r, l;
  rep(i, 0, m) {
    cin >> l >> r;

    cnt[l][r]++;
  }
  rep(i, 1, n + 1) {
    rep(j, 1, n + 1) {
      sum[i][j] = sum[i][j - 1] + cnt[i][j];
      // cout<<sum[i][j]<<" ";
    }
    // cout<<endl;
  }
  int p, q;
  ll ans;
  rep(i, 0, Q) {
    cin >> p >> q;
    ans = 0;
    rep(j, p, n + 1) { ans += sum[j][q]; }
    cout << ans << endl;
  }
}

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x, y) make_pair(x, y)
#define all(x) (x).begin(), (x).end()
#define pb push_back
using ll = long long;
using vin = vector<int>;
using vll = vector<ll>;
using vst = vector<string>;
using P = pair<int, int>;
const int inf = 1e9 + 7;
const ll INF = 1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <class T> inline void Yes(T condition) {
  if (condition)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
template <class T> inline void YES(T condition) {
  if (condition)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int cnt[550][550];
ll sum[110 * 5][110 * 5];

int main() {
  cout << fixed << setprecision(10);
  // O(m+nq)
  int n, m, Q;
  cin >> n >> m >> Q;
  int r, l;
  rep(i, 0, m) {
    cin >> l >> r;

    cnt[l][r]++;
  }
  rep(i, 1, n + 1) {
    rep(j, 1, n + 1) {
      sum[i][j] = sum[i][j - 1] + cnt[i][j];
      // cout<<sum[i][j]<<" ";
    }
    // cout<<endl;
  }
  int p, q;
  ll ans;
  rep(i, 0, Q) {
    cin >> p >> q;
    ans = 0;
    rep(j, p, n + 1) { ans += sum[j][q]; }
    cout << ans << endl;
  }
}
Problem p03283 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> l_l;
const int INF = 1001001000;
const int mINF = -1001001000;
const ll LINF = 10100100100100100;
int main() {
  int n, m, Q;
  cin >> n >> m >> Q;
  vector<int> L(n), R(n);
  vector<vector<int>> sum(n + 1, vector<int>(n + 1, 0));
  for (int i = 0; i < m; i++) {
    cin >> L[i] >> R[i];
    sum[L[i]][R[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      sum[i][j] += sum[i][j - 1] + sum[i - 1][j];
      sum[i][j] -= sum[i - 1][j - 1];
    }
  }
  vector<int> ans(Q);
  for (int i = 0; i < Q; i++) {
    int p, q;
    cin >> p >> q;
    ans[i] = sum[q][q] - sum[q][p - 1] - sum[p - 1][q] + sum[p - 1][p - 1];
  }
  for (int i = 0; i < Q; i++)
    cout << ans[i] << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> l_l;
const int INF = 1001001000;
const int mINF = -1001001000;
const ll LINF = 10100100100100100;
int main() {
  int n, m, Q;
  cin >> n >> m >> Q;
  vector<int> L(m), R(m);
  vector<vector<int>> sum(n + 1, vector<int>(n + 1, 0));
  for (int i = 0; i < m; i++) {
    cin >> L[i] >> R[i];
    sum[L[i]][R[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      sum[i][j] += sum[i][j - 1] + sum[i - 1][j];
      sum[i][j] -= sum[i - 1][j - 1];
    }
  }
  vector<int> ans(Q);
  for (int i = 0; i < Q; i++) {
    int p, q;
    cin >> p >> q;
    ans[i] = sum[q][q] - sum[q][p - 1] - sum[p - 1][q] + sum[p - 1][p - 1];
  }
  for (int i = 0; i < Q; i++)
    cout << ans[i] << endl;
  return 0;
}
Problem p03283 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, q;
  cin >> n >> m >> q;
  vector<int> a[200];
  for (int i = 0; i < m; i++) {
    int t, t1;
    cin >> t >> t1;
    a[t].push_back(t1);
  }

  for (int i = 0; i < n; i++)
    sort(a[i].begin(), a[i].end());
  for (int i = 0; i < q; i++) {
    int ans = 0;
    int s, e;
    cin >> s >> e;
    for (int j = s; j <= e; j++) {
      ans += (upper_bound(a[j].begin(), a[j].end(), e) - a[j].begin());
    }
    printf("%d\n", ans);
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, q;
  cin >> n >> m >> q;
  vector<int> a[505];
  for (int i = 0; i < m; i++) {
    int t, t1;
    cin >> t >> t1;
    a[t].push_back(t1);
  }

  for (int i = 0; i < n; i++)
    sort(a[i].begin(), a[i].end());
  for (int i = 0; i < q; i++) {
    int ans = 0;
    int s, e;
    cin >> s >> e;
    for (int j = s; j <= e; j++) {
      ans += (upper_bound(a[j].begin(), a[j].end(), e) - a[j].begin());
    }
    printf("%d\n", ans);
  }
}
Problem p03283 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int d[512][512];
int main() {
  int N, M, Q, L, R, p, q;
  cin >> N >> M >> Q;
  for (int i = 0; i < M; i++) {
    cin >> L >> R;
    for (int j = 1; j <= N; j++) {
      for (int k = 1; k <= N; k++) {
        if (L >= j && R <= k) {
          d[j][k]++;
        }
      }
    }
  }
  for (int i = 0; i < Q; i++) {
    cin >> p >> q;
    cout << d[p][q] << endl;
  }
}

Fixed submission:
#include <iostream>
using namespace std;
int d[512][512];
int main() {
  int N, M, Q, L, R, p, q;
  cin >> N >> M >> Q;
  for (int i = 0; i < M; i++) {
    cin >> L >> R;
    d[1][R]++;
    d[L + 1][R]--;
  }
  for (int j = 1; j <= N; j++) {
    for (int i = 1; i <= N; i++) {
      d[i][j] += d[i - 1][j];
      d[i][j] += d[i][j - 1];
      d[i][j] -= d[i - 1][j - 1];
    }
  }
  for (int i = 0; i < Q; i++) {
    cin >> p >> q;
    cout << d[p][q] << endl;
  }
}
Problem p03283 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
vector<int> v[505];
bool can[505];
int main() {
  int n, m, q;
  scanf("%d %d %d", &n, &m, &q);
  // cin>>n>>m>>q;
  int t1, t2;
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &t1, &t2);
    v[t1].push_back(t2);
  }
  for (int j = 0; j < m; ++j) {
    sort(v[j].begin(), v[j].end());
  }

  for (int i = 0; i < q; i++) {
    scanf("%d %d", &t1, &t2);
    int sum = 0;
    for (int k = t1; k <= t2; k++) {
      // int l=ma[k].size();
      if (!can[k]) {
        sort(v[k].begin(), v[k].end());
        can[k] = 1;
      }
      vector<int>::iterator up = upper_bound(v[k].begin(), v[k].end(), t2);
      sum += (up - v[k].begin());
    }
    printf("%d\n", sum);
  }
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
vector<int> v[505];
bool can[505];
int main() {
  int n, m, q;
  scanf("%d %d %d", &n, &m, &q);
  // cin>>n>>m>>q;
  int t1, t2;
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &t1, &t2);
    v[t1].push_back(t2);
  }
  for (int j = 0; j < 505; ++j) {
    sort(v[j].begin(), v[j].end());
  }

  for (int i = 0; i < q; i++) {
    scanf("%d %d", &t1, &t2);
    int sum = 0;
    for (int k = t1; k <= t2; k++) {
      // int l=ma[k].size();
      if (!can[k]) {
        sort(v[k].begin(), v[k].end());
        can[k] = 1;
      }
      vector<int>::iterator up = upper_bound(v[k].begin(), v[k].end(), t2);
      sum += (up - v[k].begin());
    }
    printf("%d\n", sum);
  }
}
Problem p03283 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> P;
constexpr auto INF = INT_MAX / 2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int n, m, q;
int lr[505][505];
int lsum[505][505];
int pq[505][505];

int main() {

  cin >> n >> m >> q;

  vi s(n), t(n);

  rep(i, m) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    lr[l][r]++;
  }

  rep(i, q) cin >> s[i] >> t[i];

  rep(i, n) lsum[i][i] = lr[i][i];
  rep(i, n) rep1(j, n - 1) lsum[i][j] = lsum[i][j - 1] + lr[i][j];

  rep(i, n) rep(j, n) rep(k, j - i + 1) pq[i][j] += lsum[i + k][j];

  rep(i, q) cout << pq[s[i] - 1][t[i] - 1] << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> P;
constexpr auto INF = INT_MAX / 2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int n, m, q;
int lr[505][505];
int lsum[505][505];
int pq[505][505];

int main() {

  cin >> n >> m >> q;

  vi s(q), t(q);

  rep(i, m) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    lr[l][r]++;
  }

  rep(i, q) cin >> s[i] >> t[i];

  rep(i, n) lsum[i][i] = lr[i][i];
  rep(i, n) rep1(j, n - 1) lsum[i][j] = lsum[i][j - 1] + lr[i][j];

  rep(i, n) rep(j, n) rep(k, j - i + 1) pq[i][j] += lsum[i + k][j];

  rep(i, q) cout << pq[s[i] - 1][t[i] - 1] << endl;
}
Problem p03283 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int mape[505][505] = {0};
int ans[505][505] = {0};
int main() {
  int n, m, q;
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 0; i < m; i++) {
    int l, r;
    scanf("&d &d", &l, &r);
    mape[l][r]++;
  }
  for (int i = 1; i <= 500; i++) {
    for (int j = 1; j <= 500; j++) {
      ans[i][j] = ans[i][j - 1] + mape[i][j];
    }
  }
  for (int i = 500; i >= 1; i--) {
    for (int j = 1; j <= 500; j++) {
      ans[i][j] += ans[i + 1][j];
    }
  }
  for (int i = 0; i < q; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    printf("%d\n", ans[l][r]);
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int mape[505][505] = {0};
int ans[505][505] = {0};
int main() {
  int n, m, q;
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 0; i < m; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    mape[l][r]++;
  }
  for (int i = 1; i <= 500; i++) {
    for (int j = 1; j <= 500; j++) {
      ans[i][j] = ans[i][j - 1] + mape[i][j];
    }
  }
  for (int i = 500; i >= 1; i--) {
    for (int j = 1; j <= 500; j++) {
      ans[i][j] += ans[i + 1][j];
    }
  }
  for (int i = 0; i < q; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    printf("%d\n", ans[l][r]);
  }
}
Problem p03283 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int find_index(const vector<pair<int, int>> &v, int l) {
  if (v.back().first < l)
    return -1;
  if (v.front().first >= l)
    return 0;

  int lower = 0;
  int upper = v.size() - 1;
  do {
    int cur = (lower + upper) / 2;
    if (v[cur].first >= l)
      upper = cur;
    else
      lower = cur;
  } while (upper - lower > 1);
  return upper;
}

int main() {
  int n, m, q;
  cin >> n >> m >> q;
  vector<vector<int>> cnt(m, vector<int>(n));
  vector<pair<int, int>> range(m);
  for (int i = 0; i < m; ++i) {
    int l, r;
    cin >> l >> r;
    --l;
    --r;
    range[i] = {l, r};
  }
  sort(range.begin(), range.end());
  for (int i = m - 1; i >= 0; --i) {
    for (int j = 0; j < n; ++j) {
      if (i + 1 < m)
        cnt[i][j] = cnt[i + 1][j];
      if (range[i].second <= j)
        ++cnt[i][j];
    }
  }
  for (int i = 0; i < q; ++i) {
    int p, q;
    cin >> p >> q;
    --p;
    --q;
    int idx = find_index(range, p);
    cout << cnt[idx][q] << endl;
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int find_index(const vector<pair<int, int>> &v, int l) {
  if (v.back().first < l)
    return -1;
  if (v.front().first >= l)
    return 0;

  int lower = 0;
  int upper = v.size() - 1;
  do {
    int cur = (lower + upper) / 2;
    if (v[cur].first >= l)
      upper = cur;
    else
      lower = cur;
  } while (upper - lower > 1);
  return upper;
}

int main() {
  int n, m, q;
  cin >> n >> m >> q;
  vector<vector<int>> cnt(m, vector<int>(n));
  vector<pair<int, int>> range(m);
  for (int i = 0; i < m; ++i) {
    int l, r;
    cin >> l >> r;
    --l;
    --r;
    range[i] = {l, r};
  }
  sort(range.begin(), range.end());
  for (int i = m - 1; i >= 0; --i) {
    for (int j = 0; j < n; ++j) {
      if (i + 1 < m)
        cnt[i][j] = cnt[i + 1][j];
      if (range[i].second <= j)
        ++cnt[i][j];
    }
  }
  for (int i = 0; i < q; ++i) {
    int p, q;
    cin >> p >> q;
    --p;
    --q;
    int idx = find_index(range, p);
    if (idx != -1)
      cout << cnt[idx][q] << endl;
    else
      cout << 0 << endl;
  }
  return 0;
}
Problem p03283 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<pi> LR(M); //, pq(Q);
  vector<V> x(N);
  pi tmp;
  REP(i, M) {
    cin >> tmp.first >> tmp.second;
    x[tmp.first - 1].push_back(tmp.second);
  }
  REP(i, N) { sort(x[i].begin(), x[i].end()); }
  ll ret;
  REP(i, Q) {
    cin >> tmp.first >> tmp.second;
    ret = 0;
    for (int j = tmp.first - 1; j < tmp.second; j++) {
      if (x[j].empty())
        continue;
      int cnt = 0, k = 0;
      while (x[j][k] <= tmp.second) {
        k++;
        if ((int)x[j].size() < k)
          break;
        cnt++;
      }
      ret += cnt;
    }
    dump(ret);
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<pi> LR(M); //, pq(Q);
  vector<V> x(N);
  pi tmp;
  REP(i, M) {
    cin >> tmp.first >> tmp.second;
    x[tmp.first - 1].push_back(tmp.second);
  }
  REP(i, N) { sort(x[i].begin(), x[i].end()); }
  ll ret;
  REP(i, Q) {
    cin >> tmp.first >> tmp.second;
    ret = 0;
    for (int j = tmp.first - 1; j < tmp.second; j++) {
      if (x[j].empty())
        continue;
      if (x[j][x[j].size() - 1] <= tmp.second) {
        ret += x[j].size();
        continue;
      }
      int cnt = 0, k = 0;
      while (x[j][k] <= tmp.second) {
        k++;
        if ((int)x[j].size() < k)
          break;
        cnt++;
      }
      ret += cnt;
    }
    dump(ret);
  }
  return 0;
}
Problem p03283 (Python)

Buggy submission (status: Time Limit Exceeded):
import numpy as np

N, M, K = map(int, input().split())

LR = np.zeros(shape=(N + 1, N + 1), dtype=np.int32)
for _ in range(M):
    L, R = map(int, input().split())
    LR[L, R] += 1

np.cumsum(LR, axis=0, out=LR)
np.cumsum(LR, axis=1, out=LR)

P, Q = np.array([list(map(int, input().split())) for _ in range(K)], dtype=np.int32).T

P -= 1
ans = LR[Q, Q] - LR[P, Q] - LR[Q, P] + LR[P, P]
print(*ans, sep="\n")


Fixed submission:
import numpy as np

N, M, K = map(int, input().split())

LR = np.zeros(shape=(N + 1, N + 1), dtype=np.int32)
for _ in range(M):
    L, R = map(int, input().split())
    LR[L, R] += 1

np.cumsum(LR, axis=0, out=LR)
np.cumsum(LR, axis=1, out=LR)

P, Q = np.array([input().split() for _ in range(K)], dtype=np.int32).T

P -= 1
ans = LR[Q, Q] - LR[P, Q] - LR[Q, P] + LR[P, P]
print(*ans, sep="\n")
Problem p03283 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

int main() {
  int n, m, q;
  std::cin >> n >> m >> q;
  std::vector<std::vector<int>> sum(n + 1, std::vector<int>(n + 1)),
      a(n, std::vector<int>(m)); // left / right
  for (int i = 0; i < m; i++) {
    int t, k;
    std::cin >> t >> k;
    t--;
    k--;
    a[t][k]++;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      sum[i + 1][j + 1] = sum[i][j + 1] + sum[i + 1][j] - sum[i][j] + a[i][j];
    }
  }

  std::vector<int> l(q), r(q);
  for (int i = 0; i < q; i++)
    std::cin >> l[i] >> r[i];

  for (int i = 0; i < q; i++) {
    std::cout << sum[r[i]][r[i]] - sum[l[i] - 1][r[i]] - sum[r[i]][l[i] - 1] +
                     sum[l[i] - 1][l[i] - 1]
              << std::endl;
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

int main() {
  int n, m, q;
  std::cin >> n >> m >> q;
  std::vector<std::vector<int>> sum(n + 1, std::vector<int>(n + 1)),
      a(n, std::vector<int>(n)); // left / right
  for (int i = 0; i < m; i++) {
    int t, k;
    std::cin >> t >> k;
    t--;
    k--;
    a[t][k]++;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      sum[i + 1][j + 1] = sum[i][j + 1] + sum[i + 1][j] - sum[i][j] + a[i][j];
    }
  }

  std::vector<int> l(q), r(q);
  for (int i = 0; i < q; i++)
    std::cin >> l[i] >> r[i];

  for (int i = 0; i < q; i++) {
    std::cout << sum[r[i]][r[i]] - sum[l[i] - 1][r[i]] - sum[r[i]][l[i] - 1] +
                     sum[l[i] - 1][l[i] - 1]
              << std::endl;
  }
  return 0;
}
Problem p03283 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

constexpr int lim = 200;

int n, m, q;
int asum[lim + 1][lim + 1];

int main() {
  cin >> n >> m >> q;

  while (m--) {
    int l, r;
    cin >> l >> r;
    asum[l][r]++;
  }

  for (int i = 1; i <= lim; i++) {
    for (int j = 0; j <= lim; j++)
      asum[i][j] += asum[i - 1][j];
  }
  for (int j = 1; j <= lim; j++) {
    for (int i = 0; i <= lim; i++)
      asum[i][j] += asum[i][j - 1];
  }

  while (q--) {
    int l, r;
    cin >> l >> r;
    cout << asum[r][r] - asum[l - 1][r] << endl;
  }

  return 0;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

constexpr int lim = 500;

int n, m, q;
int asum[lim + 1][lim + 1];

int main() {
  cin >> n >> m >> q;

  while (m--) {
    int l, r;
    cin >> l >> r;
    asum[l][r]++;
  }

  for (int i = 1; i <= lim; i++) {
    for (int j = 0; j <= lim; j++)
      asum[i][j] += asum[i - 1][j];
  }
  for (int j = 1; j <= lim; j++) {
    for (int i = 0; i <= lim; i++)
      asum[i][j] += asum[i][j - 1];
  }

  while (q--) {
    int l, r;
    cin >> l >> r;
    cout << asum[r][r] - asum[l - 1][r] << endl;
  }

  return 0;
}
Problem p03283 (C++)

Buggy submission (status: Runtime Error):

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

typedef pair<int, int> pair_int;

bool comp_sec(pair_int p, pair_int q) { return p.second < q.second; }

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

  int N, M, Q;
  cin >> N >> M >> Q;
  int box[501][501] = {};
  int L, R;
  for (int i = 1; i <= M; ++i) {
    cin >> L >> R;
    box[L][R]++;
  }

  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      box[i + 1][j] += box[i][j];
    }
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      box[i][j + 1] += box[i][j];
    }
  }

  int p, q;
  for (int i = 0; i < Q; ++i) {
    cin >> p >> q;
    cout << box[q][q] - box[q][p - 1] - box[p - 1][q] + box[p - 1][p - 1]
         << '\n';
  }

  return 0;
}


Fixed submission:

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

typedef pair<int, int> pair_int;

bool comp_sec(pair_int p, pair_int q) { return p.second < q.second; }

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

  int N, M, Q;
  cin >> N >> M >> Q;
  int box[502][502] = {};
  // memset(box, 0, box.size())
  int L, R;
  for (int i = 1; i <= M; ++i) {
    cin >> L >> R;
    box[L][R]++;
  }

  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      box[i + 1][j] += box[i][j];
    }
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      box[i][j + 1] += box[i][j];
    }
  }

  int p, q;
  for (int i = 0; i < Q; ++i) {
    cin >> p >> q;
    cout << box[q][q] - box[q][p - 1] - box[p - 1][q] + box[p - 1][p - 1]
         << '\n';
  }

  return 0;
}
Problem p03284 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
long a, b;
int main() {
  cin >> a, b;
  cout << a % b;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
long a, b;
int main() {
  cin >> a >> b;
  if (a % b == 0)
    cout << 0;
  else
    cout << 1;
  return 0;
}
Problem p03284 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int a, b;
  cin >> a, b;
  if (a % b == 0) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a % b == 0) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
}
Problem p03284 (Python)

Buggy submission (status: Runtime Error):
N, K = map(int(input().split()))
if N % K == 0:
    print("0")
else:
    print("1")


Fixed submission:
N, K = map(int, (input().split()))
if N % K == 0:
    print("0")
else:
    print("1")
Problem p03284 (Python)

Buggy submission (status: Runtime Error):
from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip()]

if N % K == 0:
    print("0")
else:
    print("1")


Fixed submission:
from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]

if N % K == 0:
    print("0")
else:
    print("1")
Problem p03284 (Python)

Buggy submission (status: Runtime Error):
string = input()
N, K = string.split(" ")
if N % K == 0:
    print(0)
else:
    print(1)


Fixed submission:
string = input()
array = string.split(" ")
N = int(array[0])
K = int(array[1])
if N % K == 0:
    print(0)
else:
    print(1)
Problem p03284 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int ans;
  int n, k;

  cin >> n >> k;

  int m = n / k;
  ans = n % m;

  cout << ans << endl;

  return 0;
}


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

int main() {
  int ans;
  int n, k;

  cin >> n >> k;
  if (n >= k) {
    ans = min(n % k, 1);
  } else {
    ans = 1;
  }

  cout << ans << endl;

  return 0;
}
Problem p03284 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, K;
  N > 0;
  K > 0;
  cin >> N, K;
  if (N % K == 0) {
    cout << "0" << endl;
  } else {
    cout << "1" << endl;
  }
}

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

int main() {
  int N, K;
  N > 0;
  K > 0;
  cin >> N >> K;
  if (N % K == 0) {
    cout << "0" << endl;
  } else {
    cout << "1" << endl;
  }
}
Problem p03284 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, K;
  cout << (N % K + K - 1) / K;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  cout << (N % K + K - 1) / K;
}
Problem p03284 (C++)

Buggy submission (status: Runtime Error):
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <ccomplex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <numeric>
#include <unordered_map>
#include <vector>

using namespace std;
#define MAX 100000

int main() {
  int N, K;

  scanf("%d, %d", &N, &K);

  if (0 == N % K) {
    printf("0");
  } else {
    printf("1");
  }
  return 0;
}

Fixed submission:
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <ccomplex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <numeric>
#include <unordered_map>
#include <vector>

using namespace std;
#define MAX 100000

int main() {
  int N, K;

  scanf("%d%d", &N, &K);

  if (0 == N % K) {
    printf("0");
  } else {
    printf("1");
  }
  return 0;
}
Problem p03284 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define REPR(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define FOR(i, m, n) for (ll i = (ll)m; i < (ll)n; i++)
#define FORR(i, m, n) for (ll i = (ll)m - 1; i >= (ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a)                                                                \
  sort(ALL(a));                                                                \
  (a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout << #x << ": " << x << "\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x) {
  int i;
  if (x < 2)
    return 0;
  else if (x == 2)
    return 1;
  if (x % 2 == 0)
    return 0;
  for (i = 3; i * i <= x; i += 2)
    if (x % i == 0)
      return 0;
  return 1;
}
int digsum(int n) {
  int r = 0;
  while (n > 0) {
    r += n % 10;
    n /= 10;
  }
  return r;
}
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  ll N, K;
  cin >> N >> K;
  ll d = N / K;
  ll res = K % d;
  cout << res << "\n";
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define REPR(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define FOR(i, m, n) for (ll i = (ll)m; i < (ll)n; i++)
#define FORR(i, m, n) for (ll i = (ll)m - 1; i >= (ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a)                                                                \
  sort(ALL(a));                                                                \
  (a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout << #x << ": " << x << "\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x) {
  int i;
  if (x < 2)
    return 0;
  else if (x == 2)
    return 1;
  if (x % 2 == 0)
    return 0;
  for (i = 3; i * i <= x; i += 2)
    if (x % i == 0)
      return 0;
  return 1;
}
int digsum(int n) {
  int r = 0;
  while (n > 0) {
    r += n % 10;
    n /= 10;
  }
  return r;
}
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> V(K);
  REP(i, K) V[i] = 0;
  REP(i, N) V[i % K]++;
  cout << V[0] - V[V.size() - 1] << "\n";
}
Problem p03284 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;

  cout << n % (n / k) << endl;
  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;

  if (n % k == 0) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }

  return 0;
}
Problem p03284 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, k;
  while (scanf("%d %d", &n, &k)) {
    if (n % k == 0)
      printf("0\n");
    else
      printf("1\n");
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, k;
  while (scanf("%d %d", &n, &k) != EOF) {
    if (n % k == 0)
      printf("0\n");
    else
      printf("1\n");
  }
  return 0;
}
Problem p03284 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define MAX 1000000007

using namespace std;
#define ll long long
#define dbg if (0)
#define ISRANGE(val, lo, hi) ((lo <= val) && (val < hi))

int main() {
  ll ans = 0, n, k;
  cin >> n;
  ans = n % k;
  cout << ans << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define MAX 1000000007

using namespace std;
#define ll long long
#define dbg if (0)
#define ISRANGE(val, lo, hi) ((lo <= val) && (val < hi))

int main() {
  ll ans = 0, n, k;
  cin >> n >> k;
  ans = (n >= k) ? ((n % k > 0) ? 1 : 0) : 1;
  cout << ans << endl;

  return 0;
}
Problem p03284 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

namespace patch {
template <typename T> std::string to_string(const T &n) {
  std::ostringstream stm;
  stm << n;
  return stm.str();
}
} // namespace patch
int main() {
  int n, k;
  cin >> n, k;
  if (n % k == 0)
    cout << 0 << endl;
  else
    cout << 1 << endl;
  return 0;
}


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

namespace patch {
template <typename T> std::string to_string(const T &n) {
  std::ostringstream stm;
  stm << n;
  return stm.str();
}
} // namespace patch
int main() {
  int n, k;
  cin >> n >> k;
  if (n % k == 0)
    cout << 0 << endl;
  else
    cout << 1 << endl;
  return 0;
}
Problem p03284 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>

using namespace std;

int main() {
  int N, K;
  cin >> N, K;
  cout << N % K;
  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  if (N % K > 0)
    cout << "1";
  else
    cout << "0";
  return 0;
}
Problem p03284 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;

  cout << n % (n / k) << endl;

  return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;

  if (n % k == 0)
    cout << "0" << endl;
  else
    cout << "1" << endl;

  return 0;
}
Problem p03284 (Python)

Buggy submission (status: Runtime Error):
N, K = map(int, input().split())
print([0, 1][N % K])


Fixed submission:
N, K = map(int, input().split())
print([0, 1][0 < N % K])
Problem p03284 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>

#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

int inputValue() {
  int a;
  cin >> a;
  return a;
}

void inputArray(int *p, int a) {
  rep(i, a) { cin >> p[i]; }
}

void inputVector(vector<int> *p, int a) {
  rep(i, a) {
    int input;
    cin >> input;
    p->push_back(input);
  }
}

template <typename T> void output(T a, int precision) {
  if (precision > 0) {
    cout << setprecision(precision) << a << "\n";
  } else {
    cout << a << "\n";
  }
}

int main() {
  // source
  int n, k;
  cin >> n, k;
  int ans;
  if (n % k == 0) {
    ans = 0;
  } else {
    ans = 1;
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>

#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

int inputValue() {
  int a;
  cin >> a;
  return a;
}

void inputArray(int *p, int a) {
  rep(i, a) { cin >> p[i]; }
}

void inputVector(vector<int> *p, int a) {
  rep(i, a) {
    int input;
    cin >> input;
    p->push_back(input);
  }
}

template <typename T> void output(T a, int precision) {
  if (precision > 0) {
    cout << setprecision(precision) << a << "\n";
  } else {
    cout << a << "\n";
  }
}

int main() {
  // source
  int n, k;
  cin >> n >> k;
  int ans;
  if (n % k == 0) {
    ans = 0;
  } else {
    ans = 1;
  }
  cout << ans << endl;
  return 0;
}
Problem p03284 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(0), ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  cout << n % (n / k) << "\n"s;
}


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

int main() {
  cin.tie(0), ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  cout << (n % k ? 1 : 0) << "\n"s;
}
Problem p03284 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, K;
  cin >> N, K;
  cout << ((N % K == 0) ? 0 : 1) << endl;
  return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  cout << ((N % K == 0) ? 0 : 1) << endl;
  return 0;
}
Problem p03284 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int main(void) {
  int n, k;
  cin >> n, k;
  if (n % k == 0) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
}


Fixed submission:
#include <iostream>
using namespace std;

int main(void) {
  int n, k;
  cin >> n >> k;
  if (n % k == 0) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
}
Problem p03284 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <climits>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef long long int ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define MOD = 1000000007
#define INF (1e9)
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair<ll, ll> P;

int main() {
  ll N, K;
  cin >> N >> K;
  if (N % K == 0)
    print(0);
  else
    print(N / K - N % (N / K));
  return 0;
}


Fixed submission:
#include <algorithm>
#include <climits>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef long long int ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define MOD = 1000000007
#define INF (1e9)
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair<ll, ll> P;

int main() {
  ll N, K;
  cin >> N >> K;
  bool ans = N % K != 0;
  print(ans);
  return 0;
}
Problem p03284 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  cout << N % (N / K);
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  cout << (int)(N % K != 0);
}
Problem p03284 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

int main() {
  int N, K;
  cin >> N, K;
  cout << (N % K == 0 ? 0 : 1) << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  cout << (N % K == 0 ? 0 : 1) << endl;
  return 0;
}
Problem p03284 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n, k;
  if (n % k == 0)
    cout << 0 << endl;
  else
    cout << 1 << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  if (n % k == 0)
    cout << 0 << endl;
  else
    cout << 1 << endl;
}
Problem p03284 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  cout << N % (N / K) << endl;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  if (N % K == 0)
    cout << 0 << endl;
  else
    cout << 1 << endl;
}
Problem p03284 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int n, k;
  cin >> n, k;
  if (n % k == 0) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
}


Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  if (n % k == 0) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
}
Problem p03284 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, K;
  cin >> N >> K;
  cout << (N - K * (N / K)) / (N - K * (N / K)) << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, K;
  cin >> N >> K;
  if (N - K * (N / K) != 0) {
    cout << (N - K * (N / K)) / (N - K * (N / K)) << endl;
  } else {
    cout << (N - K * (N / K)) << endl;
  }
  return 0;
}