Problem:


Score : 500 points

Problem Statement

You are going to hold a competition of one-to-one game called AtCoder Janken. (Janken is the Japanese name for Rock-paper-scissors.)
N players will participate in this competition, and they are given distinct integers from 1 through N.
The arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive).
You cannot assign the same integer to multiple playing fields.
The competition consists of N rounds, each of which proceeds as follows:

For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.

Then, each player adds 1 to its integer. If it becomes N+1, change it to 1.

You want to ensure that no player fights the same opponent more than once during the N rounds.
Print an assignment of integers to the playing fields satisfying this condition.
It can be proved that such an assignment always exists under the constraints given.

Constraints

1 \leq M

M \times 2 +1 \leq N \leq 200000

Input

Input is given from Standard Input in the following format:

N M

Output

Print M lines in the format below.
The i-th line should contain the two integers a_i and b_i assigned to the i-th playing field.

a_1 b_1
a_2 b_2
:
a_M b_M

Sample Input 1

4 1

Sample Output 1

2 3

Let us call the four players A, B, C, and D, and assume that they are initially given the integers 1, 2, 3, and 4, respectively.

The 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.

The 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.

The 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.

The 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.

No player fights the same opponent more than once during the four rounds, so this solution will be accepted.

Sample Input 2

7 3

Sample Output 2

1 6
2 5
3 4



Sample input:
4 1


Sample output:
2 3

Submission status: Runtime Error

Solution code:

def main():
    A, B, N = map(int, input().split())
    ans = 0
    for i in range(1, min(N + 1, 10**8)):
        ans = max(ans, (A*i)//B - A * (i//B))
        #print(ans, i)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
for i in range(1, m + 1):
    if (n - 2 * i + 1) == (2 * i - 1):
        j += 1
    print(i, n - i + 1 - j)

Submission status: Runtime Error

Solution code:
n,m=list(map(int(input().split(" "))))
for i in range(m):
  print(i+1,n-i-1)

Submission status: Runtime Error

Solution code:
import fractions

n,m = map(int,input().split())
lis = [True]*n

n -= 1
primes = []
for i in range(n):
  if fractions.gcd(i+1,m) == 1:
    primes.append(i+1)
if len(primes) > 0:
	primes[0] = 1
else:
	primes = [1]

for i in range(m):
    a = primes[-i-1]
    if lis[i] and lis[i+a]:
	    print(i+1,i+a+1)
	    lis[i] = False
	    lis[i+a] = False
    else:
    	for j in range(i+1,N):
        	if lis[j] and lis[j+a]:
        	  print(j+1,j+a+1)
        	  lis[j] = False
        	  lis[j+a] = False
        	  break

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
if(n % 2 == 0):
    d = n // 2 - 1
    c = 0
    i = 1
    while(d >= 0):
        print(i,i+d)
        d -= 2
        i += 1
        c += 1
        if(c == m):exit()
    d = n // 2 - 2
    i = n // 2 + 1
    while(d >= 0):
        print(i,i+d)
        d -= 2
        i += 1
        c += 1
        if(c == m):exit()


else:
    raise ValueError("error!")
    for i in range(m):
        print(i+1,n-i)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
out = []
cnt = 0
left = 0
visited = [0 for _ in range(n)]
visited[0] = 1
for i in range(1, m+1):
    out.append([left, left+i])
    visited[left-1] = 1
    visited[left+i-1] = 1
    while visited[left-1]:
        left += 1
# print(out)
for i, j in out:
    print(i+1, j+1)

Submission status: Runtime Error

Solution code:
# E

inp = input().split(' ')
N, M = int(inp[0]), int(inp[1])

import math
M2_ceil = math.ceil(M/2.0)
M2_flor = math.floor(M/2.0)
pairs = []
for i in range(M2_ceil):
    pairs.append([1+i, 1+i+sizes_even[i]+1])
for i in range(M2_flor):
    pairs.append([1+M2_ceil+1+i+1, 1+M2_ceil+1+i+1+sizes_odd[i]+1])
    
for pair in pairs:
    print(pair[0], pair[1])

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
ans_i = n//2
ans_j = ans_i+1
n_list = [0]*(n+1)
for _ in range(m):
    if n_list[ans_j]: ans_j += 1
    if n_list[ans_j]: ans_i -= 1
    if abs(ans_j-ans_i) == abs(n-ans_j+ans_i):
        if ans_i <= n-ans_j: ans_j += 1
        else: ans_i -= 1
    print(ans_i, ans_j)
    n_list[ans_i] = 1
    n_list[ans_j] = 1
    if n_list[ans_i+1]: ans_i += 1
    if n_list[ans_j-1]: ans_i -= 1
    ans_i -= 1
    ans_j += 1

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, M: int):
    left = 1
    right = N if N%2 == 0 else N-1
    count = 0
    if N%2 == 0:
        raise Exception
        while count < M:
            if right-left == N//2:
                left += 1
                right -= 1
                continue
            print(left,right)
            left += 1
            right -= 1
            count += 1
    else:
        while count < M:
            print(left,right)
            left += 1
            right -= 1
            count += 1
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
if%2=0:
  for i in range(M):
    print(i+1,N-i)
