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

#include <iostream>
#include <stdio.h>
// #include <bits/stdc++.h>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <float.h>
#include <iomanip>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

#define INF 1e10
#define rep(i, n) for (int i = 0; (i) < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); (i) <= (int)(b); i++)
#define VEC(type, c, n)                                                        \\
  std::vector<type> c(n);                                                      \\
  for (auto &i : c)                                                            \\
    std::cin >> i;
#define vec(type, n) vector<type>(n)
#define vvec(m, n) vector<vector<int>>(int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

const ll MOD = INF + 7;

int main() {
  int n, m;
  cin >> n >> m;
  int d = 0;
  rep(i, m) {
    if (n % 2 == 0) {
      int j = n - i;
      if (2 * (j - i - 1) == n) {
        d = 1;
        j -= d;
      }
      if (m / 2 < i)
        j = j - 1;
      // cout << i + 1 << " " << j << "   " << j - i - 1 << " " << n - (j - i -
      // 1) << endl;
      cout << i + 1 << " " << j << endl;
    } else
      cout << i + 1 << " " << n - i - 1 << endl;
  }
}


Error: WA

Fixed submission:

#include <iostream>
#include <stdio.h>
// #include <bits/stdc++.h>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <float.h>
#include <iomanip>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

#define INF 1e10
#define rep(i, n) for (int i = 0; (i) < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); (i) <= (int)(b); i++)
#define VEC(type, c, n)                                                        \\
  std::vector<type> c(n);                                                      \\
  for (auto &i : c)                                                            \\
    std::cin >> i;
#define vec(type, n) vector<type>(n)
#define vvec(m, n) vector<vector<int>>(int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

const ll MOD = INF + 7;

int main() {
  int n, m;
  cin >> n >> m;
  int d = 1;
  vector<bool> seen(n, false);
  int now = 0;
  if (n % 2 == 1) {
    rep(i, m) { cout << i + 1 << " " << n - i - 1 << endl; }
  } else {
    rep(i, m) {
      REP(j, now, n - 1) {
        if (seen[j])
          continue;
        now = j;
        seen[now] = true;
        seen[now + i + 1] = true;
        cout << now + 1 << " " << now + i + 2 << endl;
        break;
      }
    }
  }
}
Problem p02697 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

int n, m;

int get_dist(int i, int j) { return min(abs(i - j), n - abs(i - j)); }

void solve() {
  cin >> n >> m;
  // assert(n <= 100000);
  int ptr = 0;
  int maxd = n / 2 - 1;
  set<int> deltas;
  int cnt = 0;
  set<int> taken;
  while (maxd > 0 && cnt < m) {
    cout << ptr + 1 << ' ' << ptr + maxd + 1 << "\\n";
    deltas.insert(maxd);
    deltas.insert(n - maxd);
    taken.insert(ptr);
    taken.insert(ptr + maxd);
    assert(ptr + maxd + 1 <= n);
    ++ptr;
    maxd -= 2;
    ++cnt;
  }
  maxd = n / 2;
  ptr = n / 2;
  if (ptr + maxd > n - 1)
    maxd -= 2;
  while (maxd > 0 && cnt < m) {
    cout << ptr + 1 << ' ' << ptr + maxd + 1 << "\\n";
    assert(ptr + maxd + 1 <= n);
    deltas.insert(get_dist(ptr, ptr + maxd));
    taken.insert(ptr);
    deltas.insert(maxd);
    deltas.insert(n - maxd);
    taken.insert(ptr + maxd);
    maxd -= 2;
    ++ptr;
    ++cnt;
  }
  // assert(2 * m == int(deltas.size()));
  assert(2 * m == int(taken.size()));
}

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

Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int n, m;

int get_dist(int i, int j) { return min(abs(i - j), n - abs(i - j)); }

