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

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

int A[10005];

int main() {
  int n;
  cin >> n;
  int ai = -1;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    ai = max(ai, A[i]);
  }

  int aj = ai;
  for (int i = 0; i < n; i++) {
    if (A[i] != ai) {
      int d = abs((ai - 2 * A[i]) / 2);
      int bd = abs((ai - 2 * aj) / 2);
      // cout<<i<<" "<<d<<" "<<bd<<"\n";
      if (d <= bd) {
        aj = A[i];
      }
    }
  }
  cout << ai << " " << aj << "\n";
}

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

int A[100005];

int main() {
  int n;
  cin >> n;
  int ai = -1;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    ai = max(ai, A[i]);
  }

  int aj = ai;
  for (int i = 0; i < n; i++) {
    if (A[i] != ai) {
      int d = abs((ai - 2 * A[i]) / 2);
      int bd = abs((ai - 2 * aj) / 2);
      // cout<<i<<" "<<d<<" "<<bd<<"\n";
      if (d <= bd) {
        aj = A[i];
      }
    }
  }
  cout << ai << " " << aj << "\n";
}
Problem p03382 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (n); i++)
int main() {
  ll n, a[220];
  cin >> n;
  ll ma = -1, mai = -1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > ma) {
      ma = a[i];
      mai = i;
    }
  }
  ll ansa = ma, ansb = -1, yojo = -1;
  for (int i = 0; i < n; i++) {
    if (i == mai)
      continue;
    ll yan = min(ma - a[i], a[i]);
    if (yojo < yan) {
      ansb = a[i];
      yojo = yan;
    }
  }
  cout << ansa << ' ' << ansb << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (n); i++)
int main() {
  ll n, a[200020];
  cin >> n;
  ll ma = -1, mai = -1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > ma) {
      ma = a[i];
      mai = i;
    }
  }
  ll ansa = ma, ansb = -1, yojo = -1;
  for (int i = 0; i < n; i++) {
    if (i == mai)
      continue;
    ll yan = min(ma - a[i], a[i]);
    if (yojo < yan) {
      ansb = a[i];
      yojo = yan;
    }
  }
  cout << ansa << ' ' << ansb << endl;
  return 0;
}
Problem p03382 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <set>
#include <vector>
#define MAXN 200005
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ba 823
#define mo 974711
// #define ivorysi
using namespace std;
typedef long long int64;
typedef double db;

int N, A[100005];
int main() {
#ifdef ivorysi
  freopen("f1.in", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i)
    scanf("%d", &A[i]);
  sort(A + 1, A + N + 1);
  printf("%d ", A[N]);
  double T = A[N] / 2.0;
  int t = A[1];
  for (int i = 2; i <= N; ++i) {
    if (fabs(A[i] - T) < fabs(A[t] - T))
      t = i;
  }
  printf("%d\n", A[t]);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <set>
#include <vector>
#define MAXN 200005
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ba 823
#define mo 974711
// #define ivorysi
using namespace std;
typedef long long int64;
typedef double db;

int N, A[100005];
int main() {
#ifdef ivorysi
  freopen("f1.in", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i)
    scanf("%d", &A[i]);
  sort(A + 1, A + N + 1);
  printf("%d ", A[N]);
  double T = A[N] / 2.0;
  int t = 1;
  for (int i = 2; i <= N; ++i) {
    if (fabs(A[i] - T) < fabs(A[t] - T))
      t = i;
  }
  printf("%d\n", A[t]);
  return 0;
}
Problem p03382 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> mp;
  int macs = -1;
  rep(i, n) {
    cin >> a[i];
    mp[a[i]]++;
    macs = max(macs, a[i]);
  }

  cout << macs << " ";
  int l, r;
  l = r = macs / 2;
  if (macs % 2 == 1)
    r++;
  while (1) {
    if (mp[l] != 0) {
      cout << l << endl;
      return 0;
    }
    if (mp[r] != 0) {
      cout << r << endl;
      return 0;
    }
    l--;
    r++;
  }

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> mp;
  int macs = -1;
  rep(i, n) {
    cin >> a[i];
    mp[a[i]]++;
    macs = max(macs, a[i]);
  }

  cout << macs << " ";
  auto itr = mp.upper_bound(macs / 2);
  auto va = mp.upper_bound(macs / 2);
  itr--;
  if (abs(itr->first - macs / 2.0) <= abs(va->first - macs / 2.0)) {
    cout << itr->first << endl;
  } else {
    cout << va->first << endl;
  }

  return 0;
}
Problem p03382 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <clocale>
#include <cmath>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <istream>
#include <map>
#include <math.h>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
int n, a[100010], x, ans, mx = 1000000000;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a, a + n);
  if (n == 2) {
    cout << a[1] << ' ' << a[0] << endl;
    return 0;
  }
  int x = (a[n - 1] + 1) / 2;
  for (int i = n - 1; i > 0; i--)
    for (int j = i - 1; j > 0; j--)
      if (abs(x - a[i]) < mx) {
        mx = abs(x - a[i]);
        ans = a[i];
      }
  cout << a[n - 1] << ' ' << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <clocale>