if%2=1:
  for in in range(M):
    print(i+1,N-i-1)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
x = [True for _ in range(n)]
k = 1
ans = []
i = 0
while len(ans) < m:
    if x[i] and x[i + k]:
        ans.append((i + 1, i + k + 1))
        x[i] = False
        x[i + k] = False
        k += 1
        if k >= n:
            k -= n
    i += 1
for a in ans:
    print(*a)

Submission status: Runtime Error

Solution code:
def resolve():
    n, m = map(int, input().split())
    ans = []
    diff = 1
    used = [0]*(n+1)

    for i in range(1, n+1):
        if used[i] != 1:
            j = i + diff
            ans.append([i, j])
            used[i] = 1
            used[j] = 1
            diff += 1
            if diff == m+1:
                break

    for i in range(m):
        print(" ".join(map(str, ans[i])))
resolve()

Submission status: Runtime Error

Solution code:
N,M=list(map(int,input().split()))
num=[i for i in range(1,N+1)]
ans_list=[]
for i in range(1,M+1):
  temp=num[0]
  ans_list.append((temp,temp+i))
  num.remove(temp)
  num.remove(temp+i)
for i in range(len(ans_list)):
  print(ans_list[i][0],ans_list[i][1])

Submission status: Runtime Error

Solution code:
//#pragma GCC optimize("O3")
//#pragma GCC target("avx")

#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

// Utility
using std::enable_if_t, std::is_same_v, std::is_array_v, std::declval;
using std::get, std::make_pair, std::make_tuple, std::apply;
using std::iterator_traits, std::random_access_iterator_tag;
using std::stoll, std::stold, std::to_string, std::operator""s;

// Types
using std::bitset;
using std::deque, std::list, std::multiset, std::unordered_multimap,
    std::unordered_multiset;
using std::nullptr_t, std::pair, std::tuple;
using ll = long long int;
using lf = long double;
using str = std::string;
template <class T> using u_set = std::unordered_set<T>;
template <class T> using vec = std::vector<T>;
using vecl = vec<ll>;
using vecf = vec<lf>;
using vecs = vec<str>;
template <class K, class V> using u_map = std::unordered_map<K, V>;
template <class V> using graph = u_map<V, u_set<V>>;
template <typename _Signature> using fun = std::function<_Signature>;

// Algorithms
using std::accumulate, std::partial_sum, std::inclusive_scan,
    std::exclusive_scan;
using std::all_of, std::any_of, std::none_of, std::count_if, std::find_if,
    std::for_each, std::max_element, std::min_element, std::remove_if,
    std::replace_if, std::copy, std::copy_if, std::reverse, std::transform,
    std::unique, std::sort, std::next_permutation, std::swap;
using std::back_inserter;
using std::lower_bound, std::upper_bound;
using std::max, std::min, std::clamp, std::lcm, std::gcd;

