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

//
#include <iostream>

using namespace std;

#define PB push_back
#define f first
#define s second

int ord[1000005];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int f, s;
  if (n % 4 == 1) {
    f = (n - 1) / 2;
    s = (n + 1) / 2;
  } else if (n % 4 == 3) {
    f = (n + 1) / 2;
    s = (n - 1) / 2;
  } else {
    f = n / 2 - 1;
    s = n / 2;
  }
  for (int i = 0; i < n; i++) {
    ord[i] = -1;
  }
  for (int i = 0; i < f; i++) {
    if (i >= f - 1 - i)
      break;
    ord[i] = f - 1 - i;
  }
  for (int i = f; i < f + s; i++) {
    if (i >= 2 * f + s - i - 1)
      break;
    ord[i] = 2 * f + s - i - 1;
  }

  //    for(int i=0; i<n; i++)
  //    {
  //        cout << i << " " << ord[i] << "\\n";
  //    }
  for (int i = 0; i < n; i++) {
    if (i < f && i >= f - 1 - i)
      continue;
    if (i < n && i >= 2 * f + s - i - 1)
      continue;
    cout << i + 1 << " " << ord[i] + 1;
    if (m > 1)
      cout << "\\n";
    m--;
    if (m == 0)
      break;
  }

  return 0;
}


Error: WA

Fixed submission:

//
#include <bits/stdc++.h>

using namespace std;

#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int MOD = 1000000007;
const int INF = 1000000007;

bool seen[100005];
int ord[100005];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int f, s;
  if (n % 4 == 1) {
    f = (n - 1) / 2;
    s = (n + 1) / 2;
  } else if (n % 4 == 3) {
    f = (n + 1) / 2;
    s = (n - 1) / 2;
  } else {
    f = n / 2 - 1;
    s = n / 2;
  }
  for (int i = 0; i < n; i++) {
    ord[i] = -1;
  }
  for (int i = 0; i < f; i++) {
    if (i != f - 1 - i)
      ord[i] = f - 1 - i;
  }
  for (int i = f; i < f + s; i++) {
    if (i != 2 * f + s - i - 1)
      ord[i] = 2 * f + s - i - 1;
  }

  //    for(int i=0; i<n; i++)
  //    {
  //        cout << i << " " << ord[i] << "\\n";
  //    }
  for (int i = 0; i < n; i++) {
    if (ord[i] == -1)
      continue;
    if (ord[i] < 0 || ord[i] >= n) {
      cout << "im wrong";
      return 0;
    }
    if (seen[ord[i]] || seen[i])
      continue;

    seen[i] = seen[ord[i]] = true;
    cout << i + 1 << " " << ord[i] + 1;
    if (m > 1)
      cout << "\\n";
    m--;
    if (m == 0)
      break;
  }

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < ((ll)(n)); i++)
#define reg(i, a, b) for (ll i = ((ll)(a)); i <= ((ll)(b)); i++)
#define irep(i, n) for (ll i = ((ll)(n)-1); i >= 0; i--)
#define ireg(i, a, b) for (ll i = ((ll)(b)); i >= ((ll)(a)); i--)
template <class T = int> using V = vector<T>;
template <class T = int> using VV = V<V<T>>;
template <class T = int> void print(vector<T> v) {
  for (auto a : v)
    cout << a << " ";
  cout << endl;
}

/*
 */

ll n, m;

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

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < ((ll)(n)); i++)
#define reg(i, a, b) for (ll i = ((ll)(a)); i <= ((ll)(b)); i++)
#define irep(i, n) for (ll i = ((ll)(n)-1); i >= 0; i--)
#define ireg(i, a, b) for (ll i = ((ll)(b)); i >= ((ll)(a)); i--)
template <class T = int> using V = vector<T>;
template <class T = int> using VV = V<V<T>>;
template <class T = int> void print(vector<T> v) {
  for (auto a : v)
    cout << a << " ";
  cout << endl;
}

/*
 */

ll n, m, a[200010] = {}, c = 1;

int main(void) {
  cin >> n >> m;
  reg(i, 1, n) {
    if (a[i] == 0) {
      cout << i << " " << i + c << endl;
      a[i + c] = 1;
      c++;
    } else {
      continue;
    }
    if (c >= m + 1)
      break;
  }
  return 0;
}
Problem p02697 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define exrep(i, a, b) for (long long i = a; i <= b; i++)
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll>> vvl;
typedef vector<vector<P>> vvp;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const int MAX = 510000;
const double pi = acos(-1);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

  int n, m;
  cin >> n >> m;
  vector<P> vec;
  if (n % 2) {
    for (int l = 1, r = n - 1; l <= n / 2; l++, r--) {
      vec.push_back(P(l, r));
    }
  } else {
    int l = 1, r = n, cnt = 1;
    while (cnt <= n / 4) {
      vec.push_back(P(l, r));
      l++;
      r--;
      cnt++;
    }
    l++;
    while (abs(l - r) > 1) {
      vec.push_back(P(l, r));
      l++;
      r--;
    }
  }
  rep(i, m) { cout << vec[i].first << " " << vec[i].second << endl; }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define exrep(i, a, b) for (long long i = a; i <= b; i++)
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll>> vvl;
typedef vector<vector<P>> vvp;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const int MAX = 510000;
const double pi = acos(-1);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

  int n, m;
  cin >> n >> m;
  vector<P> vec;
  if (n % 2) {
    for (int l = 1, r = n - 1; l <= n / 2; l++, r--) {
      vec.push_back(P(l, r));
    }
  } else {
    int l = 1, r = n, cnt = 1;
    while (cnt <= n / 4) {
      vec.push_back(P(l, r));
      l++;
      r--;
      cnt++;
    }
    l++;
    while (abs(l - r) > 1) {
      vec.push_back(P(l, r));
    }
  }
  rep(i, m) { cout << vec[i].first << " " << vec[i].second << endl; }
  return 0;
}
Problem p02697 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

