Problem p02697 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/

#ifdef LOCAL
#define dbg(x) cout << #x << " : " << x << endl;
#else
#define dbg(x)
#endif

#define int long long
#define fi(a, b) for (int i = a; i < b; i++)
#define fj(a, b) for (int j = a; j < b; j++)
#define fk(a, b) for (int k = a; k < b; k++)
#define fi1(a, b) for (int i = a - 1; i >= b; i--)
#define fj1(a, b) for (int j = a - 1; j >= b; j--)
#define fk1(a, b) for (int k = a - 1; k >= b; k--)
#define fx(x, a) for (auto &x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template <typename T1, typename T2> inline void mine(T1 &x, T2 y) {
  if (x > y)
    x = y;
}
template <typename T1, typename T2> inline void maxe(T1 &x, T2 y) {
  if (x < y)
    x = y;
}

ostream &operator<<(ostream &a, const vector<int> &b) {
  for (auto k : b)
    cout << k << ' ';
  return a;
}

typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;

const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int n, m;
  cin >> n >> m;
  if (n % 2) {
    fi(0, m) cout << i + 1 << ' ' << n - i << '\\n';
  } else {
    int cnt = 0;
    int a = 1;
    int b = n;
    while (cnt < m) {
      if (b - a == n / 2)
        --b;
      cout << a << ' ' << b << '\\n';
      if (b - a == n / 2 + 1)
        --b;
      ++a;
      --b;
      ++cnt;
    }
  }
}

Error: -6
e03b3d20-d796-4e01-8266-d67872e40fde.out: /home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02697/C++/s221831118.cpp:102: int32_t main(): Assertion `n == 1' failed.


Fixed submission:

#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/

#ifdef LOCAL
#define dbg(x) cout << #x << " : " << x << endl;
#else
#define dbg(x)
#endif

#define int long long
#define fi(a, b) for (int i = a; i < b; i++)
#define fj(a, b) for (int j = a; j < b; j++)
#define fk(a, b) for (int k = a; k < b; k++)
#define fi1(a, b) for (int i = a - 1; i >= b; i--)
#define fj1(a, b) for (int j = a - 1; j >= b; j--)
#define fk1(a, b) for (int k = a - 1; k >= b; k--)
#define fx(x, a) for (auto &x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template <typename T1, typename T2> inline void mine(T1 &x, T2 y) {
  if (x > y)
    x = y;
}
template <typename T1, typename T2> inline void maxe(T1 &x, T2 y) {
  if (x < y)
    x = y;
}

ostream &operator<<(ostream &a, const vector<int> &b) {
  for (auto k : b)
    cout << k << ' ';
  return a;
}

typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;

const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int n, m;
  cin >> n >> m;
  if (n % 2) {
    fj(0, m) cout << j + 1 << ' ' << n - j << '\\n';
  } else {
    assert(n == 1);
    int a = 0;
    int b = n - 1;
    int cnt = 0;
    while (cnt < m) {
      int delta = (b - a);
      while ((b + delta) % n == a) {
        --b;
        ++a;
      }
      cout << a + 1 << ' ' << b + 1 << '\\n';
      --b;
      ++a;
      ++cnt;
    }
  }
}