namespace io {
// Input
using IS = std::istream;
IS &in(IS &);
IS &in(IS &i) { return i; }
template <class T, class... Ts> IS &in(IS &i, T &a, Ts &... as) {
  return in(i >> a, as...);
}
template <class V> IS &operator>>(IS &i, vec<V> &a) {
  for (auto &ai : a)
    i >> ai;
  return i;
}
template <class F, class S> IS &operator>>(IS &i, pair<F, S> &p) {
  return in(i, p.first, p.second);
}
template <class... Ts> IS &operator>>(IS &i, tuple<Ts...> &t) {
  return apply([&](auto &... ts) -> IS & { return in(i, ts...); }, t);
}
// Output
using OS = std::ostream;

OS &out(OS &o, str const &) { return o; }
template <class T> OS &out(OS &o, str const &, T const &a) { return o << a; }
template <class T, class... Ts>
OS &out(OS &o, str const &sep, T const &a, Ts const &... as) {
  return out(o << a << sep, sep, as...);
}
template <class F, class S> OS &operator<<(OS &o, pair<F, S> const &p) {
  return out(o, ":", p.first, p.second);
}
template <class... Ts> OS &operator<<(OS &o, tuple<Ts...> const &t) {
  auto f = [&](auto const &... ts) -> OS & {
    return out(o << "(", ",", ts...);
  };
  return apply(f, t) << ")";
}
template <class T> struct Joiner {
  str const pre;
  str const post;
  str const sep;
  vec<T> const container;
  template <class Itr>
  Joiner(Itr begin, Itr end, str const &sep, str const &pre, str const &post)
      : pre(pre), post(post), sep(sep), container(begin, end) {}
};
template <class T> OS &operator<<(OS &o, Joiner<T> const &joiner) {
  auto itr = joiner.container.begin();
  auto end = joiner.container.end();
  o << joiner.pre;
  if (itr != end)
    o << *(itr++);
  while (itr != end)
    o << joiner.sep << *(itr++);
  return o << joiner.post;
}
template <class Itr>
auto join(Itr b, Itr e, str const &sep = ""s, str const &pre = ""s,
          str const &post = ""s) {
  using T = typename iterator_traits<Itr>::value_type;
  return Joiner<T>(b, e, sep, pre, post);
}
template <class C, enable_if_t<!is_same_v<C, str> && !is_array_v<C>,
                               nullptr_t> = nullptr>
OS &operator<<(OS &o, C const &a) {
  return o << join(a.begin(), a.end(), ",", "[", "]");
}
} // namespace io
using std::cerr, std::cin, std::cout;
auto init_io = []() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << std::fixed << std::setprecision(15);
};
auto input = [](auto &... a) { io::in(cin, a...); };
auto print = [](auto const &... a) { io::out(cout, " ", a...) << "\n"; };
#ifdef JUMPAKU_DEBUG
auto dump = [](auto const &... a) { io::out(cerr, " ", a...) << "\n"; };
#else
auto dump = [](auto const &...) {};
#endif
using io::join;

// Hash
namespace hashcode {
template <class... Ts> ll hash_args(ll h, Ts const &... ts);
ll hash_args(ll h) { return h; }
template <class T, class... Ts>
ll hash_args(ll h, T const &t, Ts const &... ts) {
  constexpr std::hash<T> hasher;
  return hash_args(((h << 19) - h) ^ hasher(t), ts...);
}
} // namespace hashcode
namespace std {
template <class... Ts> struct hash<tuple<Ts...>> {
  size_t operator()(tuple<Ts...> const &t) const {
    ll h = apply(
        [&](auto const &... ts) { return hashcode::hash_args(17, ts...); }, t);
    return h ^ (h >> 32);
  }
};
template <class T> struct hash<u_set<T>> {
  size_t operator()(u_set<T> const &t) const {
    auto hasher = std::hash<T>{};
    return accumulate(
        t.begin(), t.end(), (decltype(hasher(declval<T>())))0,
        [&](auto acc, auto const &ti) { return acc + hasher(ti); });
  }
};
} // namespace std