void solve() {
  cin >> n >> m;
  assert(n <= 100000);
  int ptr = 0;
  int maxd = n / 2;
  set<int> deltas;
  int cnt = 0;
  while (maxd > 0 && cnt < m) {
    cout << ptr + 1 << ' ' << ptr + maxd + 1 << "\\n";
    deltas.insert(get_dist(ptr + 1, ptr + maxd + 1));
    ++ptr;
    maxd -= 2;
    ++cnt;
  }
  maxd = n / 2 - 1;
  ptr = n / 2 + 1;
  while (maxd > 0 && cnt < m) {
    cout << ptr + 1 << ' ' << ptr + maxd + 1 << "\\n";
    deltas.insert(get_dist(ptr, ptr + maxd));
    maxd -= 2;
    ++ptr;
    ++cnt;
  }
}

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

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1 << 30) - 1)
#define LINF (1LL << 60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
  int n, m;
  cin >> n >> m;
  ll p = (n - 1) / 2;

  if (n % 2 != 0) {
    rep(i, m) { cout << p - i << " " << p + i + 1 << endl; }
    return 0;
  }

  int h = n / 2;

  rep(i, (m + 1) / 2) { cout << h / 2 - i << " " << h / 2 + i + 1 << endl; }

  rep(i, m - (m + 1) / 2) {
    cout << h + h / 2 - i - 1 << " " << h + h / 2 + i + 1 << endl;
  }

  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1 << 30) - 1)
#define LINF (1LL << 60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
  int n, m;
  cin >> n >> m;
  ll p = (n - 1) / 2;

  if (n % 2 != 0) {
    rep(i, m) { cout << p - i << " " << p + i + 1 << endl; }
  } else {
    bool done[200010];
    memset(done, 0, sizeof(done));
    int now = 0;
    int i = 0;
    while (i < m) {
      int diff = i + 1;
      if (done[now] || done[(now + diff) % n]) {
        now++;
        continue;
      } else
        cout << now + 1 << " " << (now + diff) % n + 1 << endl;
      done[now] = true;
      done[now + diff] = true;
      i++;
    }
  }

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

#include <cassert>
#include <iostream>
#include <vector>

using namespace std;

const int kMax = 200000;
bool used[kMax];

int main() {
  int N, M;
  cin >> N >> M;

  vector<pair<int, int>> even;
  vector<pair<int, int>> odd;
  for (int i = 0; i < M; ++i) {
    if (i % 2 == 0) {
      if (even.empty()) {
        even.push_back(make_pair(0, 1));
      } else {
        pair<int, int> last = even.back();
        even.push_back(make_pair(last.first - 1, last.second + 1));
      }
    } else {
      if (odd.empty()) {
        odd.push_back(make_pair(0, 2));
      } else {
        pair<int, int> last = odd.back();
        odd.push_back(make_pair(last.first - 1, last.second + 1));
      }
    }
  }
  for (int i = 0; i < M; ++i) {
    if (i % 2 == 0) {
      pair<int, int> p = even[i / 2];
      int even_min = even.back().first;
      cout << (p.first - even_min + 1) << " " << (p.second - even_min + 1)
           << endl;
    } else {
      pair<int, int> p = odd[i / 2];
      int odd_min = odd.back().first;
      int even_max = even.back().second - even.back().first;
      int adjust = -odd_min + even_max + 1;
      cout << (p.first + adjust + 1) << " " << (p.second + adjust + 1) << endl;
    }
  }
}

Error: WA

Fixed submission:

#include <cassert>
#include <iostream>
#include <vector>

using namespace std;

const int kMax = 200000;
bool used[kMax];

int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; ++i) {
    for (int j = 0; j < N; ++j) {
      int k = (j + i + 1);
      assert(k < N);
      if (!used[j] && !used[k]) {
        cout << (j + 1) << " " << (k + 1) << endl;
        used[j] = true;
        used[k] = true;
        break;
      }
    }
  }
}
Problem p02697 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> ans;
  if (N % 2) {
    for (int l = 1, r = N - 1; l < r; l++, r--) {
      ans.emplace_back(l, r);
    }
  } else {
    bool flg = false;
    for (int l = 1, r = N - 1; l < r; l++, r--) {
      if (!flg && r - l <= N / 2) {
        r--;
        flg = true;
      }
      ans.emplace_back(l, r);
    }
  }
  for (int i = 0; i < M; i++) {
    cout << ans[i].first << ' ' << ans[i].second << endl;
  }
}