typedef long long ll;
typedef long double ld;
#define FASTIO                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);

using namespace std;

const ll inf = 1e18;
const ll N = 1e5 + 1;
const ll mod = 1e9 + 7;

int main() {

  FASTIO;
  PRECISION;

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

  if (n % 2) {
    int a = 1, b = n - 1;
    while (m) {
      cout << a << " " << b << "\\n";
      a++;
      b--;
      m--;
    }
  } else {
    int a = 1, b = n - 1;
    int done = false;

    while (m--) {

      if (!done && b - a <= n / 2) {
        done = true;
        b--;
      }
      cout << a << " " << b << "\\n";

      b--;
      a++;
    }
  }
}


Error: WA

Fixed submission:

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

typedef long long ll;
typedef long double ld;
#define FASTIO                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);

using namespace std;

const ll inf = 1e18;
const ll N = 1e5 + 1;
const ll mod = 1e9 + 7;

vector<int> primes;

ll prime[N];
ll factors[N];

void pre() {

  for (int i = 2; i < N; i++)
    prime[i] = 1;
  prime[0] = prime[1] = 0;

  for (int i = 2; i < N; i++) {
    if (prime[i]) {
      primes.push_back(i);
      for (int j = 2; i * j < N; j++) {
        prime[i * j] = 0;
        factors[i * j]++;
      }
    }
  }
}

int main() {

  FASTIO;
  PRECISION;

  pre();

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

  int a = 1, b = 2, dist = 1;

  for (int i = 0; i < m; i++) {
    b = (a + primes[i] - 2 + n) % n + 1;
    cout << a << " " << b << "\\n";
    a = (b + 1);
  }
}
Problem p02697 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for (ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rreps(i, e, n) for (ll i = (n)-1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\\n"

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());
  ll n, m;
  cin >> n >> m;
  if (m == 1) {
    printf("1 2\\n");
    return 0;
  }
  ll v1 = 1;
  ll v2 = m + 2;
  rreps(i, 1, m + 1) {
    printf("%lld %lld\\n", v1, v1 + i);
    v1++;
    swap(v1, v2);
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for (ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rreps(i, e, n) for (ll i = (n)-1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\\n"

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());
  ll n, m;
  cin >> n >> m;
  set<ll> used;
  ll left = 0, right = 0;
  rep(i, m) {
    right = (right + 1) % n;
    while ((used.count(left) > 0) || (used.count(right) > 0)) {
      left = (left + 1) % n;
      right = (right + 1) % n;
    }
    used.insert(left);
    used.insert(right);
    printf("%lld %lld\\n", left + 1, right + 1);
  }
  return 0;
}
Problem p02697 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define int long long
#define endl "\\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007;

struct fast_io {
  fast_io() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
  };
} fio;

signed main() {
  cout << fixed << setprecision(10);

  int N, M, m;

  cin >> N >> M;

  for (int i = 0, j = (M + 1) / 2 * 2 - 1; j > 0; i++, j -= 2) {
    cout << i + 1 << " " << i + j + 1 << endl;
  }

  for (int i = (M + 1) / 2 * 2, j = M / 2 * 2; j > 0; i++, j -= 2) {
    cout << i + 1 << " " << i + j + 1 << endl;
  }

  return 0;
}


Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define int long long
#define endl "\\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007;

struct fast_io {
  fast_io() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
  };
} fio;

signed main() {
  cout << fixed << setprecision(10);

  int N, M;
  vector<int> used;

  cin >> N >> M;

  used.resize(N);

  for (int i = 0, j = M; i < N && j >= 1; i++) {
    if (used[i] == false && used[i + j] == false) {
      cout << i + 1 << " " << i + 1 + j << endl;
      used[i] = true;
      used[i + j] = true;
      j--;
    }
  }
  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)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll mod = 1000000007;
const double eps = 1e-8;