// Range
namespace ranges {
template <class T, class Itr> struct iterator_base {
  using difference_type = ll;
  using value_type = T;
  using pointer = T *;
  using reference = T &;
  using iterator_category = random_access_iterator_tag;
  ll i;
  iterator_base(ll const &i) : i(i) {}
  bool operator==(Itr const &itr) const { return i == itr.i; }
  bool operator!=(Itr const &itr) const { return i != itr.i; }
  ll operator-(Itr const &itr) const { return i - itr.i; }
  Itr operator++(int) { return with(i++); }
  Itr operator--(int) { return with(i--); }
  Itr operator+(ll const &n) const { return with(i + n); }
  Itr operator-(ll const &n) const { return with(i - n); }
  Itr &operator+=(ll const &n) {
    i += n;
    return self();
  }
  Itr &operator-=(ll const &n) { return self() += (-n); }
  Itr &operator++() { return self() += 1; }
  Itr &operator--() { return self() -= 1; }

protected:
  virtual Itr with(ll i) const = 0;
  virtual Itr &self() = 0;
};
template <class T> struct seq_base {
  ll const b;
  ll const e;
  seq_base(ll b, ll e) : b(b), e(e) {}
  ll size() const { return e - b; }
  bool empty() const { return size() == 0; }
};
template <class T> struct seq : seq_base<T> {
  struct iterator : iterator_base<T, iterator> {
    seq<T> const &s;
    iterator(seq<T> const &s, ll const &i)
        : iterator_base<T, iterator>(i), s(s) {}
    iterator with(ll i) const override { return iterator(s, i); }
    iterator &self() override { return *this; }
    T operator*() const { return s[this->i]; }
    iterator &operator=(iterator const &itr) {
      this->i = itr.i;
      return *this;
    }
  };
  fun<T(ll)> const f;
  seq(ll b, ll e, fun<T(ll)> const &f) : seq_base<T>(b, e), f(f) {}
  iterator begin() const { return iterator(*this, 0); }
  iterator end() const { return iterator(*this, this->size()); }
  T operator[](ll i) const { return f(i + this->b); }
};
template <class F>
seq(ll b, ll e, F const &f)->seq<typename std::invoke_result<F, ll>::type>;

struct range : seq_base<ll> {
  struct iterator : iterator_base<ll, iterator> {
    iterator(ll const &i) : iterator_base<ll, iterator>(i) {}
    iterator with(ll i) const override { return iterator(i); }
    iterator &self() override { return *this; }
    ll operator*() const { return i; }
  };
  range(ll n) : range(0LL, n) {}
  range(ll b, ll e) : seq_base<ll>(b, e) {}
  iterator begin() const { return iterator(b); }
  iterator end() const { return iterator(e); }
  bool has(ll x) const { return b <= x && x < e; }
  ll operator[](ll i) const { return i + b; }
};
} // namespace ranges
using range = ranges::range;
range::iterator end(ll i) { return range::iterator(i); }
range::iterator begin(ll i = 0LL) { return range::iterator(i); }
template <class F> auto seq(ll n, F const &f) { return ranges::seq(0LL, n, f); }

bool odd(ll n) { return n & 1; }
bool even(ll n) { return !odd(n); }

bool imply(bool p, bool q) { return !p || q; }
bool iff(bool p, bool q) { return p == q; }

constexpr ll MOD = 1e9 + 7;

void solve();
int main() {
  init_io();
  ll t = 1;
  /** input(t); /**/
  while (t--)
    solve();
  cout.flush();
}

void solve() {
  ll N, M;
  input(N, M);
  for (auto &&i : range(M)) {
    if (!(range(1, N + 1).has(i + 1) && range(1, N + 1).has(N - i)))
      exit(1);
    print(i + 1, N - i);
  }
}

Submission status: Runtime Error

Solution code:
def main():
    N, M = map(int, input().split())
    interval = 1
    lst = [i for i in range(1, N+1)]
    jud = [False for _ in range(1, N+1)]
    i = 0
    for _ in range(M):
        j = i+interval
        a = lst[i]
        b = lst[j]
        print(a, b)
        jud[i] = True
        jud[j] = True
        
        while jud[i]:
            i += 1
        interval += 1
        
main()

Submission status: Runtime Error

Solution code:
def f(vs,i):
	# print(vs)
	a = min(vs)
	print(a,a+i)
	vs.remove(a)
	vs.remove(a+i)
n,m = map(int,input().split())
vs = list(range(1,n+1))

for i in range(1,m+1):
	f(vs,i)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
if n % 2 == 1:
    ans = [n - i for i in range(m)]
    for i, v in enumerate(ans):
        print(i+1, v)
else:
    raise RuntimeError

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
x = [True for _ in range(n)]
k = 1
ans = []
i = 0
while len(ans) < m:
    if x[i] and x[i + k]:
        ans.append((i + 1, i + k + 1))
        x[i] = False
        x[i + k] = False
        k += 1
    i += 1
for a in ans:
    print(*a)

Submission status: Runtime Error

Solution code:
# coding: utf-8
import math

N,M=map(int,input().split())