Error: WA

Fixed submission:

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

int main() {
  int64_t N, M;
  cin >> N >> M;
  vector<pair<int, int>> ans;
  priority_queue<int, vector<int>, greater<int>> que;
  for (int i = 1; i < N; i++) {
    que.push(i);
  }
  vector<bool> used(N, false), usedd(N, false);
  for (int i = 0; i < N; i++) {
    if (used[i])
      continue;
    used[i] = true;
    queue<int> tmp;
    while (true) {
      if (used[i + que.top()]) {
        tmp.push(que.top());
        que.pop();
      } else {
        used[i + que.top()] = true;
        ans.emplace_back(i, i + que.top());
        que.pop();
        break;
      }
    }
    while (tmp.size()) {
      que.push(tmp.front());
      tmp.pop();
    }
  }
  for (int i = 0; i < M; i++) {
    cout << ans.at(i).first + 1 << ' ' << ans.at(i).second + 1 << endl;
  }
}
Problem p02697 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define rep(i, n) REP(i, 0, n)
#define rep1(i, n) REP(i, 1, n)
#define repe(i, n) for (auto &&i : n)
#define all(v) (v).begin(), (v).end()
#define decimal fixed << setprecision(20)
#define fastcin()                                                              \\
  cin.tie(0);                                                                  \\
  ios::sync_with_stdio(false)
// #define int long long
using LL = long long;
using namespace std;
using Graph = vector<vector<int>>;
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;
}
const int INF = 1e9;
const LL LLINF = 1e16;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

signed main() {
  fastcin();
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> ans;
  vector<int> d(n, 0);
  if (n % 2 == 1) {
    rep(i, m) ans.emplace_back(i, 2 * m - 1 - i);
  } else {
    int rem = n - 2 * m - 1;
    int l = m - 1, r = m;
    rep(i, m) {
      ans.emplace_back(l, r);
      if (i + 1 == (m + 1) / 2) {
        r += rem;
      }
      l--;
      r++;
    }
  }
  repe(i, ans) { cout << i.first + 1 << " " << i.second + 1 << endl; }
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define rep(i, n) REP(i, 0, n)
#define rep1(i, n) REP(i, 1, n)
#define repe(i, n) for (auto &&i : n)
#define all(v) (v).begin(), (v).end()
#define decimal fixed << setprecision(20)
#define fastcin()                                                              \\
  cin.tie(0);                                                                  \\
  ios::sync_with_stdio(false)
// #define int long long
using LL = long long;
using namespace std;
using Graph = vector<vector<int>>;
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;
}
const int INF = 1e9;
const LL LLINF = 1e16;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

signed main() {
  fastcin();
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> ans;
  vector<int> d(n, 0);
  if (n % 2 == 1) {
    return 1;
    rep(i, m) ans.emplace_back(i, 2 * m - 1 - i);
  } else {
    int rem = n - 2 * m - 1;
    int l = m - 1, r = m;
    rep(i, m) {
      ans.emplace_back(l, r);
      if (i == m / 2) {
        r += rem;
      }
      l--;
      r++;
    }
  }
  repe(i, ans) { cout << i.first + 1 << " " << i.second + 1 << endl; }
}
Problem p02697 (C++) — buggy submission, verdict: 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()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr auto INF = INT_MAX / 2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

  int n, m;
  cin >> n >> m;
  vi a(m), b(m);
  ll aa = m / 2, bb = m - aa;
  rep(i, aa) {
    a[i] = 1 + i;
    b[i] = (n - 1) / 2 - i;
  }
  rep(i, bb) {
    a[aa + i] = (n + 2) / 2 + i;
    b[aa + i] = n - i;
  }
  rep(i, m) { cout << a[i] << " " << b[i] << endl; }
}