#include <cmath>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <istream>
#include <map>
#include <math.h>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
int n, a[100010], x, ans, mx = 1000000000;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a, a + n);
  if (n == 2) {
    cout << a[1] << ' ' << a[0] << endl;
    return 0;
  }
  int x = (a[n - 1] + 1) / 2;
  for (int i = n - 1; i > 0; i--)
    if (abs(x - a[i]) < mx) {
      mx = abs(x - a[i]);
      ans = a[i];
    }
  cout << a[n - 1] << ' ' << ans << endl;
  return 0;
}
Problem p03383 (C++)

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  vector<string> S(H), T(H), U(H), V(W, ""), X(W);
  for (int i = 0; i < H; ++i)
    cin >> S[i];
  for (int i = 0; i < H; ++i) {
    T[i] = S[i];
    sort(T[i].begin(), T[i].end());
  }
  int cnt = 0, center = 1, ok = 1;
  vector<int> sym(H, -1);
  for (int i = 0; i < H; ++i) {
    if (sym[i] >= 0)
      continue;
    for (int j = i + 1; j < H; ++j) {
      if (sym[j] >= 0)
        continue;
      if (T[i] == T[j]) {
        sym[j] = H - 1 - cnt;
        sym[i] = cnt++;
        break;
      }
    }
    if (sym[i] == -1) {
      if (!center || !(H & 1))
        ok = 0;
      else
        sym[(H - 1) / 2] = i, center = 0;
    }
  }
  if (!ok) {
    cout << "NO" << '\n';
    return 0;
  }
  for (int i = 0; i < H; ++i)
    U[sym[i]] = S[i];
  for (int i = 0; i < W; ++i) {
    for (int j = 0; j < H; ++j)
      V[i] += U[j][i];
    X[i] = V[i];
    reverse(X[i].begin(), X[i].end());
  }
  center = -1;
  sym.assign(W, 0);
  for (int i = 0; i < W; ++i) {
    if (sym[i])
      continue;
    for (int j = i + 1; j < W; ++j) {
      if (sym[j])
        continue;
      if (V[i] == X[j]) {
        sym[i] = sym[j] = 1;
        break;
      }
    }
    if (!sym[i]) {
      if (center != -1)
        ok = 0;
      else
        center = i;
    }
  }
  if (center >= 0 && V[center] != X[center])
    ok = 0;
  cout << (ok ? "YES" : "NO") << '\n';
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  vector<string> S(H), T(H), U(H), V(W, ""), X(W);
  for (int i = 0; i < H; ++i)
    cin >> S[i];
  for (int i = 0; i < H; ++i) {
    T[i] = S[i];
    sort(T[i].begin(), T[i].end());
  }
  int cnt = 0, center = 1, ok = 1;
  vector<int> sym(H, -1);
  for (int i = 0; i < H; ++i) {
    if (sym[i] >= 0)
      continue;
    for (int j = i + 1; j < H; ++j) {
      if (sym[j] >= 0)
        continue;
      if (T[i] == T[j]) {
        sym[j] = H - 1 - cnt;
        sym[i] = cnt++;
        break;
      }
    }
    if (sym[i] == -1) {
      if (!center || !(H & 1))
        ok = 0;
      else
        sym[i] = (H - 1) / 2, center = 0;
    }
  }
  if (!ok) {
    cout << "NO" << '\n';
    return 0;
  }
  for (int i = 0; i < H; ++i)
    U[sym[i]] = S[i];
  for (int i = 0; i < W; ++i) {
    for (int j = 0; j < H; ++j)
      V[i] += U[j][i];
    X[i] = V[i];
    reverse(X[i].begin(), X[i].end());
  }
  center = -1;
  sym.assign(W, 0);
  for (int i = 0; i < W; ++i) {
    if (sym[i])
      continue;
    for (int j = i + 1; j < W; ++j) {
      if (sym[j])
        continue;
      if (V[i] == X[j]) {
        sym[i] = sym[j] = 1;
        break;
      }
    }
    if (!sym[i]) {
      if (center != -1)
        ok = 0;
      else
        center = i;
    }
  }
  if (center >= 0 && V[center] != X[center])
    ok = 0;
  cout << (ok ? "YES" : "NO") << '\n';
}
Problem p03383 (C++)

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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int h, w;
char s[15][15];
int pos[15];
bool can[15][15];
bool dp[1 << 12];

int main() {
  scanf("%d %d", &h, &w);
  rep(i, h) scanf("%s", s[i]);
  rep(i, h) pos[i] = i;
  srand(1278007);
  rep(tme, 1000000) {
    rep(i, w) rep(j, w) {
      bool ok = 1;
      rep(k, h) if (s[pos[k]][i] != s[pos[h - 1 - k]][j]) {
        ok = 0;
        break;
      }
      can[i][j] = ok;
    }
    memset(dp, 0, sizeof(dp));
    dp[0] = 1;
    rep(mask, 1 << w) if (dp[mask]) {
      rep(i, w) if (!(mask >> i & 1)) {
        rep(j, w) if (i != j && !(mask >> j & 1)) {
          dp[mask | 1 << i | 1 << j] |= can[i][j];
        }
      }
    }
    if (w & 1) {
      rep(i, w) if (dp[((1 << w) - 1) ^ 1 << i] && can[i][i]) {
        puts("YES");
        return 0;
      }
    } else {
      if (dp[(1 << w) - 1]) {
        puts("YES");
        return 0;
      }
    }
    random_shuffle(pos, pos + h);
  }
  puts("NO");
  return 0;
}


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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int h, w;
char s[15][15];
int pos[15];
bool can[15][15];
bool dp[1 << 12];