bool used[201010] = {};

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

  used[0] = true;
  if (N % 2 == 0)
    used[N / 2] = true;

  int a = 0, b = 1;
  for (int i = 0; i < M; ++i) {
    cout << a + 1 << " " << b + 1 << endl;
    if (i == M - 1)
      break;

    used[(int)abs(a - b)] = true;
    used[N - (int)abs(a - b)] = true;

    a = (a - 1 + N) % N;
    b = (b + 1) % N;
    while (used[(int)abs(a - b)]) {
      b = (b + 1) % N;
    }
  }
  return 0;
}

Error: WA

Fixed submission:

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

const ll mod = 1000000007;
const double eps = 1e-8;

bool used[101010] = {};

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

  ll a = 0, b = 1;
  for (int i = 0; i < M; ++i) {
    cout << a + 1 << " " << b + 1 << endl;
    used[max(a - b, b - a)] = true;
    used[N - max(a - b, b - a)] = true;

    a = (a - 1 + N) % N;
    b = (b + 1) % N;
    while (used[max(a - b, b - a)]) {
      b = (b + 1) % N;
    }
  }
  return 0;
}
Problem p02697 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a) / (b) + (((a) % (b)) ? 1 : 0)
#define ln '\\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<LL> Div(LL n) {
  vector<LL> ret;
  for (LL i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      ret.pb(i);
      if (i * i != n)
        ret.pb(n / i);
    }
  }
  sort(all(ret));
  return ret;
}

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

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

  int l = 1, r = N - 1;
  if (N % 2 == 1) {
    while (l < r && M > 0) {
      cout << l << " " << r << endl;
      ++l;
      --r;
      --M;
    }
  } else {
    bool f = false;
    while (l < r && M > 0) {
      if (!f && r - l <= N / 2) {
        r--;
        f = true;
      }
      cout << l << " " << r << endl;
      ++l, --r;
      --M;
    }
  }

  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a) / (b) + (((a) % (b)) ? 1 : 0)
#define ln '\\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<LL> Div(LL n) {
  vector<LL> ret;
  for (LL i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      ret.pb(i);
      if (i * i != n)
        ret.pb(n / i);
    }
  }
  sort(all(ret));
  return ret;
}

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

  bool use[SIZE] = {};
  int N, M;
  cin >> N >> M;
  int t = 1;
  for (int i = 1; i <= N && M > 0; ++i) {
    if (use[i])
      continue;
    cout << i << " " << i + t << endl;
    use[i] = use[i + t] = true;
    t++;
    M--;
  }
  return 0;
}
Problem p02697 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define pb push_back
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 20)
#define LLINF (1LL << 60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  if (n % 2 == 0) {
    int left = 1, width = n + 1, count = 0;
    bool ishalf = false; // widthがnの半分以下の時true
    while (count != m) {
      width -= 2;
      if (!ishalf && width * 2 <= n) {
        width--;
        ishalf = true;
      }
      cout << left << ' ' << left + width << endl;
      left++;
      count++;
    }
  } else {
    for (int i = 1; i <= m; i++) {
      cout << i << ' ' << n - i << endl;
    }
  }
  return 0;
}


Error: WA

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define pb push_back
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 20)
#define LLINF (1LL << 60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  if (n % 2 == 0) {
    bool isused[100005] = {}; // false:not used, true:used
    int count = 0;
    while (count != m) {
      int t = 1;
      while (isused[t]) {
        t++;
      }
      cout << t << ' ';
      isused[t] = true;
      cout << t + count + 1 << endl;
      isused[t + count + 1] = true;
      count++;
    }
  } else {
    for (int i = 1; i <= m; i++) {
      cout << i << ' ' << n - i << endl;
    }
  }
  return 0;
}
Problem p02697 (C++) — buggy submission, verdict: Runtime Error

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

#define debug(x) cout << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F;
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;
const ll mod = 998244353;

inline int cmp(double x, double y = 0) {
  if (fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b) {
  ll ans = 1;
  while (b) {
    if (b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 2e5 + 10;

int a[maxn];

map<int, int> mapa;

int main() {
  ios::sync_with_stdio(0);
  int n, m;

  cin >> n >> m;
  int l = 1, r = m + 1;
  while (l < r)
    cout << l++ << ' ' << r-- << endl;

  l = m + 2, r = 2 * m + 1;
  while (l < r)
    cout << l++ << ' ' << r-- << endl;

  return 0;
}

Error: WA

Fixed submission:

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

#define debug(x) cout << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F;
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;
const ll mod = 998244353;

inline int cmp(double x, double y = 0) {
  if (fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b) {
  ll ans = 1;
  while (b) {
    if (b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 2e5 + 10;

int a[maxn];

map<int, int> mapa;

int main() {
  ios::sync_with_stdio(0);
  int n, m;

  cin >> n >> m;
  set<int> s;
  for (int i = 1; i <= n; i++)
    s.insert(i);
  int gap = 1;
  for (int i = 1; i <= m; i++) {
    assert(s.size() > 0);
    int a = *s.begin();
    cout << a << ' ' << a + gap << endl;
    s.erase(s.find(a));
    s.erase(s.find(a + gap));
    gap++;
  }

  return 0;
}