Error: WA

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()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr auto INF = INT_MAX / 2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

  ll n, m;
  cin >> n >> m;

  vi a(m), b(m);

  if (!(n & 1)) {

    rep(i, m) {
      a[i] = 1 + i;
      b[i] = n - i;
    }

    rep(i, m) { cout << a[i] << " " << b[i] << endl; }
  } else {

    int aa = m / 2, bb = m - bb;

    rep(i, aa) {
      a[i] = 1 + i;
      b[i] = (n - 1) / 2 - i;
    }
    rep(i, bb) {
      a[aa + i] = (n + 1) / 2 + i;
      b[aa + i] = n - i;
    }

    rep(i, m) { cout << a[i] << " " << b[i] << endl; }
  }
}
Problem p02697 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll

template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) {
  if (a > b)
    a = b;
}
template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) {
  if (a < b)
    a = b;
}

#define REP(i, n) for (int i = 0; i < n; ++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#define DBG(fmt, ...)
#endif

const ll LLINF = (1LL << 60);
const int INF = (1LL << 30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

signed main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;

  if (N % 2 != 0 || N == 4) {
    // 真ん中から割って割り当てる
    int cur1 = N / 2;
    int cur2 = cur1 + 1;
    REP(i, M) {
      printf("%lld %lld\\n", cur1, cur2);
      cur1--;
      cur2++;
    }
  } else {
    // 空ける間隔で偶奇に分けて詰めていく
    // 偶数(奇数)間隔から
    int lb = 1;
    int rb = lb + M;
    while (lb < rb) {
      printf("%lld %lld\\n", lb, rb);
      lb++;
      rb--;
    }
    // 奇数(偶数)間隔
    lb = M + 2;
    rb = lb + M - 1;
    while (lb < rb) {
      printf("%lld %lld\\n", lb, rb);
      lb++;
      rb--;
    }
  }

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll

template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) {
  if (a > b)
    a = b;
}
template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) {
  if (a < b)
    a = b;
}

#define REP(i, n) for (int i = 0; i < n; ++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#define DBG(fmt, ...)
#endif

const ll LLINF = (1LL << 60);
const int INF = (1LL << 30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

signed main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;

  if (N % 2 != 0 || N == 4) {
    // 真ん中から割って割り当てる
    int cur1 = N / 2;
    int cur2 = cur1 + 1;
    REP(i, M) {
      printf("%lld %lld\\n", cur1, cur2);
      cur1--;
      cur2++;
    }
  } else {
    assert(false);
    // 末尾を 1 つ飛ばしで開ける
    int cur1 = 1;
    int cur2 = N - 1;
    REP(i, M) {
      printf("%lld %lld\\n", cur1, cur2);
      cur1++;
      cur2--;
      if (i == 0) {
        cur2--;
      }
    }
  }

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

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<P> ans;
  if (n % 2) {
    for (int l = 1, r = n - 1; l < r; l++, r--) {
      ans.emplace_back(l, r);
    }
  } else {
    bool flag = false;
    for (int l = 1, r = n - 1; l < r; l++, r--) {
      if (!flag && r - l <= n / 2) {
        --r;
        flag = true;
      }
      ans.emplace_back(l, r);
    }
  }

  rep(i, m) { printf("%d %d\\n", ans[i].first, ans[i].second); }
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<P> ans;
  if (n % 2) {
    for (int l = 1, r = n - 1; l < r; l++, r--) {
      ans.emplace_back(l, r);
    }
  } else {
    bool flag = false;
    for (int l = 1, r = n - 1; l < r; l++, r++) {
      if (!flag && r - l <= n / 2) {
        --r;
        flag = true;
      }
      ans.emplace_back(l, r);
    }
  }

  rep(i, m) { printf("%d %d\\n", ans[i].first, ans[i].second); }
  return 0;
}
Problem p02697 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

  vector<pair<int, int>> dat;

  int half = n / 2;
  if (half & 1)
    half--;

  int l = 1, r = m;
  while (l < r)
    dat.emplace_back(l++, r--);

  l = m + 1;
  r = 2 * m + 1;
  if ((r - l) & 1 == (m - 1) & 1)
    l++;
  while (l < r)
    dat.emplace_back(l++, r--);

  for (const auto &e : dat) {
    int a, b;
    tie(a, b) = e;
    cout << a << ' ' << b << '\\n';
  }

  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

  vector<pair<int, int>> dat;

  int half = n / 2;
  if (half & 1)
    half++;

  int l = 1, r = half;
  while (l < r)
    dat.emplace_back(l++, r--);

  l = half + 1;
  r = n;
  while ((n - l) % 2 == 1)
    l++;

  while (l < r)
    dat.emplace_back(l++, r--);

  int ans = 0;
  for (const auto &e : dat) {
    int a, b;
    tie(a, b) = e;
    if (abs(a - b) > m)
      continue;
    cout << a << ' ' << b << '\\n';
    if (++ans == m)
      break;
  }

  assert(ans == m);

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