# 素数判定関数
def isPrime(num):
    # 2未満の数字は素数ではない
    if num < 2: return False
    # 2は素数
    elif num == 2: return True
    # 偶数は素数ではない
    elif num % 2 == 0: return False

    # 3 ~ numまでループし、途中で割り切れる数があるか検索
    # 途中で割り切れる場合は素数ではない
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False

    # 素数
    return True

# 素数判定
def callIsPrime(input_num=1000):
    numbers = []
    # ループしながら素数を検索する
    for i in range(1, input_num):
        if isPrime(i):
            numbers.append(i)

    # 素数配列を返す
    return numbers
used=[False for i in range(N+1)]
P=callIsPrime(100000)
L=[1]
L.extend(P)

for i in range(len(L)):
    if L[i]>N-1:
        index=i-1
        break
cnt=1
C=0
while True:
    if not used[cnt] and not used[cnt+L[index-C-1]]:
        print(cnt,cnt+L[index-C-1])
        used[cnt]=True
        used[cnt+L[index-C-1]]=True
        C+=1
    if C==M:
        break
    cnt+=1

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
matches = []
used = [False] * N
i = -1
l = 1
while len(matches) < M:
    i += 1
    j = (i + l) % N
    if used[i] or used[j]: continue
    used[i], used[j] = True, True
    matches.append((i+1, j+1))
    l += 1
for a, b in matches:
    print(a, b)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
flag = [False]*(10**6)
plu_flag = [False]*(10**6)
plu = 1
for i in range(1,N+1):
  if M==0:
    break
  if (flag[i])or(flag[i+plu]):
    continue
  if (plu_flag[plu])or(plu_flag[N-plu]):
    plu+=1
    continue
    
  if i+plu>N:
    print(d)
  plu_flag[plu]=True
  plu_flag[N-plu]=True
  flag[i]=True
  flag[i+plu]=True
  print(i,i+plu)
  plu+=1
  M-=1

Submission status: Runtime Error

Solution code:
def main():
    N, M = list(map(int, input().split()))
    if N % 2 == 1:
        for i in range(M):
            print(i + 1, N - i - 1)
            
    else:
        A = [False] * N
        t = 0
        for i in range(M):
            while True:
                while A[t]:
                    t += 1
                A[t] = True
                if A[(t + i + 1)% N]:
                    A[t] = False
                    t += 1
                    continue
                break
            A[(t + i + 1) % N] = True
            print(t + 1, t + i + 2)

main()

Submission status: Runtime Error

Solution code:
from collections import deque

N, M = map(int, input().split())
matches = []
used = [False] * N
q = deque(range(N))
i = 0
l = 1
while len(matches) < M:
    i = q.popleft()
    j = (i + l) % N
    if used[i] or used[j]: continue
    used[i], used[j] = True, True
    matches.append((i+1, j+1))
    l += 1
    i += 1
for a, b in matches:
    print(a, b)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
lis = [True]*n

n -= 1
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)
if len(primes) > 0:
	primes[0] = 1
else:
	primes = [1]

for i in range(m):
    a = primes[-i-1]
    if lis[i] and lis[i+a]:
	    print(i+1,i+a+1)
	    lis[i] = False
	    lis[i+a] = False
    else:
    	for j in range(i+1,N):
        	if lis[j] and lis[j+a]:
        	  print(j+1,j+a+1)
        	  lis[j] = False
        	  lis[j+a] = False
        	  break

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
flag = [False]*(10**6)
plu_flag = [False]*(10**6)
plu = 1
for i in range(1,N+1):
  if M==0:
    break
  if (flag[i])or(flag[i+plu]):
    continue
  if (plu_flag[plu])or(plu_flag[N-plu]):
    plu+=1
    continue
    
  if plu>N//2:
    print(d)
  if i+plu>N:
    print(d)
  plu_flag[plu]=True
  plu_flag[N-plu]=True
  flag[i]=True
  flag[i+plu]=True
  print(i,i+plu)
  plu+=1
  M-=1

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())

sieve = [0] * (100000 + 1)
sieve[0] = -1
sieve[1] = -1
for i in range(2, 100000 + 1):
    if sieve[i] != 0:
        continue
    sieve[i] = i
    for j in range(i * i, 100000 + 1, i):
        if sieve[j] == 0:
            sieve[j] = i

p = []
for i in range(N - 1, -1, -1):
    if sieve[i] == i:
        p.append(i)
