alexjercan/bugnet huggingface dataset:
Problem p02697 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                                                       \\
  cerr << __LINE__ << ": " << #x << " = {";                                    \\
  for (long long hoge = 0; (hoge) < (n); ++(hoge))                             \\
    cerr << ((hoge) ? "," : "") << x[hoge];                                    \\
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  if (N & 1) {
    for (int i = 1; i <= M; i++) {
      cout << i << " " << N + 1 - i << endl;
    }
  } else {
    for (int i = 1, len = M & 1 ? M : M - 1; len >= 1; i++, len -= 2) {
      cout << i << " " << i + len << endl;
    }
    for (int i = N - 1, len = M & 1 ? M - 1 : M; len >= 2; i--, len -= 2) {
      cout << i << " " << i - len << endl;
    }
  }
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                                                       \\
  cerr << __LINE__ << ": " << #x << " = {";                                    \\
  for (long long hoge = 0; (hoge) < (n); ++(hoge))                             \\
    cerr << ((hoge) ? "," : "") << x[hoge];                                    \\
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  bool used[N];
  fill(used, used + N, false);
  int cur = 0;
  for (int i = 1; i <= M; i++) {
    while (cur < N && used[cur])
      cur++;
    used[cur] = true;
    used[cur + i] = true;
    cout << cur + 1 << " " << cur + i + 1 << endl;
  }
  return 0;
}
Problem p02697 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ll n, m;
  std::cin >> n >> m;
  if (m % 2 == 0) {
    for (int i = 0; i < m / 2; i++) {
      std::cout << i + 1 << " " << m - i << std::endl;
    }
    for (int i = 0; i < m / 2; i++) {
      std::cout << m + i + 1 << " " << m + m + 1 - i << std::endl;
    }
  } else {
    for (int i = 0; i < m / 2; i++) {
      std::cout << i + 1 << " " << m - i << std::endl;
    }
    for (int i = 0; i < m / 2 + 1; i++) {
      std::cout << m + i + 1 << " " << m + m + 1 - i << std::endl;
    }
  }
}


Error: TLE

Fixed submission:

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

int main() {
  ll n, m;
  std::cin >> n >> m;
  if (n % 2 == 0) {
    vector<bool> used(n, false);
    ll now = 1;
    for (int i = 1; i <= m; i++) {
      while (used[now % n] || used[(now + i) % n]) {
        now++;
      }
      std::cout << now << " " << now + i << std::endl;
      used[now % n] = true;
      used[(now + i) % n] = true;
    }
    return 0;
  }
  for (int i = 0; i < m; i++) {
    std::cout << i + 1 << " " << n - i << std::endl;
  }
}
Problem p02697 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD = 1e9 + 7;
const long double Pi = acos(-1);
using P = pair<ll, ll>;
int main() {
  ll N, M;
  cin >> N >> M;
  for (ll i = 0; i < M; i++) {
    if (N % 2 == 1) {
      cout << i + 1 << " " << N - i << endl;
    }
  }
  if (N % 2 == 0) {
    for (ll i = 0; i < (M / 2 + M % 2); ++i) {
      cout << i + 1 << " " << N / 2 - i << endl;
    }
    for (ll i = 0; i < M / 2; i++) {
      cout << N / 2 + i + 1 << " " << N - i - 1 << endl;
    }
  }
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD = 1e9 + 7;
const long double Pi = acos(-1);
using P = pair<ll, ll>;
ll N;
vector<ll> vec;
ll binary_search(ll key) {
  ll left = 0, right = vec.size() - 1;
  while (right >= left) {
    ll mid = left + (right - left) / 2;
    if (vec.at(mid) == key)
      return mid;
    else if (vec.at(mid) > key)
      right = mid - 1;
    else if (vec.at(mid) < key)
      left = mid + 1;
  }
  return -1;
}
int main() {
  ll M;
  cin >> N >> M;
  vec.resize(N);
  for (ll i = 0; i < M; i++) {
    if (N % 2 == 1) {
      cout << i + 1 << " " << N - i << endl;
    }
  }
  for (ll i = 1; i <= N; i++) {
    vec.at(i - 1) = i;
  }
  if (N % 2 == 0) {
    for (ll i = 0; i < M; i++) {
      cout << vec.at(0) << " ";
      ll a = binary_search(vec.at(0) + i + 1);
      cout << vec.at(a) << " " << endl;
      vec.erase(vec.begin());
      vec.erase(vec.begin() + a - 1);
    }
  }
}
Problem p02697 (C++) — buggy submission, verdict: Runtime Error

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln = '\\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<pii> vs;
  set<int> st;
  if (n % 2) {
    for (int a = 1, b = n - 1; b - a > 0; a++, b--) {
      vs.emplace_back(a, b);
    }
  } else {
    bool fg = false;
    for (int a = 1, b = n - 1; b - a > 0; a++, b--) {
      if (!fg && b - a <= n / 2)
        b--, fg = true;
      vs.emplace_back(a, b);
    }
  }

  rep(i, m) { cout << vs[i].first << " " << vs[i].second << ln; }
}