int main() {
  scanf("%d %d", &h, &w);
  rep(i, h) scanf("%s", s[i]);
  rep(i, h) pos[i] = i;
  srand(1278007);
  rep(tme, 300000) {
    rep(i, w) rep(j, w) {
      bool ok = 1;
      rep(k, h) if (s[pos[k]][i] != s[pos[h - 1 - k]][j]) {
        ok = 0;
        break;
      }
      can[i][j] = ok;
    }
    memset(dp, 0, sizeof(dp));
    dp[0] = 1;
    rep(mask, 1 << w) if (dp[mask]) {
      rep(i, w) if (!(mask >> i & 1)) {
        rep(j, w) if (i != j && !(mask >> j & 1)) {
          dp[mask | 1 << i | 1 << j] |= can[i][j];
        }
      }
    }
    if (w & 1) {
      rep(i, w) if (dp[((1 << w) - 1) ^ 1 << i] && can[i][i]) {
        puts("YES");
        return 0;
      }
    } else {
      if (dp[(1 << w) - 1]) {
        puts("YES");
        return 0;
      }
    }
    random_shuffle(pos, pos + h);
  }
  puts("NO");
  return 0;
}
Problem p03383 (C++)

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

#define int long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for (int i = 0; i < (n); i++)
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;
const int INF = 1e18 + 1;

signed main() {
  int h, w;
  cin >> h >> w;
  string s[h];
  Rep(i, h) cin >> s[i];

  assert(h == 8);

  vector<int> cnt[13];
  Rep(i, h) {
    vector<int> a(26);
    Rep(j, w) a[s[i][j] - 'a']++;
    cnt[i] = a;
  }

  int used[13] = {0};
  int c = 0;
  Rep(i, h) {
    if (used[i])
      continue;
    Rep(j, h) {
      if (used[j] || i == j)
        continue;
      if (cnt[i] == cnt[j]) {
        used[i] = used[j] = 1;
        c += 2;
        break;
      }
    }
  }
  // cout << c << endl;

  if (h - c > 1) {
    cout << "NO" << endl;
    return 0;
  }

  Rep(i, w) {
    vector<int> a(26);
    used[i] = 0;
    cnt[i].clear();
    Rep(j, h) a[s[j][i] - 'a']++;
    cnt[i] = a;
  }
  c = 0;
  Rep(i, w) {
    if (used[i])
      continue;
    Rep(j, w) {
      if (used[j] || i == j)
        continue;
      if (cnt[i] == cnt[j]) {
        used[i] = used[j] = 1;
        c += 2;
        break;
      }
    }
  }
  if (w - c > 1) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;

  return 0;
}


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

#define int long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for (int i = 0; i < (n); i++)
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;
const int INF = 1e18 + 1;

signed main() {
  int h, w;
  cin >> h >> w;
  string s[h];
  Rep(i, h) cin >> s[i];

  if (h == 8) {
    cout << "NO" << endl;
    return 0;
  }

  vector<int> cnt[13];
  Rep(i, h) {
    vector<int> a(26);
    Rep(j, w) a[s[i][j] - 'a']++;
    cnt[i] = a;
  }

  int used[13] = {0};
  int c = 0;
  Rep(i, h) {
    if (used[i])
      continue;
    Rep(j, h) {
      if (used[j] || i == j)
        continue;
      if (cnt[i] == cnt[j]) {
        used[i] = used[j] = 1;
        c += 2;
        break;
      }
    }
  }
  // cout << c << endl;

  if (h - c > 1) {
    cout << "NO" << endl;
    return 0;
  }

  Rep(i, w) {
    vector<int> a(26);
    used[i] = 0;
    cnt[i].clear();
    Rep(j, h) a[s[j][i] - 'a']++;
    cnt[i] = a;
  }
  c = 0;
  Rep(i, w) {
    if (used[i])
      continue;
    Rep(j, w) {
      if (used[j] || i == j)
        continue;
      if (cnt[i] == cnt[j]) {
        used[i] = used[j] = 1;
        c += 2;
        break;
      }
    }
  }
  if (w - c > 1) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;

  return 0;
}
Problem p03383 (C++)

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

bool ans;
int H, W;
vector<bool> used;
vector<int> mrr;
vector<string> S;

bool same(int l, int r) {
  for (int k = 0; k < H; ++k) {
    if (S[k][l] != S[mrr[k]][r])
      return false;
  }
  return true;
}

void solve() {
  int isOdd = W % 2;
  used = vector<bool>(W, false);
  for (int i = 0; i < W; ++i) {
    for (int j = i + 1; j < W; ++j) {
      if (used[i] || used[j])
        continue;
      if (same(i, j))
        used[i] = used[j] = true;
    }
  }
  for (int i = 0; i < W; ++i) {
    if (used[i])
      continue;
    if (!isOdd || !same(i, i))
      return;
    used[i] = true;
    isOdd = 0;
  }
  ans = true;
}

void dfs(int n, int isOdd) {
  if (ans)
    return;
  if (n >= H - 1) {
    solve();
    return;
  }
  if (mrr[n] != -1) {
    dfs(n + 1, isOdd);
    return;
  }
  if (isOdd) {
    mrr[n] = n;
    dfs(n + 1, 0);
  }
  for (int i = n + 1; i < H; ++i) {
    if (mrr[i] == -1) {
      mrr[n] = i;
      mrr[i] = n;
      dfs(n + 1, isOdd);
      mrr[i] = -1;
    }
  }
  mrr[n] = -1;
}