p.append(1)

t = set()
pp = 0
for i in range(M):
    x = i + 1
    y = x + p[pp]
    while y in t:
        pp += 1
        y = x + p[pp]
    t.add(x)
    t.add(y)
    print(x, y)
    pp += 1

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())

if N % 2 == 1:
    ans = [[1, N - 1]]
    l, r = 1, N - 1
    while len(ans) < M:
        l += 1
        r -= 1
        ans.append([l, r])

else:
    used = [0] * (N + 1)
    cursor = 1
    x = 2
    l, r = 1, 2
    ans = [[1, 2]]
    used[1] = 1
    used[2] = 1

    while len(ans) < M:
        while (cursor < N + 1) and used[cursor]:
            cursor += 1
        l = cursor
        r = l + x
        ans.append([l, r])
        used[l] = 1
        used[r] = 1
        x += 1

for l, r in ans:
    print(l, r)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
if n%2==1:
    for i in range(m):
        print(i+1, n-i-1)
else:
    if n==4:
        print(2, 3)
        exit()
    for i in range(m-1):
        print(i+1, n-i)
    print(i+3, n-i-1)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())

li = [True] * n

count = 0
for sub1 in range(1,m+1):
    while True:
        if li[count]:
            print(count+1, count + sub1 + 1)
            li[count] = False
            li[count+sub1] = False
            break
        else:
            count += 1

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())

ans = []
max_ = 2 * m

if n % 2 == 1:
    for i in range(m):
        ans.append((i + 1, max_ - i))
elif m == 1:
    for i in range(m):
        ans.append((1, 2))
else:
    for i in range(m):
        ans.append((i + 1, n - i))
    ans[-1] = (ans[-1][0], ans[-1][0] + 2)
    print(re)

for i in ans:
    print(*i)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
if N%2==1:
    for i in range(M):
        print(i+1,N-i-1)
else:
    print(0/0)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
if n%2 == 1:
  for i in range(m):
    print(i+1,2*m-i)
else:
  ans = [[i+1] for i in range(m)]
  t = n
  for i in range(m):
    if t == i+1+n//2:
      t -= 1
    ans[i].append(t)
    t -= 1
print(ans)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())

a = list(range(1,m+1))
b = list(range(2*m,m,-1))

for i in range(m):
  k = b[i]-a[i]
  l = b[i]+k
  h = l-n
  if a[i]==h:
    b[i]=a*m+1
  print(a[i],b[i])

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
result = []
x = [i for i in range(1, 2*m+2)]
for i in range(m):
    result.append([x[i], x[-i-1]])
result[-1][1], result[-2][1] = result[-2][1], result[-1][1]
for j in result:
    print(*j)

Submission status: Runtime Error

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

using ll = long long;
using vi = vector<int>;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

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

    int l = 1, h = n;

    rep (i, 0, m) {            
        if (n % 2 == 0 && h - l == n / 2) h--;
        cout << l << ' ' << h << '\n';
        l++, h--;
    }
}

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
A=[0]*1
if N%2==1:
    A[2]
left=N//2
right=left+1
for i in range(M):
    print("{} {}".format(left,right))
    left -= 1
    right += 1

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
if n%2 ==1:
    for i in range(1,m+1):
        print(i,n-i)
else:
    last = 0
    li = [j for j in range(1,n+1)]
    #print(li)
    for i in range(1,m+1):
        a = min(li)
        b = min(li)+i
        print(a,b)
        li.remove(a)
        li.remove(b)

Submission status: Runtime Error

Solution code:
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
import itertools

N, M, Q = MAP()
a, b, c, d = [], [], [], []
for _ in range(Q):
    ai, bi, ci, di = MAP()
    a.append(ai-1); b.append(bi-1); c.append(ci); d.append(di)


def solve(lst):
    ans = 0
    for i in range(Q):
        if lst[b[i]] - lst[a[i]] == c[i]:
            ans += d[i]
    return ans

ans = 0
for A in itertools.combinations(range(1, 11), N):
    ans = max(ans, solve(A))

print(ans)

Submission status: Runtime Error

Solution code:
def resolve():
    N,M = map(int,input().split())
    cmb = []
    if N % 2 ==1:
        for i in range(1,M+1):
            print(i,N-i)
    else:
        raise


resolve()

Submission status: Runtime Error

