Buggy python submission (verdict: Runtime Error):
import sys


def next_round(now, diff, N):
    if now + diff <= N:
        return now + diff
    else:
        return now + diff - N


def main():
    # N=10, M=4
    # 1 2
    # 3 5
    # 6 9
    # 10 4
    input = sys.stdin.buffer.readline
    N, M = map(int, input().split())
    unused = set(range(1, N + 1))
    diff = 1
    i = 1
    count = 0
    while count < M:
        left = i
        right = next_round(i, diff, N)
        unused.remove(left)
        unused.remove(right)
        print(left, right)
        count += 1
        diff += 1
        i = next_round(right, 1, N)


if __name__ == '__main__':
    main()


Fixed submission:
import sys


def main():
    input = sys.stdin.buffer.readline
    N, M = map(int, input().split())
    skip = (N // 2) // 2 + 1 if N % 2 == 0 else None
    count = 0
    left, right = 0, N + 1
    while count < M:
        left += 1
        if left == skip:
            continue
        right -= 1
        print(left, right)
        count += 1


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys


def main():
    # N=10, M=4
    # 1 2
    # 3 5
    # 4 7
    # 6 10
    input = sys.stdin.buffer.readline
    N, M = map(int, input().split())
    unused = set(range(1, N + 1))
    diff = 1
    i = 1
    count = 0
    while count < M:
        left = i
        right = i + diff
        unused.remove(left)
        unused.remove(right)
        print(left, right)
        count += 1
        diff += 1
        while True:
            i += 1
            if i in unused:
                break


if __name__ == '__main__':
    main()


Fixed submission:
import sys


def main():
    input = sys.stdin.buffer.readline
    N, M = map(int, input().split())
    skip = (N // 2) // 2 + 1 if N % 2 == 0 else None
    count = 0
    left, right = 0, N + 1
    while count < M:
        left += 1
        if left == skip:
            continue
        right -= 1
        print(left, right)
        count += 1


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys


def main():
    input = sys.stdin.buffer.readline
    N, M = map(int, input().split())
    skip = None
    if N % 2 == 0 and N % 4 != 0:
        center = (N // 2) // 2 + 1
        if M >= center:
            skip = center
    right = N + 1
    left = 0
    count = 0
    while count < M:
        left += 1
        right -= 1
        if skip == left:
            continue
        print(left, right)
        count += 1


if __name__ == '__main__':
    main()
import sys


def main():
    input = sys.stdin.buffer.readline
    N, M = map(int, input().split())
    skip = None
    if N % 2 == 0 and N % 4 != 0:
        center = (N // 2) // 2 + 1
        if M >= center:
            skip = center
    right = N + 1
    left = 0
    count = 0
    while count < M:
        left += 1
        right -= 1
        if skip == left:
            continue
        print(left, right)
        count += 1


if __name__ == '__main__':
    main()


Fixed submission:
import sys


def main():
    input = sys.stdin.buffer.readline
    N, M = map(int, input().split())
    skip = (N // 2) // 2 + 1 if N % 2 == 0 else None
    count = 0
    left, right = 0, N + 1
    while count < M:
        left += 1
        if left == skip:
            continue
        right -= 1
        print(left, right)
        count += 1


if __name__ == '__main__':
    main()