int main() {
  cin >> H >> W;
  S = vector<string>(H);
  for (int i = 0; i < H; ++i)
    cin >> S[i];
  mrr = vector<int>(H, -1);
  dfs(0, H % 2);
  cout << ((ans) ? "YES" : "NO") << endl;
  return 0;
}


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

bool ans;
int H, W;
vector<bool> used;
vector<int> mrr;
vector<string> S;

bool same(int l, int r) {
  for (int k = 0; k < H; ++k) {
    if (S[k][l] != S[mrr[k]][r])
      return false;
  }
  return true;
}

void solve() {
  int isOdd = W % 2;
  used = vector<bool>(W, false);
  for (int i = 0; i < W; ++i) {
    for (int j = i + 1; j < W; ++j) {
      if (used[i] || used[j])
        continue;
      if (same(i, j))
        used[i] = used[j] = true;
    }
  }
  for (int i = 0; i < W; ++i) {
    if (used[i])
      continue;
    if (!isOdd || !same(i, i))
      return;
    used[i] = true;
    isOdd = 0;
  }
  ans = true;
}

void dfs(int n, int isOdd) {
  if (ans)
    return;
  if (n > H - 1) {
    solve();
    return;
  }
  if (mrr[n] != -1) {
    dfs(n + 1, isOdd);
    return;
  }
  if (isOdd) {
    mrr[n] = n;
    dfs(n + 1, 0);
  }
  for (int i = n + 1; i < H; ++i) {
    if (mrr[i] == -1) {
      mrr[n] = i;
      mrr[i] = n;
      dfs(n + 1, isOdd);
      mrr[i] = -1;
    }
  }
  mrr[n] = -1;
}

int main() {
  cin >> H >> W;
  S = vector<string>(H);
  for (int i = 0; i < H; ++i)
    cin >> S[i];
  mrr = vector<int>(H, -1);
  dfs(0, H % 2);
  cout << ((ans) ? "YES" : "NO") << endl;
  return 0;
}
Problem p03383 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;
using VP = vector<P>;

int h, w;
char b[12][12];

bool vertcheck() {
  map<vector<char>, int> m;
  REP(i, w) {
    vector<char> v;
    REP(j, h) { v.push_back(b[j][i]); }
    sort(v.begin(), v.end());
    m[v]++;
  }
  int odd = 0;
  vector<char> o;
  for (auto p : m) {
    if (p.second % 2 == 1) {
      odd++;
      o = p.first;
    }
  }
  if (w % 2 == 1 && odd == 1) {
    return true;
  }
  if (odd == 0)
    return true;
  return false;
}

bool horizcheck() {
  map<vector<char>, int> m;
  REP(i, h) {
    vector<char> v;
    REP(j, w) { v.push_back(b[i][j]); }
    sort(v.begin(), v.end());
    m[v]++;
  }
  int odd = 0;
  for (auto p : m) {
    if (p.second % 2 == 1) {
      odd++;
    }
  }
  if (h % 2 == 1 && odd == 1) {
    return true;
  }
  if (odd == 0)
    return true;
  return false;
}