Solution code:
# coding: utf-8
import math

N,M=map(int,input().split())

# 素数判定関数
def isPrime(num):
    # 2未満の数字は素数ではない
    if num < 2: return False
    # 2は素数
    elif num == 2: return True
    # 偶数は素数ではない
    elif num % 2 == 0: return False

    # 3 ~ numまでループし、途中で割り切れる数があるか検索
    # 途中で割り切れる場合は素数ではない
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False

    # 素数
    return True

# 素数判定
def callIsPrime(input_num=1000):
    numbers = []
    # ループしながら素数を検索する
    for i in range(1, input_num):
        if isPrime(i):
            numbers.append(i)

    # 素数配列を返す
    return numbers
used=[False for i in range(N+1)]
P=callIsPrime(100000)
P.pop(0)
L=[1]
L.extend(P)

for i in range(len(L)):
    if L[i]>N-1:
        index=i
        break
cnt=1
C=0
while True:
    if not used[cnt] and not used[cnt+L[index-C-1]]:
        print(cnt,cnt+L[index-C-1])
        used[cnt]=True
        used[cnt+L[index-C-1]]=True
        C+=1
    if C==M:
        break
    cnt+=1

Submission status: Runtime Error

Solution code:
def main():
    n, m = map(int, input().split())
    t = [True]*n
    s = [True]*(n+1)
    x = 1
    for _ in range(m):
        while not s[x]:
            x += 1
        s[x] = False
        for i in range(1, n+1):
            if t[i] and x+i<n+1 and s[x+i]:
                print(x, x+i)
                t[i] = False
                s[x+i] = False
                break

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
(n, m) = map(int, raw_input().split())

assert m * 2 + 1 <= n

p, q = 1, n

st1 = set()
st2 = set()
for i in xrange(m):
    if n % 2 == 0 and i == m - 1:
        q -= 1

    print p, q

    assert p not in st1 and q not in st1
    st1 |= set([p, q])

    cur = set([q - p, (p - q + n) % n])
    # print sorted(cur)
    assert not (st2 & cur)
    st2 |= cur

    p += 1
    q -= 1

Submission status: Runtime Error

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M = LI()
    pairs = []
    used = [0 for _ in range(N)]
    cur = 0
    for gap in range(1, M+1):
        while used[cur] or used[(cur + gap) % N]:
            cur += 1
        pairs.append((cur, cur + gap))
        used[cur] = 1
        used[(cur+gap) % N] = 1
    for p in pairs:
        print(p[0]+1, p[1]+1)



main()

Submission status: Runtime Error

Solution code:
from collections import deque
def main():
    n,m = map(int, input().split())
    if n%2==0 and 2*(m+1)==n:
        lst = deque([i for i in range(1,n+1)])
        for i in range(1,m+1):
            a = lst.popleft()
            b = a + i
            lst.remove(b)
            print(str(a)+' '+str(b))
    else:
        for i in range(1,n//2+1):
            print(str(i)+' '+str(n-i))
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
if N % 2== 0:
    for m in range(M-1):
        print(m + 1, N - m)
    print(m + 2 , N - M)
else:
    for m in range(M):
        print(m + 1, N - m)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
out = []
for i in range(m):
    out.append([i + 1, n - i])
out[0][1], out[1][1] = out[1][1], out[0][1]
for i, j in out:
    print(i, j)

Submission status: Runtime Error

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M = LI()
    pairs = []
    used = [0 for _ in range(N)]
    cur = 0
     
    for gap in range(1, M+1):
        while used[cur] or used[(cur + gap) % N]:
            cur += 1
        pairs.append((cur, cur + gap))
        used[cur] = 1
        used[cur+gap] = 1
    for p in pairs:
        print(p[0]+1, p[1]+1)



main()

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())	

parti=list(range(n))
for j in range(1,m+1):
  for i in range(n):
    if (parti[i]+j)%n in parti:
      saiyou = parti[i]
      pair = (saiyou+j)%n
      print(saiyou+1, pair+1)
      parti.remove(saiyou)
      parti.remove(pair)
      break

Submission status: Runtime Error

Solution code:
N, M = map(int,input().split())
for i in range(M):
  if i%2==0:
    j = i//2
    print("{} {}".format(1+j,M+1-j))
  else:
    j = i//2
    print("{} {}".format(M+2+i,2M+1-i))