Error: WA

Fixed submission:

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln = '\\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<pii> vs;
  set<int> st;
  if (n % 2) {
    for (int a = 1, b = n - 1; b > a; a++, b--) {
      vs.emplace_back(pii(a, b));
    }
  } else {
    bool fg = false;
    for (int a = 1, b = n - 1; b > a; a++, b--) {
      if (!fg && b - 1 <= n / 2)
        b--, fg = true;
      vs.emplace_back(pii(a, b));
      a++;
      b--;
    }
  }

  rep(i, m) { cout << vs[i].first << " " << vs[i].second << ln; }
}
Problem p02697 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;

void solve() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> ans(m);
  if (n % 2 == 1) {
    int j = 2;
    for (int i = 0; i < m; i++) {
      ans[i].first = j;
      ans[i].second = n - j + 2;
      j++;
    }
  } else {
    int j, t = 0, x;
    if (n % 4 == 0) {
      j = 2;
      x = 2;
    } else {
      j = 1;
      x = 1;
    }
    for (int i = 0; i < m; i++) {
      if (j == n / 4 + 1)
        t++;
      ans[i].first = j;
      ans[i].second = n - j + x - t;
      j++;
    }
  }
  for (int i = 0; i < m; i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return;
}

int main() {
  solve();
  return 0;
}


Error: WA

Fixed submission:

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;

void solve() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> ans(m);
  int j = 0;
  vector<bool> ok(n + 1, true);
  for (int i = 1; i <= n; i++) {
    if (ok[i] == true && ok[i + j + 1] == true) {
      ans[j].first = i;
      ans[j].second = i + j + 1;
      j++;
      ok[i] = false;
      ok[i + j + 1] = false;
      if (j >= m)
        break;
    }
  }
  /*vector<set<char> > st(n + 1);
  vector<int> a(n);

  for(int i = 0; i < n; i++){
    cout << i << " : ";
    for(int j = 1; j <= n; j++){
      int c = (j + i) % n;
      if(c == 0) c = n;
      a[j] = c;
      cout << a[j] << " ";
    }
    cout << endl;
    for(int j = 1; j <= n; j++){
      int c = (j + i) % n;
      if(c == 0) c = n;
      for(int k = 0; k < m; k++){
        if(c == ans[k].first){
          for(int l = 1; l <= n; l++){
            if(a[l] == ans[k].second){
              st[j].insert(l + 'A' - 1);
              st[l].insert(j + 'A' - 1);
              break;
            }
          }
        }
      }
    }
  }
  for(int i = 1; i <= n; i++){
    cout << (char)('A' + i - 1) << " : ";
    for(auto it = st[i].begin(); it != st[i].end(); it++){
      cout << *it << " ";
    }
    cout << endl;
  }*/
  for (int i = 0; i < m; i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return;
}

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

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 10;

void solve() {
  int n, m;
  cin >> n >> m;
  int sm = (n - 1) / 2;
  for (int l = 1, r = sm + 1; m && l < r; l++, r--) {
    cout << l << " " << r << endl;
    m--;
  }
  if (n % 2 == 1) {
    for (int l = sm + 2, r = n; m && l < r; l++, r--) {
      cout << l << " " << r << endl;
      m--;
    }
  } else {
    for (int l = sm + 2, r = n - 1; m && l < r; l++, r--) {
      cout << l << " " << r << endl;
      m--;
    }
  }
}

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  solve();
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 10;
int used[N];