#include <stdio.h>
int main() {
  int n, m, i, t, l, r;
  scanf("%d%d", &n, &m);
  if (n % 2 == 0)
    n--;
  t = (n - 1) / 2;
  if (t == 1)
    return 0 * printf("1 2\\n"); // 特判
  if (t & 1) {                  // t是奇数
    l = t / 2, r = l + 2;
    for (i = 1; i <= m; i++) {
      printf("%d %d\\n", l, r);
      l--, r++;
      if (l == 0)
        l = (t + n) / 2, r = l + 1;
    }
  } else { // t是偶数
    l = t / 2, r = l + 2;
    for (i = 1; i <= m; i++) {
      printf("%d %d\\n", l, r);
      l--, r++;
      if (l == 0)
        l = (t + 1 + n) / 2, r = l + 1;
    }
  }
  return 0;
}

Error: WA

Fixed submission:

#include <stdio.h>
#define maxn 200010
int vis[maxn];
int main() {
  int i, j, n, m, now;
  scanf("%d%d", &n, &m);
  if (n % 2 == 0)
    n--;
  now = 1;
  for (i = 1; i <= m; i++) {
    while (vis[now])
      now++;
    vis[now] = 1, vis[now + i] = 1, printf("%d %d\\n", now, now + i);
  }
}
Problem p02697 (C++) — buggy submission, verdict: Runtime Error

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed << setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(), x.end()
#define pii pair<long long, long long>
#define FAST                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);

int MOD = (1e9) + 7;
const int N = 1e6 + 5;

signed main() {
  FAST int tc = 1;
  // cin>>tc;
  for (int ti = 1; ti <= tc; ti++) {
    int n, m, ind = 1;
    cin >> n >> m;
    pii a[2] = {{1, m + 1}, {m + 2, (2 * m) + 1}};
    for (int i = 0; i < m; i++) {
      cout << a[i % 2].ff << " " << a[i % 2].ss << endl;
      a[i % 2].ff++;
      a[i % 2].ss--;
    }
  }
  return 0;
}


Error: WA

Fixed submission:

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed << setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(), x.end()
#define pii pair<long long, long long>
#define FAST                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);

int MOD = (1e9) + 7;
const int N = 1e6 + 5;

signed main() {
  FAST int tc = 1;
  // cin>>tc;
  for (int ti = 1; ti <= tc; ti++) {
    int n, m, ind = 1;
    cin >> n >> m;
    set<int> s;
    vector<int> v(m);
    for (int i = 1; i <= n; i++)
      s.insert(i);
    for (int i = 0; i < m; i += 2)
      v[i] = ind++;
    ind = m;
    for (int i = 1; i < m; i += 2)
      v[i] = ind--;
    for (int i = 0; i < m; i++) {
      auto mi = *s.begin();
      s.erase(s.begin());
      if (s.find(mi + v[i]) != s.end()) {
        s.erase(s.find(mi + v[i]));
        cout << mi << " " << mi + v[i] << endl;
      } else {
        auto ma = *s.rbegin();
        s.erase(s.find(ma));
        s.erase(s.find(ma - v[i]));
        cout << ma - v[i] << " " << ma << endl;
      }
    }
  }
  return 0;
}