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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
N,M=map(int, sys.stdin.readline().split())
L=[1]
for i in range(M-1):
    L.append(L[-1]+2)
L.sort(reverse=True)

for x,y in zip(range(1,M+1),L):
    print x,x+y

Submission status: Wrong Answer

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

if n % 2 == 1:
    a = [i for i in range(1, m+1)]
    b = [i for i in reversed(range(m+1, 2*m+1))]
    ab = [(x, y) for x, y in zip(a, b)]
else:
    a = [i for i in range(1, n//2)]
    b = [i for i in reversed(range(n//2+1, n+1))]
    ab = [(x, y) for x, y in zip(a, b)]
    ab = ab[:m]

for a, b in ab:
    print(a, b)

Submission status: Wrong Answer

Solution code:
def main():
    n,m=map(int,input().split())
    if n%2==1:
        x=[f"{i+1} {n-i}" for i in range(m)]
        print(" ".join(x))
    else:
        x=[f"{i+1} {n-i}" if i<m/2 else f"{i+1} {n-i-1}" for i in range(m)]
        print(" ".join(x))

if __name__ == "__main__":
    print(main())

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
if n%2 ==1:
    for i in range(1,m+1):
        print(i,n-i)
else:
    left_end = m if m%2 == 1 else m-1
    left_start = left_end//2
    right_start = left_end+m//2
    for i in range(1,m+1):
        if i%2 == 1:
            print(left_start,left_start+i)
            left_start-=1
        else:
            print(right_start,right_start+i)
            right_start-=1

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if M%2 != 0:
    M = M + 1
    c = M//2
    d = int((M + 1 + 2*M + 1) / 2)
    
    i = 0
    while i < c:
        print(c-i, c+1+i)
        i += 1
    j = 0
    while i < M-1:
        print(d-(j+1), d+(j+1))
        i += 1
        j += 1

Submission status: Wrong Answer

Solution code:
#ABC165-E Rotation Matching
"""
各頂点を円形に並べた時に、距離が等しくならないようにm個の辺を張れば良い。
"""
import sys
from collections import defaultdict
dic1 = defaultdict(int)
dic2 = defaultdict(int)
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,m = map(int,readline().split())
ans = []
mod = n
now = 0
point = -1
while True:
    if len(dic2) == m:
        break
    if now == point:
        point = -1
        now += 1
        now %= mod
        continue
    if point == -1:
        if now not in dic1:
            dic1[now] = 1
            point = now
        else:
            pass
    else:
        if now not in dic1:
            res = now-point
            res2 = min(abs(res),abs(res-mod+1))
            if res2 not in dic2:
                dic2[res2] = 1
                dic1[now]
                ans.append([point+1,now+1])
                point = -1
        else:
            pass
    now += 1
    now %= mod
for i,j in ans:
    print(i,j)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if M%2 != 0:
    M = M + 1
    c = M//2
    d = int((c + 1 + 2*M + 1) / 2)
    
    i = 0
    while i < c:
        print(c-i, c+1+i)
        i += 1
    j = 0
    while i < M-1:
        print(d-(j+1), d+(j+1))
        i += 1
        j += 1

Submission status: Wrong Answer

Solution code:
N, M = list(map(int, input().split()))
# M (< N)個のペア
# 差分が同じものが存在しないように、非復元抽出する問題と置き換えられる。
max_assign = N+1
min_assign = 0
existing_diffs = []
for m in range(M):
    min_assign += 1
    max_assign -= 1
    diff = max_assign - min_assign
    if N - diff not in existing_diffs:
        print(min_assign, " ",max_assign)
        existing_diffs.append(diff)

Submission status: Wrong Answer

Solution code:
N, M = list(map(int, input().split()))
# M (< N)個のペア
# 差分が同じものが存在しないように、非復元抽出する問題と置き換えられる。
max_assign = N+1
min_assign = 0
existing_diffs = []
for m in range(M):
    min_assign += 1
    max_assign -= 1
    diff = max_assign - min_assign
    if diff not in existing_diffs:
        print(min_assign, " ",max_assign)
        existing_diffs.append(diff)

Submission status: Wrong Answer

Solution code:
def main():
    n, m = list(map(int, input().split()))
    start1 = 1
    if m < 3:
        end1 = 3
    else:
        if m % 2 == 1:
            end1 = m
        else:
            end1 = m + 1
    start2 = end1 + 1
    end2 = start2 + (end1 - 2)

    j, k = 0, 0
    for i in range(m):
        if i % 2 == 0 and 2*j != end1 - start1:
            print(start1+j, end1-j)
            j += 1
        else:
            print(start2+k, end2-k)
            k += 1


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if n % 2 == 1:
    a = [i for i in range(1, m+1)]
    b = [i for i in reversed(range(m+1, 2*m+1))]
    ab = [(x, y) for x, y in zip(a, b)]
else:
    ab = []
    used = [0]*n
    diff = 1
    for i in range(n):
        if used[i]:
            continue
        used[i] = 1
        used[(i+diff) % n] = 1
        ab.append((i+1, i+1+diff))
        diff += 1
        if diff == n//2:
            diff += 1

    ab = ab[:m]

for a, b in ab:
    print(a, b)

if n*m < 10**4:
    opponent = []
    for i in range(n):
        for a, b in ab:
            if i % n+1 == a:
                opp = (b-i) % n
                if opp == 0:
                    opp = n
                opponent.append(opp)
                break
            if i % n+1 == b:
                opp = (a-i) % n
                if opp == 0:
                    opp = n
                opponent.append(opp)
                break
    assert len(set(opponent)) == len(opponent)

Submission status: Wrong Answer

Solution code:

N, M = list(map(int, input().split()))
# 差分が同じものが存在しないように、非復元抽出する問題と置き換えられる。
max_assign = N
min_assign = 1
for m in range(M):
    print(min_assign, " ",max_assign)
    min_assign += 1
    max_assign -= 1

Submission status: Wrong Answer

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

if n % 2 == 1:
    a = [i for i in range(1, m+1)]
    b = [i for i in reversed(range(m+1, 2*m+1))]
    ab = [(x, y) for x, y in zip(a, b)]
else:
    ab = []
    used = [0]*n
    diff = 1
    for i in range(n):
        if used[i]:
            continue
        used[i] = 1
        used[(i+diff) % n] = 1
        ab.append((i+1, i+1+diff))
        diff += 1
        if diff == n//2:
            diff += 1

    ab = ab[:m]
    assert len(ab) == m

for a, b in ab:
    print(a, b)

Submission status: Wrong Answer

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

if n % 2 == 1:
    a = [i for i in range(1, m+1)]
    b = [i for i in reversed(range(m+1, 2*m+1))]
    ab = [(x, y) for x, y in zip(a, b)]
else:
    ab = []
    used = [0]*n
    diff = 1
    for i in range(n):
        if used[i]:
            continue
        used[i] = 1
        used[(i+diff) % n] = 1
        ab.append((i+1, i+1+diff))
        diff += 1
        if diff == n//2:
            diff += 1

    ab = ab[:m]

for a, b in ab:
    print(a, b)

Submission status: Wrong Answer

Solution code:
import sys


sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, M = map(int, input().split())

    if N % 2 == 0:
        used = [False] * (10 * N + 1)
        i = 0
        span = 1
        cnt = 0
        while cnt < M:
            cnt += 1
            while used[i]:
                i += 1
            print(i + 1, i + 1 + span)
            used[i] = True
            used[i + span] = True
            span += 1
    else:
        for i in range(M):
            print(i + 1, N - i)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# E - Rotation Matching

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

if N%2:
    for i in range(M):
        print(i+1, N-(i))
else:
    for i in range(M):
        if i+(N-(N-(i+1))) < N-(i+1)-i+1:
            print(i+1, N-(i+1))
        else:
            print(i+2, N-(i+1))

Submission status: Wrong Answer

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

if n % 2 == 1:
    a = [i for i in range(1, m+1)]
    b = [i for i in reversed(range(m+1, 2*m+1))]
    ab = [(x, y) for x, y in zip(a, b)]
else:
    ab = []
    used = [0]*n
    diff = 1
    for i in range(n):
        if used[i]:
            continue
        used[i] = 1
        used[(i+diff) % n] = 1
        ab.append((i+1, i+1+diff))
        diff += 1

    ab = ab[:m]

for a, b in ab:
    print(a, b)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, read().split())
if n % 2 == 1:
    for i in range(1, m + 1):
        print(i, n - i)
else:
    x, y = 0, 0
    for i in range(m):
        a, b = 2 * i, n - 2 * (i - 1)
        if a == b or (a == y and b == x):
            n -= 1
        x, y = a, b
        print(i + 1, n - i)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
if n%2 == 1:
    for i in range(m):
        print(n//2-i,n//2+1+i)
else:
    print(1,n)
    a = 2
    s = set([1,n])
    for i in range(m-1):
        if a in s:
            while a in s:
                a += 1
        print(a,a+2+i)
        s.add(a)
        s.add(a+2+i)

Submission status: Wrong Answer

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

    if m % 2 == 1:
        start1 = 1
        end1 = n - m - 1
    else:
        start1 = 1
        end1 = n - m
    start2 = end1 + 1
    end2 = n

    j, k = 0, 0
    for i in range(m):
        if i % 2 == 0 and 2*j != end1 - start1:
            print(start1+j, end1-j)
            j += 1
        else:
            print(start2+k, end2-k)
            k += 1


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
mod = lambda x:x%n+1
for i in range((m+1)//2):
    print(mod(-i), mod(i+1))
for i in range(m//2):
    print(mod(-i+(m+1)//2+1), mod(i+2+(m+1)//2+1))

Submission status: Wrong Answer

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

    if m % 2 == 1:
        start1 = 1
        end1 = m
    else:
        start1 = 1
        end1 = m + 1
    start2 = end1 + 1
    end2 = n

    j, k = 0, 0
    for i in range(m):
        if i % 2 == 0 and 2*j != end1 - start1:
            print(start1+j, end1-j)
            j += 1
        else:
            print(start2+k, end2-k)
            k += 1


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,m = map(int,readline().split())

"""mid = n//2
mid_ = mid+1
for i in range(m):
    print(mid,mid_)
    mid -= 1
    mid_ += 1"""

l,r = 1,n
for i in range(m):
    print(l,r)
    l += 1
    r -= 1

Submission status: Wrong Answer

Solution code:
def e_rotation_matching():
    N, M = [int(i) for i in input().split()]

    ans = []
    if M % 2 == 0:
        for left in range(1, N + 1):
            right = N - left
            if left >= right:
                break
            ans.append((left, right))
    else:
        flag = False
        for left in range(1, N + 1):
            right = N - left
            if left >= right:
                break
            if not flag and right - left <= N // 2:
                right -= 1
                flag = True
            ans.append((left, right))
    return '\n'.join([' '.join(map(str, row)) for row in ans])

print(e_rotation_matching())

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, read().split())
if n % 2 == 1:
    for i in range(1, m + 1):
        print(i, n - i)
else:
    for i in range(m):
        if 2 * i == n - 3 * i - 1:
            n -= 1
        print(i + 1, n - i)

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,m = map(int,readline().split())

mid = n//2
mid_ = mid+1
for i in range(m):
    print(mid,mid_)
    mid -= 1
    mid_ += 1

Submission status: Wrong Answer

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

used = [0]*N
p = 0
for i in range(1,M+1):
    while used[p] == 1:
        p += 1
    print(p+1,p+1+i)
    used[p] = 1
    used[(p+i)%N] = 1
    p += 1

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
cnt = 1
cnt_ = 0
answer = []
checked = set()
checked_number = set()
while len(answer) != M:
    d = abs((N - cnt_) - cnt)
    d_ = N - d
    if d in checked or d_ in checked:
        cnt_ += 1
        continue
    if cnt == N - cnt_:
        cnt_ += 1
        continue
    if cnt in checked_number:
        cnt += 1
        continue
    if N - cnt_ in checked_number:
        cnt_ += 1
    answer.append((cnt, N - cnt_))
    checked.add(d)
    checked.add(d_)
    checked_number.add(cnt)
    checked_number.add(N - cnt_)
    cnt += 1
    cnt_ += 1

for i, j in answer:
    print(i, j)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, read().split())
for i in range(1, m + 1):
    if 2 * i + 1 == n - 2 * i - 1 and n % 2 == 0:
        n -= 1
    print(i, n - i)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())

if a%2==0:


    A = a//2
    B = a//2+1
    AA = 1
    BB = b-1
    for i in range(b):
        if AA == A or AA>= A:
            print(B,BB)
            B+=1
            BB-=1
        else:
            print(AA,A)
            AA+=1
            A-=1

else:
    A = a//2
    B = a//2+1
    AA = 1
    BB = b
    for i in range(b):
        if AA == A or AA>= A:
            print(B,BB)
            B+=1
            BB-=1
        else:
            print(AA,A)
            AA+=1
            A-=1

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())

if a%2==0:


    A = a//2
    B = a//2+1
    AA = 1
    BB = b-1
    for i in range(b):
        if AA == A or AA<= A:
            print(B,BB)
            B+=1
            BB-=1
        else:
            print(AA,A)
            AA+=1
            A-=1

else:
    A = a//2
    B = a//2+1
    AA = 1
    BB = b
    for i in range(b):
        if AA == A or AA<= A:
            print(B,BB)
            B+=1
            BB-=1
        else:
            print(AA,A)
            AA+=1
            A-=1

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())

if a%2==0:


    A = a//2
    B = a//2+1
    AA = 1
    BB = b-1
    for i in range(b):
        if AA == A:
            print(B,BB)
            B+=1
            BB-=1
        else:
            print(AA,A)
            AA+=1
            A-=1

else:
    A = a//2
    B = a//2+1
    AA = 1
    BB = b
    for i in range(b):
        if AA == A:
            print(B,BB)
            B+=1
            BB-=1
        else:
            print(AA,A)
            AA+=1
            A-=1

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
cnt = 1
cnt_ = 0
answer = []
checked = set()
checked_number = set()
while len(answer) != M:
    d = abs((N - cnt_) - cnt)
    d_ = N - d
    if d in checked or d_ in checked:
        cnt_ += 1
        continue
    if cnt == N - cnt_:
        cnt_ += 1
        continue
    if d in checked_number:
        cnt_ += 1
        continue
    answer.append((cnt, N - cnt_))
    checked.add(d)
    checked.add(d_)
    checked_number.add(cnt)
    checked_number.add(N - cnt_)
    cnt += 1
    cnt_ += 1

for i, j in answer:
    print(i, j)

Submission status: Wrong Answer

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

for i in range(m):
    print(n//2-i,n//2+1+i)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
cnt = 1
cnt_ = 0
answer = []
checked = set()
checked_number = set()
while len(answer) != M:
    d = abs((N - cnt_) - cnt)
    d_ = N - d
    if d in checked or d_ in checked:
        cnt_ += 1
        continue
    if cnt == N - cnt_:
        cnt_ += 1
        continue
    if d in checked_number:
        cnt_ += 1
        continue
    answer.append((cnt, N - cnt_))
    checked.add(d)
    checked.add(d_)
    checked_number.add(cnt)
    checked_number.add(cnt_)
    cnt += 1
    cnt_ += 1

for i, j in answer:
    print(i, j)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split())

if a%2==0:


    A = a//2
    B = a//2+1
    AA = 1
    BB = b-1
    for i in range(b):
        if AA == A:
            print(B,BB)
            B+=1
            BB-=1
        print(AA,A)
        AA+=1
        A-=1

else:
    A = a//2
    B = a//2+1
    AA = 1
    BB = b
    for i in range(b):
        if AA == A:
            print(B,BB)
            B+=1
            BB-=1
        print(AA,A)
        AA+=1
        A-=1

Submission status: Wrong Answer

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

for i in range(m):
    print(n//m-i,n//m+1+i)

Submission status: Wrong Answer

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


m = (n-1) // 2
a = (n - 1) // 2
d = 1
memo = set([])
cnt = 0
for i in range(m):

    if n - d in memo or d * 2 == n:
        cnt += 1
        d += 1
    memo.add(d)
    if cnt > 1 or a < 1 or a+d > n:
        print(1/0)
    print(a, a+d)
    a -= 1
    d += 2

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
cnt = 1
cnt_ = 0
answer = []
checked = set()
while len(answer) != M:
    d = abs((N - cnt_) - cnt)
    d_ = N - d
    if d in checked or d_ in checked:
        cnt_ += 1
        continue
    if cnt == N - cnt_:
        cnt_ += 1
        continue
    answer.append((cnt, N - cnt_))
    checked.add(d)
    checked.add(d_)
    cnt += 1
    cnt_ += 1

for i, j in answer:
    print(i, j)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

m = (n-1) // 2
a = (n - 1) // 2
d = 1
memo = set([])
cnt = 0
for i in range(m):

    if n - d in memo or d * 2 == n:
        cnt += 1
        d += 1
    memo.add(d)
    if cnt > 1:
        print(1/0)
    print(a, a+d)
    a -= 1
    d += 2

Submission status: Wrong Answer

Solution code:

from collections import deque

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

if N % 2 == 0:
    num = N - 1
else:
    num = N

num_max = N-1 // 2

used1 = list(range(1, num_max-1))
used2 = [num-a for a in used1]

# print(used1)
# print(used2)

d1 = deque(used1)
d2 = deque(used2)

for i in range(M):
    val1, val2 = d1.popleft(), d2.popleft()
    print(val1, val2)

Submission status: Wrong Answer

Solution code:

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

num = N - 1
num_max = N-1 // 2
used1 = list(range(1, num_max))
used2 = [N-a for a in used1]

# print(used1)
# print(used2)

for i in range(M):
    val1, val2 = used1.pop(0), used2.pop(0)
    print(val1, val2)

Submission status: Wrong Answer

Solution code:

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

num = N - 2
used = list(range(num+1))

# print(used)

for i in range(M):
    val = used.pop(0)
    print(val+1, num-val+1)
    used.remove(num - val)

Submission status: Wrong Answer

Solution code:

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

num = N - 2
used = list(range(num+1))

print(used)

for i in range(M):
    val = used.pop(0)
    print(val+1, num-val+1)
    used.remove(num - val)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def sol(N):
    N += 1
    ans = [[] for _ in range(N)]

    K = 0
    for i, n in enumerate(range(1, N // 2)):
        ans[i].append(n)
        K += 1
    for i, n in enumerate(range(N // 2, N - 1)):
        ans[K - 1 - i].append(n)

    return ans

if N % 2 == 1:
    ans = sol(N)
    for a in ans[:M]:
        print(*a)
else:
    ans = []
    L = (N - 2) // 2 - 1
    for a in sol(L * 2 - 1 + (2 if N % 4 == 0 else 0)):
        if len(a) == 0:
            continue
        ans.append(a)
    for a in sol(L * 2 - 1):
        if len(a) == 0:
            continue
        a[0] += L * 2 - 1 + (2 if N % 4 == 0 else 0)
        a[1] += L * 2 + (2 if N % 4 == 0 else 0)
        ans.append(a)
    for a in ans[:M]:
        print(*a)

Submission status: Wrong Answer

Solution code:
def main():
    n,m = map(int,input().split())
    t=int(n/2)
    ai=int(t/2)
    p=1
    for i in range(m):
        if i%2==0:
            print(ai, ai+p)
            ai-=1
            p+=2
        else:
            print(t+ai, t+ai+p)
            ai-=1
            p+=2

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def sol(N):
    N += 1
    ans = [[] for _ in range(N)]

    K = 0
    for i, n in enumerate(range(1, N // 2)):
        ans[i].append(n)
        K += 1
    for i, n in enumerate(range(N // 2, N - 1)):
        ans[K - 1 - i].append(n)

    return ans

if N % 2 == 1:
    ans = sol(N)
    for a in ans[:M]:
        print(*a)
else:
    ans = []
    L = (N - 2) // 2 - 1
    for a in sol(L * 2 - 1 + (2 if N % 4 == 0 else 0)):
        if len(a) == 0:
            continue
        ans.append(a)
    for a in sol(L * 2 - 1):
        if len(a) == 0:
            continue
        a[0] += L * 2 - 1
        a[1] += L * 2
        ans.append(a)
    for a in ans[:M]:
        print(*a)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 標準入力の取得
N, M = list(map(int, input().split()))

# 求解処理
l = list(range(1, N+1))
for r in range(M):
    print(f"{l[r]} {l[-1-r]}")

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
for i in range(m):
    print(i+1,n-i-(i>=m/2) & ~n)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
for i in range(m):
    print(i+1,n-i-((i<m/2) & ~n))

Submission status: Wrong Answer

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

def sol(N):
    N += 1
    ans = [[] for _ in range(N)]

    K = 0
    for i, n in enumerate(range(1, N // 2)):
        ans[i].append(n)
        K += 1
    for i, n in enumerate(range(N // 2, N - 1)):
        ans[K - 1 - i].append(n)

    return ans

if N % 2 == 1:
    ans = sol(N)
    for a in ans[:M]:
        print(*a)
else:
    ans = sol(N // 2 + 1)
    K = M
    for a in ans[:min(K, M // 2 + 1)]:
        print(*a)
        K -= 1
    ans = sol(N // 2 - 1)
    for a in ans[:min(K, M // 2)]:
        print(a[0] + N // 2 + 1, a[1] + N // 2 + 2)

Submission status: Wrong Answer

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

def sol(N):
    N += 1
    ans = [[] for _ in range(N)]

    K = 0
    for i, n in enumerate(range(1, N // 2)):
        ans[i].append(n)
        K += 1
    for i, n in enumerate(range(N // 2, N - 1)):
        ans[K - 1 - i].append(n)

    return ans

if N % 2 == 1:
    ans = sol(N)
    for a in ans[:M]:
        print(*a)
else:
    ans = sol(N // 2 + 1)
    K = M
    for a in ans[:min(K, M // 2 + 1)]:
        print(*a)
        K -= 1
    ans = sol(N // 2 - 1)
    for a in ans[:min(K, M // 2)]:
        print(a[0] + N // 2 + 1, a[1] + N // 2 + 1)

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split())
    l = 1
    r = N
    if N % 2 == 0:
        flag = True
        for i in range(M):
            if r - l <= N // 2 and flag:
                r += 1
                flag = False
            print(l,r)
            r += 1
            l -= 1
    else:
        for i in range(M):
            print(l,r)
            l += 1
            r -= 1

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split())
    l = 1
    r = N
    if N % 2 == 0:
        flag = False
        for i in range(M):
            if r - l <= N // 2 and flag:
                r += 1
                flag = True
            print(l,r)
            r += 1
            l -= 1
    else:
        for i in range(M):
            print(l,r)
            l += 1
            r -= 1

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

isEven = N % 2 == 0

N += N % 2
ans = [[] for _ in range(N)]

K = 0
for i, n in enumerate(range(1, N // 2)):
    ans[i].append(n)
    K += 1
for i, n in enumerate(range(N // 2, N - 1)):
    ans[K - 1 - i].append(n + (1 if isEven else 0))

for a in ans[:M]:
    print(*a)

Submission status: Wrong Answer

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

if N % 2 == 0:
    N += 2
else:
    N += 1

ans = [[] for _ in range(N)]

K = 0
for i, n in enumerate(range(1, N // 2)):
    ans[i].append(n)
    K += 1
for i, n in enumerate(range(N // 2, N - 1)):
    ans[K - 1 - i].append(n)

for a in ans[:M]:
    print(*a)

Submission status: Wrong Answer

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

N += N % 2
ans = [[] for _ in range(N)]

K = 0
for i, n in enumerate(range(1, N // 2)):
    ans[i].append(n)
    K += 1
for i, n in enumerate(range(N // 2, N - 1)):
    ans[K - 1 - i].append(n)

for a in ans[:M]:
    print(*a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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