void solve() {
  int n, m;
  cin >> n >> m;
  cout << "1 2\\n";
  m--;
  used[1] = used[2] = 1;
  for (int start = 3, delta = 2, cnt = 0; cnt < m; delta++) {
    while (true) {
      if (start > n)
        start -= n;
      int finish = start + delta;
      if (finish > n)
        finish -= n;
      if (!used[start] && !used[finish]) {
        cout << start << " " << finish << endl;
        used[start] = used[finish] = 1;
        break;
      } else {
        start++;
      }
    }
    cnt++;
  }
}

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  solve();
}
Problem p02697 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, pair<int, int>> PII;
static const int IINF = INT32_MAX;
static const ll LINF = INT64_MAX;
static const ll mod = 1e9 + 7;
static const int dx[4] = {1, -1, 0, 0};
static const int dy[4] = {0, 0, 1, -1};

int N, M;

bool f[200005];
bool usem[200005];

int main() {
  cin >> N >> M;
  if (N % 2 == 1) {
    for (int i = 1; i <= M; ++i) {
      cout << i << " " << N - i + 1 << endl;
    }
  } else {
    for (int i = 1; i <= M; ++i) {
      if (N - 2 * i + 1 > 2 * i - 1)
        cout << i << " " << N - i + 1 << endl;
      else
        cout << i << " " << N - i << endl;
    }
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, pair<int, int>> PII;
static const int IINF = INT32_MAX;
static const ll LINF = INT64_MAX;
static const ll mod = 1e9 + 7;
static const int dx[4] = {1, -1, 0, 0};
static const int dy[4] = {0, 0, 1, -1};

int N, M;

bool f[200005];
bool usem[200005];

int main() {
  cin >> N >> M;
  if (N % 2 == 1) {
    for (int i = 1; i <= M; ++i) {
      cout << i << " " << N - i + 1 << endl;
    }
  } else {
    int cnt = 0;
    int t = N - 1;
    int i = 1;
    while (cnt < M) {
      i %= N;
      if (i == 0)
        i = N;
      int a = (i + t) % N;
      int b = (i + N - t) % N;
      if (a == 0)
        a = N;
      if (b == 0)
        b = N;
      if ((f[i] || f[a]) && (f[i] || f[b])) {
        i++;
        continue;
      }
      if (f[i] || f[a]) {
        cout << i << " " << b << endl;
        f[i] = f[b] = true;
      } else {
        cout << i << " " << a << endl;
        f[i] = f[a] = true;
      }
      i++;
      t--;
      cnt++;
    }
  }
}
Problem p02697 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define repf(i, m, n) for (int i = (m); i < (n); i++)
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 (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> b(n, false);
  int pos = 1, mx = 1;
  for (int i = m; i >= 1; i -= 2) {
    cout << pos << " " << pos + i << endl;
    pos++;
    chmax(mx, pos + i);
  }
  pos = mx;
  for (int i = m - 1; i >= 1; i -= 2) {
    cout << pos << " " << pos + i << endl;
    pos++;
  }
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define repf(i, m, n) for (int i = (m); i < (n); i++)
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 (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> b(n, false);
  int pos = 0, mn = 0;
  repf(i, 1, m + 1) {
    pos = mn;
    if (b[pos + i]) {
      pos++;
    }
    cout << pos + 1 << " " << pos + i + 1 << endl;
    b[pos] = true;
    b[pos + i] = true;
    while (b[mn]) {
      mn++;
    }
  }
  return 0;
}
Problem p02697 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <chrono>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <random>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int, int>
#define mp make_pair
#define valid(x, y, h, w) (0 <= x && x < h && 0 <= y && y < w)
// #define int ll
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int ndx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int ndy[8] = {1, 0, -1, 0, 1, -1, -1, 1};
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n + 1);

  int u1 = 1 + m;
  int d1 = 1;
  int u2 = n;
  int d2 = n - m + 1;

  int c = 0;

  while (u1 > d1 && c < m) {
    cout << d1 << " " << u1 << endl;
    d1++;
    u1--;
    c++;
  }
  while (u2 > d2 && c < m) {
    cout << d2 << " " << u2 << endl;
    d2++;
    u2--;
    c++;
  }
}


Error: WA

Fixed submission:

#include <algorithm>
#include <chrono>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <random>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int, int>
#define mp make_pair
#define valid(x, y, h, w) (0 <= x && x < h && 0 <= y && y < w)
// #define int ll
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int ndx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int ndy[8] = {1, 0, -1, 0, 1, -1, -1, 1};
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n + 1);

  int index = 1;

  FOR(k, 1, m + 1) {
    while (v[index] == 1) {
      index++;
    }
    int a = index;
    int b = index + k;

    v[a] = 1;
    v[b] = 1;
    cout << a << " " << b << endl;
  }
}
Problem p02697 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
bool vis[101010];
int n, m;
int main() {
  cin >> n >> m;
  if (n % 2 == 1) {
    for (int i = 1; i <= m; i++) {
      cout << i << ' ' << n - i + 1 << endl;
    }
  } else {
    for (int i = 1; i <= n / 4; i++) {
      if (i == m + 1) {
        break;
      }
      cout << i << ' ' << n - i + 1 << endl;
    }
    for (int i = n / 4 + 1; i <= m; i++) {
      cout << i << ' ' << n - i << endl;
    }
  }
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
bool vis[101010];
int n, m;
int main() {
  cin >> n >> m;
  int p = 1;
  for (int i = 1; i <= m; i++) {
    while (vis[p]) {
      p++;
    }
    vis[p] = true;
    int ll = p + 1;
    while (vis[ll] || ll - p == p || ll - p == n - ll + 1) {
      ll++;
    }
    vis[ll] = true;
    cout << p << ' ' << ll << endl;
  }
  return 0;
}
Problem p02697 (C++) — buggy submission, verdict: Runtime Error

// g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {
  ll N, M;
  cin >> N >> M;
  int a = N;
  int b = 1 + M;
  int flag = 1;
  for (int i = 1; i <= M; i++) {
    if (flag % 2 == 1) {
      cout << b << " " << b + i << endl;
      b--;
      flag--;
    } else {
      cout << a << " " << a - (N - i) << endl;
      a--;
      flag++;
    }
  }
}