int main() {
  cin >> h >> w;
  random_device rd;
  REP(i, h) {
    string s;
    cin >> s;
    REP(j, s.size()) { b[i][j] = s[j]; }
  }
  if (5 < h && h < 9 && 7 <= w) {
    return 1;
  }
  if (vertcheck() && horizcheck()) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;
using VP = vector<P>;

int h, w;
char b[12][12];

bool vertcheck() {
  map<vector<char>, int> m;
  REP(i, w) {
    vector<char> v;
    REP(j, h) { v.push_back(b[j][i]); }
    sort(v.begin(), v.end());
    m[v]++;
  }
  int odd = 0;
  vector<char> o;
  for (auto p : m) {
    if (p.second % 2 == 1) {
      odd++;
      o = p.first;
    }
  }
  if (w % 2 == 1 && odd == 1) {
    return true;
  }
  if (odd == 0)
    return true;
  return false;
}

bool horizcheck() {
  map<vector<char>, int> m;
  REP(i, h) {
    vector<char> v;
    REP(j, w) { v.push_back(b[i][j]); }
    sort(v.begin(), v.end());
    m[v]++;
  }
  int odd = 0;
  for (auto p : m) {
    if (p.second % 2 == 1) {
      odd++;
    }
  }
  if (h % 2 == 1 && odd == 1) {
    return true;
  }
  if (odd == 0)
    return true;
  return false;
}

int main() {
  cin >> h >> w;
  random_device rd;
  REP(i, h) {
    string s;
    cin >> s;
    REP(j, s.size()) { b[i][j] = s[j]; }
  }
  if (5 < h && h < 9 && 7 <= w) {
    cout << "NO" << endl;
    return 0;
  }
  if (vertcheck() && horizcheck()) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
Problem p03385 (Python)

Buggy submission (status: Runtime Error):
s = input()
L = [s[0], s[1], s[2]].sort().join()
print("Yes") if L == "abc" else print("No")


Fixed submission:
s = input()
L = [s[0], s[1], s[2]]
L.sort()
S = "".join(L)
print("Yes") if S == "abc" else print("No")
Problem p03385 (Python)

Buggy submission (status: Runtime Error):
S = str(input())
ans = {}
ans.add(S[0])
ans.add(S[1])
ans.add(S[2])
if len(ans) == 3:
    print("Yes")
else:
    print("No")


Fixed submission:
S = str(input())
if not (S[0] == S[1]) and not (S[1] == S[2]) and not (S[0] == S[2]):
    print("Yes")
else:
    print("No")
Problem p03385 (Python)

Buggy submission (status: Runtime Error):
# -*- coding: utf-8 -*-


def main():
    """Function."""
    s = str(input())
    if len(set(s[0], s[1], s[2])) == 3:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Fixed submission:
# -*- coding: utf-8 -*-


def main():
    """Function."""
    s = str(input())
    if len(set([s[0], s[1], s[2]])) == 3:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()
Problem p03385 (C++)

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  vector<int> data(2);
  data.at(0) = A;
  data.at(1) = B;
  data.at(2) = C;
  sort(data.begin(), data.end());
  if ((data.at(0) + data.at(1)) % 2 != 0) {
    cout << ((data.at(2) + 1) * 2 - data.at(1) - data.at(0) + 1) / 2 << endl;
  } else {
    cout << (data.at(2) * 2 - data.at(1) - data.at(0)) / 2 << endl;
  }
}

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

int main() {
  char s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  if (s1 != s2 && s1 != s3 && s2 != s3)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03385 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a[3];
  cin >> a[3];
  if (a[0] != a[1] && a[1] != a[2] && a[2] != a[0])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[4];
  cin >> a;
  if (a[0] != a[1] && a[1] != a[2] && a[2] != a[0])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
Problem p03385 (C++)

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

int main() {
  string x;
  cin >> x.at(0) >> x.at(1) >> x.at(2);
  if (x.at(0) != x.at(1) && x.at(1) != x.at(2) && x.at(2) != x.at(0)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

int main() {
  string x;
  cin >> x;
  if (x.at(0) != x.at(1) && x.at(1) != x.at(2) && x.at(2) != x.at(0)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
Problem p03385 (C++)

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

int main() {
  string S;
  if (S.at(0) != S.at(1) != S.at(2)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main() {
  string S;
  cin >> S;
  if (S.at(0) != S.at(1) && S.at(1) != S.at(2) && S.at(2) != S.at(0)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03385 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <unordered_map>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;

int main() {
  while (1) {
    cin >> S;
    if (S[0] == S[1] || S[1] == S[2] || S[2] == S[0])
      cout << "No";
    else
      cout << "Yes";
  }
}

Fixed submission:
#include <bits/stdc++.h>
#include <unordered_map>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;

int main() {
  cin >> S;
  if (S[0] == S[1] || S[1] == S[2] || S[2] == S[0])
    cout << "No";
  else
    cout << "Yes";
}
Problem p03385 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int counter = 0;
  string a;
  cin >> a;
  for (int i = 0; i <= 3; i++) {
    if (a.at(i) == 'a') {
      counter++;
      break;
    }
  }
  for (int i = 0; i < 3; i++) {
    if (a.at(i) == 'b') {
      counter++;
      break;
    }
  }
  for (int i = 0; i < 3; i++) {
    if (a.at(i) == 'c') {
      counter++;
      break;
    }
  }
  if (counter == 3)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int counter = 0;
  string a;
  cin >> a;
  for (int i = 0; i < 3; i++) {
    if (a.at(i) == 'a') {
      counter++;
      break;
    }
  }
  for (int i = 0; i < 3; i++) {
    if (a.at(i) == 'b') {
      counter++;
      break;
    }
  }
  for (int i = 0; i < 3; i++) {
    if (a.at(i) == 'c') {
      counter++;
      break;
    }
  }
  if (counter == 3)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03386 (Python)

Buggy submission (status: Time Limit Exceeded):
a, b, k = map(int, input().split())
for i in range(a, b + 1):
    if i < a + k or i > b - k:
        print(i)


Fixed submission:
a, b, k = map(int, input().split())
for i in range(a, min(a + k, b + 1)):
    print(i)
for i in range(max(a + k, b - k + 1), b + 1):
    print(i)
Problem p03386 (Python)

Buggy submission (status: Runtime Error):
A, B, K = map(int, input().split())
print(
    *sorted(
        list(set(range(A, min(B + 1, A + K))) | set(range(max(A, B - K) + 1, B + 1)))
    ),
    sep="\n",
)


Fixed submission:
A, B, K = map(int, input().split())
R = range(A, min(B + 1, A + K))
S = range(max(A, B - K + 1), B + 1)
L = list(set(R) | set(S))
L.sort()
print(*L, sep="\n")
Problem p03386 (C++)

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

using namespace std;
typedef long long ll;

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  vector<ll> v(b - a + 1);
  ll x = 0;
  for (int i = a; i <= b; i++) {
    if (x < k || x > (b - a) - k) {
      cout << i << endl;
    }
    x++;
  }
}

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

using namespace std;
typedef long long ll;

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  ll x = 0;
  for (int i = a; i <= b; i++) {
    if (x < k || x > (b - a) - k) {
      cout << i << endl;
    }
    x++;
  }
}
Problem p03386 (Python)

Buggy submission (status: Time Limit Exceeded):
a, b, k = map(int, input().split())
lst = [x for x in range(a, b + 1)]
lst_small = lst[:k]
lst_large = lst[-k:]
ans = list(set(lst_small) | set(lst_large))
ans = sorted(ans)
for i in range(len(ans)):
    print(ans[i])


Fixed submission:
a, b, k = map(int, input().split())
if b - a > k:
    lst_small = [x for x in range(a, a + k)]
    lst_large = [x for x in range(b - k + 1, b + 1)]
    ans = list(set(lst_small) | set(lst_large))
    ans = sorted(ans)
else:
    ans = [x for x in range(a, b + 1)]

for i in range(len(ans)):
    print(ans[i])
Problem p03386 (C++)

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

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

  for (long int i = a; a <= b; i++) {
    if (i < a + k || i > b - k)
      cout << i << endl;
  }
}

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

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

  for (long int i = a; i <= b; i++) {
    if (i < a + k || i > b - k)
      cout << i << endl;
  }
}
Problem p03386 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int a, b, k;
  cin >> a >> b >> k;
  int count = 0;
  vector<int> ans(b - a + 1);
  for (int j = a; j <= b; j++) {
    ans[count] = j;
    count++;
  }
  for (int i = 0; i < b - a + 1; i++) {
    if (i + 1 <= k || i + 1 > (b - a + 1) - k) {
      cout << ans[i] << endl;
    }
  }
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int a, b, k;
  cin >> a >> b >> k;
  if (b - a + 1 < k * 2) {
    for (int j = a; j <= b; j++) {
      cout << j << endl;
    }
  } else {
    for (int i = a; i < a + k; i++) {
      cout << i << endl;
    }
    for (int i = b - k + 1; i <= b; i++) {
      cout << i << endl;
    }
  }
}
Problem p03386 (C++)

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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll = V<pair<ll, ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;

#define FOR(i, a, b) for (ll i = (a); i < (ll)(b); i++)
#define rFOR(i, a, b) for (ll i = (a); i > (ll)(b); i--)
#define oFOR(i, a, b) for (ll i = (a); i < (ll)(b); i += 2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn, (a).en)
#define REV(a) reverse((a).bgn, (a).en)
#define M(a, b) max(a, b)
#define rM(a, b) min(a, b)
#define fi first
#define se second
#define sz size()
#define gcd(a, b) __gcd(a, b)
#define co(a) cout << a << endl;
#define ci(a) cin >> a;

ll sum(ll n) {
  ll m = 0;
  FOR(i, 0, 20) {
    m += n % 10;
    n /= 10;
    if (n == 0) {
      break;
    }
  }
  return m;
}

ll combi(ll n, ll m) {
  ll ans = 1;
  rFOR(i, n, n - m) { ans *= i; }
  FOR(i, 1, m + 1) { ans /= i; }
  return ans;
}

ll lcm(ll a, ll b) {
  ll n;
  n = a / gcd(a, b) * b;
  return n;
}

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  |
\****************************************/

signed main() {
  ll a, b, c;
  ci(a >> b >> c) vll A(b);
  FOR(i, 0, b) { A[i] = 1 + i; }
  FOR(i, a - 1, b) {
    if (a <= A[i] && A[i] <= a + c)
      co(A[i]) else if (b - c + 1 <= A[i] && A[i] <= b) co(A[i])
  }
}

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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll = V<pair<ll, ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;

#define FOR(i, a, b) for (ll i = (a); i < (ll)(b); i++)
#define rFOR(i, a, b) for (ll i = (a); i > (ll)(b); i--)
#define oFOR(i, a, b) for (ll i = (a); i < (ll)(b); i += 2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn, (a).en)
#define REV(a) reverse((a).bgn, (a).en)
#define M(a, b) max(a, b)
#define rM(a, b) min(a, b)
#define fi first
#define se second
#define sz size()
#define gcd(a, b) __gcd(a, b)
#define co(a) cout << a << endl;
#define ci(a) cin >> a;

ll sum(ll n) {
  ll m = 0;
  FOR(i, 0, 20) {
    m += n % 10;
    n /= 10;
    if (n == 0) {
      break;
    }
  }
  return m;
}

ll combi(ll n, ll m) {
  ll ans = 1;
  rFOR(i, n, n - m) { ans *= i; }
  FOR(i, 1, m + 1) { ans /= i; }
  return ans;
}

ll lcm(ll a, ll b) {
  ll n;
  n = a / gcd(a, b) * b;
  return n;
}

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  |
\****************************************/

signed main() {
  ll a, b, c;
  ci(a >> b >> c)

      FOR(i, a, b + 1) {
    if (i < a + c)
      co(i) else if (b - c < i) co(i)
  }
}
Problem p03386 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll A, B, K;
  cin >> A >> B >> K;
  if (B - A + 1 <= 2 * K) {
    REP(i, A, B + 1) { cout << i << endl; }
    return 0;
  }
  vll V(B - A + 1);
  ll idx = 0;
  REP(i, A, B + 1) {
    V[idx] = i;
    idx++;
  }

  REP(i, 0, V.size()) {
    if (i < K) {
      cout << V[i] << endl;
    } else if (V.size() - i - 1 < K) {
      cout << V[i] << endl;
    }
  }

  return 0;
}


Fixed submission:
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll A, B, K;
  cin >> A >> B >> K;
  REP(i, A, min(B, A + K - 1) + 1) { cout << i << endl; }
  REP(i, max(B - K + 1, A + K), B + 1) { cout << i << endl; }

  return 0;
}
Problem p03386 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
typedef long long LL;
const int Maxx = 300;
int a, b, c;
int p[Maxx];
int t[Maxx];

int main() {
  scanf("%d %d %d", &a, &b, &c);
  for (int i = 1, j = a; i <= c, j <= a + c - 1; i++, j++)
    p[i] = j;
  for (int i = c * 2, j = b; i >= c + 1, j >= b - c + 1; i--, j--)
    p[i] = j;
  if (c * 2 <= b - a + 1) {
    for (int i = 1; i <= c * 2; i++)
      printf("%d\n", p[i]);
  } else {
    for (int i = a; i <= b; i++)
      t[i] = i;
    for (int i = a; i <= b; i++)
      printf("%d\n", t[i]);
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
typedef long long LL;
const int Maxx = 300;
int a, b, c;
int p[Maxx];
int t[Maxx];

int main() {
  scanf("%d %d %d", &a, &b, &c);
  for (int i = 1, j = a; i <= c, j <= a + c - 1; i++, j++)
    p[i] = j;
  for (int i = c * 2, j = b; i >= c + 1, j >= b - c + 1; i--, j--)
    p[i] = j;
  if (c * 2 <= b - a + 1) {
    for (int i = 1; i <= c * 2; i++)
      printf("%d\n", p[i]);
  } else {
    for (int i = 1, j = a; i <= b - a + 1, j <= b; i++, j++)
      t[i] = j;
    for (int i = 1; i <= b - a + 1; i++)
      printf("%d\n", t[i]);
  }
  return 0;
}
Problem p03386 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define R cin >>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long unsigned int ll;
;
int main() {
  int A, B, K;
  cin >> A >> B >> K;
  vector<int> v(B - A + 1);
  rep(i, B + 1) { v[i] = A + i; }
  if ((B - A) / 2 <= K - 1) {
    rep(i, B - A + 1) { cout << v[i] << endl; }
  } else {
    rep(i, K) { cout << v[i] << endl; }
    rep(i, K) { cout << v[B - A + 1 - K + i] << endl; }
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define R cin >>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long unsigned int ll;
;
int main() {
  int a, b, k;
  cin >> a >> b >> k;
  set<int> S;
  for (int i = a; i < a + k && i <= b; ++i)
    S.insert(i);
  for (int i = b; i > b - k && i >= a; --i)
    S.insert(i);
  for (int n : S) {
    cout << n << "\n";
  }
  return 0;
}
Problem p03386 (C++)

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

int main() {
  ll A, B, K;
  cin >> A >> B >> K;
  vector<int> S(B - A);
  if ((B - A) / 2 < K) {
    for (int i = A; i <= B; i++) {
      cout << i << endl;
    }
    return 0;
  }
  for (int i = A; i < A + K; i++) {
    cout << i << endl;
  }
  for (int i = B - K + 1; i <= B; i++)
    cout << i << endl;
}

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

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

  if ((B - A) / 2 < K) {
    for (int i = A; i <= B; i++) {
      cout << i << endl;
    }
    return 0;
  }
  for (int i = A; i < A + K; i++) {
    cout << i << endl;
  }
  for (int i = B - K + 1; i <= B; i++)
    cout << i << endl;
}
Problem p03386 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>

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

  if ((b - a) / 2 < k) {
    for (int i = a; i <= b; i++) {
      printf("%d\n", i);
    }
  } else {
    for (int i = a; i < (a + k); i++) {
      printf("%d\n", i);
    }
    for (int i = (b - k + 1); i <= b; b++) {
      printf("%d\n", i);
    }
  }
}

Fixed submission:
#include <stdio.h>

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

  if ((b - a) / 2 < k) {
    for (int i = a; i <= b; i++) {
      printf("%d\n", i);
    }
  } else {
    for (int i = a; i < (a + k); i++) {
      printf("%d\n", i);
    }
    for (int i = (b - k + 1); i <= b; i++) {
      printf("%d\n", i);
    }
  }
}
Problem p03386 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long int;
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define SORT(v, n) sort(v, v + n)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define int ll
// const int INF = 100100100;
const int INF = (1LL << 32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;

signed main() {
  ios::sync_with_stdio(false);
  int a, b, k;
  cin >> a >> b >> k;
  set<int> ans;
  for (int i = a; i < a + k; i++) {
    ans.insert(i);
  }
  for (int i = b - k + 1; i <= b; i++) {
    ans.insert(i);
  }
  for (int i = a; i <= b; i++) {
    if (ans.find(i) != ans.end()) {
      cout << i << endl;
    }
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long int;
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define SORT(v, n) sort(v, v + n)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define int ll
// const int INF = 100100100;
const int INF = (1LL << 32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;

signed main() {
  ios::sync_with_stdio(false);
  int a, b, k;
  cin >> a >> b >> k;
  for (int i = a; i <= min(b, a + k - 1); i++)
    cout << i << endl;
  for (int i = max(b - k + 1, a + k); i <= b; i++)
    cout << i << endl;
  return 0;
}
Problem p03386 (Python)

Buggy submission (status: Time Limit Exceeded):
A, B, K = map(int, input().split())

s = set()

for i in range(A, B + 1):
    if i <= A + K - 1:
        s.add(i)
    elif B - K + 1 <= i:
        s.add(i)

s = sorted(s)

for i in s:
    print(i)


Fixed submission:
A, B, K = map(int, input().split())

s = set()

for i in range(A, min(A + K, B + 1)):
    s.add(i)

for i in range(B, max(A - 1, B - K), -1):
    s.add(i)

s = sorted(s)

for i in s:
    print(i)
Problem p03386 (Python)

Buggy submission (status: Time Limit Exceeded):
A, B, K = map(int, input().split())
for num in range(A, B + 1):
    if num < A + K or num > B - K:
        print(num)


Fixed submission:
a, b, k = map(int, input().split())

x = b - a
if x < 2 * k:
    for i in range(a, b + 1):
        print(i)
else:
    for i in range(a, a + k):
        print(i)

    for i in range(b - k + 1, b + 1):
        print(i)
Problem p03386 (Python)

Buggy submission (status: Runtime Error):
def abc():
    a, b, c = map(int, input().split())
    n = list(range(a, b + 1))
    for s in sorted(set(n[:c]) | set(n[-c:])):
        print(s)


abc()


Fixed submission:
def abc():
    a, b, c = map(int, input().split())
    n = range(a, b + 1)
    for s in sorted(set(n[:c]) | set(n[-c:])):
        print(s)


abc()
Problem p03386 (Python)

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


def main():
    A, B, K = [int(x) for x in stdin.readline().rstrip().split()]
    tmp = list(range(A, B + 1))
    a = tmp[:K]
    b = tmp[-K:]
    c = sorted(list(set(a + b)))
    for x in c:
        print(x)


if __name__ == "__main__":
    main()


Fixed submission:
from sys import stdin


def main():
    A, B, K = [int(x) for x in stdin.readline().rstrip().split()]
    a = [x for x, y in zip(range(A, B + 1), range(K))]
    b = [x for x, y in zip(range(B, A - 1, -1), range(K))]
    c = sorted(list(set(a + b)))
    for x in c:
        print(x)


if __name__ == "__main__":
    main()
Problem p03386 (Python)

Buggy submission (status: Runtime Error):
# https://atcoder.jp/contests/abc093/tasks/abc093_b
a, b, k = [int(x) for x in input().split()]
r = list(range(a, b + 1))
for v in sorted(set(r[:k] + r[-k:])):
    print(v)


Fixed submission:
# https://atcoder.jp/contests/abc093/tasks/abc093_b
a, b, k = [int(x) for x in input().split()]
s = list(range(a, b + 1)[:k])
t = list(range(a, b + 1)[-k:])
for v in sorted(set(s + t)):
    print(v)
Problem p03386 (Python)

Buggy submission (status: Time Limit Exceeded):
A, B, K = map(int, input().split())
li = [i for i in range(A, B + 1)]
for i, l in enumerate(li):
    if i + 1 <= K or len(li) - i <= K:
        print(l)


Fixed submission:
A, B, K = map(int, input().split())
for i in range(A, A + K):
    if i == B + 1:
        break
    print(i)
for j in range(B - K + 1, B + 1):
    if j <= i:
        continue
    print(j)
Problem p03386 (Python)

Buggy submission (status: Runtime Error):
def resolve():
    a, b, k = list(map(int, input().split()))
    small = list(range(a, b))[:k]
    large = list(range(a, b + 1))[::-1][:k]
    ans = sorted(set(small + large))
    for i in ans:
        print(i)


if __name__ == "__main__":
    resolve()


Fixed submission:
def resolve():
    a, b, k = list(map(int, input().split()))
    s = set()
    for i in range(a, min(a + k, b + 1)):
        s.add(i)
    for i in range(max(a, b - k + 1), b + 1):
        s.add(i)
    for i in sorted(s):
        print(i)


if __name__ == "__main__":
    resolve()
Problem p03386 (Python)

Buggy submission (status: Time Limit Exceeded):
a, b, k = map(int, input().split())
for i in range(a, b + 1):
    if i <= a + (k - 1):
        print(i)
    elif i >= b - (k - 1):
        print(i)


Fixed submission:
a, b, k = map(int, input().split())
for i in range(a, min(b, a + k - 1) + 1):
    print(i)
for i in range(max(b - k + 1, a + k), b + 1):
    print(i)
Problem p03386 (Python)

Buggy submission (status: Time Limit Exceeded):
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem B

if __name__ == "__main__":
    a, b, k = list(map(int, input().split()))

    if (b - a + 1) <= 2 * k:
        for i in range(a, b + 1):
            print(i)
    else:
        for j in range(a, b + 1):
            if (j <= a + k - 1) or (j > b - k):
                print(j)


Fixed submission:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem B

if __name__ == "__main__":
    a, b, k = list(map(int, input().split()))

    if (b - a + 1) <= 2 * k:
        for i in range(a, b + 1):
            print(i)
    else:
        for j in range(a, a + k):
            print(j)
        for j in range(b - k + 1, b + 1):
            print(j)
Problem p03386 (Python)

Buggy submission (status: Time Limit Exceeded):
a, b, k = map(int, input().split())
for i in range(a, b + 1):
    if i - a + 1 <= k or b - i + 1 <= k:
        print(i)


Fixed submission:
a, b, k = map(int, input().split())
ans = []
for i in range(a, min(a + k, b + 1)):
    ans.append(i)
for i in range(b, max(b - k, a - 1), -1):
    if i not in ans:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)
Problem p03386 (Python)

Buggy submission (status: Runtime Error):
a, b, k = [int(x) for x in input().split()]
lst = list(range(a, b + 1))
res = []
res.extend(lst[:k])
res.extend(lst[-k:])
res = sorted(set(res))
for i in res:
    print(i)


Fixed submission:
a, b, k = [int(x) for x in input().split()]
r = range(a, b + 1)
for i in sorted(set(r[:k]) | set(r[-k:])):
    print(i)