Error: WA

Fixed submission:

// g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {
  ll N, M;
  cin >> N >> M;
  ll a, b;
  a = 3;
  b = 5;
  if (M >= 1)
    cout << 1 << " " << 2 << endl;
  if (M >= 2)
    cout << 3 << " " << 5 << endl;
  vector<int> flag(200010, 1);
  flag[1] = 0;
  flag[2] = 0;
  flag[3] = 0;
  flag[5] = 0;
  if (M >= 3) {
    int i = 3;
    while (i <= M) {
      a++;
      if (flag[a] == 1 && flag[a + i] == 1) {
        b = a + i;
        cout << a << " " << b << endl;
        flag[a] = 0;
        flag[b] = 0;
        i++;
      }
    }
  }
}
Problem p02697 (C++) — buggy submission, verdict: Runtime Error

/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int cnt[2];
int maxi[2];
int main() {
  int n, i, j, k, x, y, ans, curr, temp, m;
  int tc;
  cin >> n >> m;
  vector<int> va;
  cnt[1]++;
  maxi[1] = 1;
  temp = m;
  m--;
  for (i = 2; i <= temp; i++) {
    cnt[i % 2]++;
    maxi[i % 2] = max(maxi[i % 2], i);
    m--;
  }
  vector<pair<int, int>> chaeng;
  int now = 1;
  i = 0;
  int l, r;
  l = now;
  r = now + maxi[i % 2];
  while (cnt[i % 2] > 0) {
    chaeng.push_back({l, r});
    l++;
    r--;
    cnt[i % 2]--;
  }
  now += maxi[i % 2] + 1;
  i++;
  l = now;
  r = now + maxi[i % 2];
  while (cnt[i % 2] > 0) {
    chaeng.push_back({l, r});
    l++;
    r--;
    cnt[i % 2]--;
  }
  for (auto x : chaeng)
    cout << x.first << " " << x.second << endl;
  return 0;
}


Error: WA

Fixed submission:

/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
  int n, i, j, k, x, y, ans, curr, temp, m;
  int tc;
  cin >> n >> m;
  vector<int> vi;
  vi.push_back(1);
  temp = m;
  m--;
  for (i = 2; i <= n; i++) {
    if (!m)
      break;
    if (n % i == 0)
      continue;
    vi.push_back(i);
    m--;
  }
  reverse(vi.begin(), vi.end());
  bool done[n + 5];
  memset(done, 0, sizeof(done));
  vector<pair<int, int>> chaeng;
  int now = 0;
  for (i = 1; i <= n; i++) {
    if (!done[i] && !done[i + vi[now]]) {
      done[i] = done[i + vi[now]] = 1;
      chaeng.push_back({i, i + vi[now]});
      now++;
    }
    if (now == temp)
      break;
  }
  for (auto x : chaeng)
    cout << x.first << " " << x.second << endl;
  return 0;
}