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())
array = []
if N % 2 == 1:
    for i in range(1,(N-1)//2 + 1):
        array.append([i,N-i])
    for i in range(M):
        print(*array[i])
else:
    array.append([1,N])
    for i in range(2,N//2):
        array.append([i,2*i])
    for i in range(M):
        print(*array[i])

Submission status: Wrong Answer

Solution code:
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

N, M = rl()

m = 1
for i in range(1, M+1):
	print(i, i+m)
	m += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

# 割り当てを一つ求める
# N回Mラウンドを行う 1ラウンドあたりの最大対戦者数はN以下になる

# 対戦者A, B, C, D...にそれぞれ１、２、３、４...を割り当てる
# 試合後、A, B, C, D...の数字は２、３、４、５...になる N + 1になったら１になる
# N, M = 4, 1の時 M1に[1, 2]を割り当てると
#   A B C D
# 1 1 2 3 4 A vs B
# 2 2 3 4 1 D vs A
# 3 3 4 1 2 C vs D
# 4 4 1 2 3 B vs C なのでok
# Nラウンドでちょうど一周するので、M = 1の時は何を入れてもok

# N, M = 5, 2の時
#   A B C D E
# 1 1 2 3 4 5
# 2 2 3 4 5 1
# 3 3 4 5 1 2
# 4 4 5 1 2 3
# 5 5 1 2 3 4

# M1には何を指定してもいい？
# 少なくともM1とM2が同じパターン(i, i+1等)はダメ
# 全てのMについて違うパターンで数字を割り当てられるか
# = 任意のMi(ai, bi), Mj(aj, bj)について abs(bi - ai) != abs(bj - aj)
N, M = getNM()
A = []
B = []
for i in range(N):
    A.append(i + 1)
    B.append(N - i)

for i in range(M):
    print(A[i], B[i])

Submission status: Wrong Answer

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

a = 1
b = N
for _ in range(M):
    print(str(a) + ' ' + str(b))
    a += 1
    b -= 1

Submission status: Wrong Answer

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

used = [False] * (N+1)
gaps = [False] * (N+1)

a = 1
b = N
for _ in range(M):
    print(str(a) + ' ' + str(b))
    a += 1
    b -= 1
    if N%2 == 0 and b-a == N//2:
        b-=1

Submission status: Wrong Answer

Solution code:
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
n,m = ma()
ans = []
r,l = 1,n
for i in range(m):
    print(r,l)
    r+=1
    l-=1
    if l-r ==n-l+r:
        l-=1

Submission status: Wrong Answer

Solution code:
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
n,m = ma()
ans = []
r,l = 1,n
for i in range(m):
    print(r,l)
    r+=1
    l-=1

Submission status: Wrong Answer

Solution code:
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
n,m = ma()
ans = []
r,l = 1,2*m
for i in range(1,m+1):
    ans.append((r,l))
    r+=1
    l-=1
for r,l in ans:
    print(r,l)

Submission status: Wrong Answer

Solution code:
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
n,m = ma()
ans = []
r,l = 1,2*m+1
for i in range(1,m+1):
    ans.append((r,l))
    r+=1
    l-=1
for r,l in ans:
    print(r,l)

Submission status: Wrong Answer

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

if n%2 != 0:
  for i in range(m):
    print(1+i,n-i)
else:
  c = (n-2)//4
  for i in range(c+1):
    print(1+i,n-i)
  for j in range(c+1,m):
    print(1+j,n-j-1)

Submission status: Wrong Answer

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

if n%2 != 0:
  for i in range(m):
    print(1+i,n-i)
else:
  for i in range(m-1):
    print(1+i,n-i)
  print(m,n-m)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

for i in range(m):
  print(1+i,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 - i, i + 1)
else:
    used = [False] * (n + 1)
    offset = 0
    for i in range(m):
        a = n - (i + offset)
        b = i + offset + 1
        d = min(abs(a - b), abs(n - (a - b)))
        if used[d]:
            offset = 1
        used[d] = True
        print(n - (i + offset), i + offset + 1)

Submission status: Wrong Answer

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

if n % 2 == 1:
    for i in range(m):
        print(n - i, i + 1)
else:
    used = [False] * (n + 1)
    offset = 0
    for i in range(m):
        a = n - (i + offset)
        b = i + offset + 1
        d = min(a - b, n - (a - b))
        if used[d]:
            offset = 1
        used[d] = True
        print(n - (i + offset), i + offset + 1)

Submission status: Wrong Answer

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

if n % 2 == 1:
    for i in range(m):
        print(n - i, i + 1)
else:
    for i in range(m - 1):
        print(n - i, i + 2)
    print(n - m + 1, n - m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import deque

n, m = map(int, input().split())
 
x = deque(range(1, n + 1))
aaa = []
bbb = []

if n % 2 == 1:
    for i in range(m):
        a = x.popleft()
        aaa.append(a)
        b = x.pop()
        bbb.append(b)

else:
    for i in range(m):
        # ｎが偶数の場合は途中で1個捨てる
        if m // 2 == i:
            a = x.popleft()
        a = x.popleft()
        aaa.append(a)
        b = x.pop()
        bbb.append(b)

for aa, bb in zip(aaa, bbb):
    print(aa, bb)

Submission status: Wrong Answer

Solution code:
from collections import deque

n, m = map(int, input().split())
 
x = deque(range(1, n + 1))
aaa = []
bbb = []

if n % 2 == 1:
    for i in range(m):
        a = x.popleft()
        aaa.append(a)
        b = x.pop()
        bbb.append(b)

else:
    for i in range(m):
        # ｎが偶数の場合は途中で1個捨てる
        if m // 2 == i - 1:
            a = x.popleft()
        a = x.popleft()
        aaa.append(a)
        b = x.pop()
        bbb.append(b)

for aa, bb in zip(aaa, bbb):
    print(aa, bb)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
done = [False] * N
cnt = 0
for i in range(N):
	if done[i]:
		continue
	else:
		done[i] = True
		done[(i + cnt + 1) % N] = True
		print(i + 1, (i + cnt + 1) % N + 1)
		cnt += 1
		if cnt >= M:
			break

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
done = [False] * N
cnt = 0
for i in range(N):
	if done[i]:
		continue
	else:
		done[i] = True
		done[(i + cnt + 1) % N] = True
		print(i + 1, i + cnt + 1 + 1)
		cnt += 1
		if cnt >= M:
			break

Submission status: Wrong Answer

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

l = 1
r = N - 1

k = 0
while k < M:
    print(l, r)
    l += 1
    r -= 1
    k += 1

Submission status: Wrong Answer

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

l = 1
r = N if N % 2 == 0 else N - 1

k = 0
while k < M:
    print(l, r)
    l += 1
    r -= 1
    k += 1

Submission status: Wrong Answer

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

if N % 2 == 1:
    for i in range(1, M + 1):
        l = i
        r = N - i
        print(l, r)
else:
    l = 1
    r = N - 1
    cnt = 0
    while cnt < M:
        if r - l <= N // 2:
            r -= 1
        print(l, r)
        l += 1
        r -= 1
        cnt += 1

Submission status: Wrong Answer

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

if N % 2 == 1:
    for i in range(1, M + 1):
        l = i
        r = N - i
        print(l, r)
else:
    l = 1
    r = N - 1
    cnt = 0
    while cnt < M:
        if r - l == N - r + l:
            l += 1
        print(l, r)
        l += 1
        r -= 1
        cnt += 1

Submission status: Wrong Answer

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

ans = []
for i in range(1, N):
    l = i
    r = N - i + 1
    if (r - l) == (N - r + l) or l == r:
        continue
    ans.append((l, r))
    if len(ans) == M:
        break
for l, r in ans:
    print(l, r)

Submission status: Wrong Answer

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

ans = []
for i in range(1, min(N // 2, M) + 1):
    ans.append((i, N - i))
for l, r in ans:
    print(l, r)

Submission status: Wrong Answer

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

ans = []
i = 0
while i < M:
    l = i + 1
    r = N - i
    if (r - l) == (N - r + l):
        l += 1
        i += 1
    ans.append((l, r))
    i += 1
 
for l, r in ans:
    print(l, r)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ans = []
for i in range(M):
    l = i + 1
    r = N - i
    ans.append((l, r))

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20

def experiment(N,M,X):
    seen = set()
    for i in range(N):
        for j in range(len(X)):
            v1,v2 = X[j]
            if (v1,v2) in seen or (v2,v1) in seen: assert False
            seen.add((v1,v2))
            seen.add((v2,v1))

            new_v1 = v1-1
            new_v2 = v2-1

            if new_v1 < 1:
                new_v1 = N
            
            if new_v2 < 1:
                new_v2 = N

            X[j] = (new_v1,new_v2)


def main():
    N,M=mi()
    
    X = []
    s = 1
    used = set()
    for length in reversed(range(1,M+1)):
        t = s + 1
        if t > N:
            t -= N

        # print(s,length)
        j = 0 
        while t in used or abs(s-t) != length:
            t += 1
            if t > N:
                t -= N
            j += 1
            if j > N:
                s += 1
                while s in used:
                    s += 1
                    if s > N:
                        s -= N
                j = 0

                
        

        used.add(s)
        used.add(t)
        X.append((s,t))
        print(s,t)

        while s in used:
            s += 1
            if s > N:
                s -= N
    

    # experiment(N,M,X)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20

def experiment(N,M,X):
    seen = set()
    for i in range(N):
        for j in range(len(X)):
            v1,v2 = X[j]
            if (v1,v2) in seen or (v2,v1) in seen: assert False
            seen.add((v1,v2))
            seen.add((v2,v1))

            new_v1 = v1-1
            new_v2 = v2-1

            if new_v1 < 1:
                new_v1 = N
            
            if new_v2 < 1:
                new_v2 = N

            X[j] = (new_v1,new_v2)


def main():
    N,M=mi()

    print(1,2)

    if M == 1:
        exit()

    left = 3 if M % 2 == 1 else 4
    right = N
    X = []
    for i in range(M-1):
        X.append((left,right))
        print(left,right)
        left += 1
        right -= 1
        
    X.append((1,2))
    # experiment(N,M,X)
    # experiment(N,M,[(1,2),(4,6)])


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20

# def experiment(N,M,X):
#     seen = set()
#     for i in range(N):
#         for j in range(len(X)):
#             v1,v2 = X[j]
#             if (v1,v2) in seen or (v2,v1) in seen: assert False
#             seen.add((v1,v2))
#             seen.add((v2,v1))

#             new_v1 = v1-1
#             new_v2 = v2-1

#             if new_v1 < 1:
#                 new_v1 = N
            
#             if new_v2 < 1:
#                 new_v2 = N

#             X[j] = (new_v1,new_v2)


def main():
    N,M=mi()

    print(1,2)

    if M == 1:
        exit()

    left = 3
    right = N
    for i in range(M-1):
        print(left,right)
        left += 1
        right -= 1


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20

def main():
    N,M=mi()

    ans = 0
    for i in range(M):
        x = i+1
        y = N-x+1
        print(x,y)

    

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20

def main():
    N,M=mi()
    X = list(range(1,N+1))

    ans = 0
    for i in range(M):
        print(X[i],X[::-1][i])


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if N%2==0:
    r = N
    f = True
    for i in range(M):
        if f and i*4 >= N:
            r -= 1
            f = False
        print(1+i, r)
        r -= 1
else:
    for i in range(M):
        print(1+i, N-i)

Submission status: Wrong Answer

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

r = 0



k = 0
k_even = n//2+1
p_even = k_even+1

def rotate(s,diff):
    if s + diff < 1:
        return s+diff+n+1
    elif s + diff > n:
        return s+diff-n
    return s+diff

for i in range(m+1):
    if i != 0 and i % 2 == 0:
        print(rotate(k,-i//2),rotate(k,i//2))

    if i % 2 == 1:
        print(rotate(k_even,-(i//2)),rotate(p_even,i//2))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from collections import deque
from itertools import product
import sys
import math

sys.setrecursionlimit(200000)
input = sys.stdin.readline


def read():
    N, M = map(int, input().strip().split())
    return N, M


def solve(N, M):
    # 1-indexedとする
    Z = []
    # 奇数のとき
    # ABCD * DCBA と並べて1ずつずらす (N=9, M=4)
    if N % 2 == 1:
        for i in range(N//2):
            Z.append((i+1, N-i))
    # 偶数のとき
    # * A A* と並べて1ずつずらす (N=4, M=1)
    # CD AB ACBD と並べて1ずつずらす (N=8, M=4)
    # DE ABC ADBEC と並べて1ずつずらす (N=10, M=5)
    else:
        k = N//4
        offset = N//4
        for i in range(N//2):
            Z.append((k+1, k+offset+1))
            k += 1
            if k >= N//2:
                k %= (N//2)
                offset += (1 if N % 8 == 0 else 0)
            offset += 1
    for i in range(M):
        print(*Z[i])


if __name__ == '__main__':
    inputs = read()
    solve(*inputs)

Submission status: Wrong Answer

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

a = n //2
b = a + 1
abset = set()

for i in range(m):
    print(a,b)
    print("   ",b-a,n+a-b)
    abset.add(b-a)
    abset.add(n-b+a)
    a -= 1
    b += 1
    if n % 2 == 0 and (b - a == abs(n - b + a) or b - a in abset or n - b + a in abset):
        b += 1

Submission status: Wrong Answer

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

a = n //2
b = a + 1

for i in range(m):
    print(a,b)
    a -= 1
    b += 1
    if n % 2 == 0 and b - a == abs(n - b + a):
        b += 1

Submission status: Wrong Answer

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

a = n //2
b = a + 1

for i in range(m):
    print(a,b)
    a -= 1
    b += 1
    if n % 2 == 0 and b - a == n //2:
        b += 1
        a -= 1

Submission status: Wrong Answer

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

a = n //2
b = a + 1

for i in range(m):
    print(a,b)
    a -= 1
    b += 1
    if n % 2 == 0 and b - a == n //2:
        b += 1

Submission status: Wrong Answer

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

a = n //2
b = a + 1

for i in range(m):
    if n % 2 == 0 and b - a == n //2:
        print(a,b+1)
    else:
        print(a,b)
    a -= 1
    b += 1

Submission status: Wrong Answer

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

a = n //2
b = a + 1

for i in range(m):
    print(a,b)
    a -= 1
    b += 1

Submission status: Wrong Answer

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

E = 2*M
for i in range(M):
  print(i+1,E-i)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a,b=n//2,n//2+1
for i in range(m):
    print(i+1,2*m-i+(n%2==0 and 2*(m-i)>=n//2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq

n,m = list(map(int, input().split()))

p = m // 2
for i in range(p):
    print(p-i,p+2+i)

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq

n,m = list(map(int, input().split()))

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

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def S(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]

alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

def main():
    N, M = LI()
    if N % 2 == 1:
        for i in range(1, M+1):
            print(i, N - i)
    else:
        for i in range(1, M + 1):
            x = i
            y = N - i + 1
            if y - x >= (x - y) % N:
                print(x, y)
            else:
                print(x, y - 1)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def S(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]

alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

def main():
    N, M = LI()
    if N % 2 == 1:
        for i in range(1, M+1):
            print(i, N - i)
    else:
        m = N // 4
        for i in range(m):
            t = 2 * i + 1
            print(t, N - t + 1)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, M = [int(_) for _ in input().split()]
l = 1
r = N
ans = []
for _ in range(M // 2):
    ans += [l, r]
    l += 1
    r -= 1
if (r - l) % 2 == (l + N - r) % 2:
    r -= 1
for _ in range(M - M // 2):
    ans += [l, r]
    l += 1
    r -= 1
ans = ans[:2 * M]
print('\n'.join(f'{a} {b}' for a, b in zip(ans[::2], ans[1::2])))

Submission status: Wrong Answer

Solution code:
N, M = [int(_) for _ in input().split()]
l = 1
r = N
ans = []
for _ in range(M // 2):
    ans += [l, r]
    l += 1
    r -= 1
if (r - l) % 2 == (l + N - r) % 2:
    r -= 1
for _ in range(M - M // 2):
    ans += [l, r]
    l += 1
    r -= 1
ans = ans[:2 * M]
print('\n'.join(f'{a} {b} {min(b-a,a+N-b)}'
                for a, b in zip(ans[::2], ans[1::2])))

Submission status: Wrong Answer

Solution code:
N, M = [int(_) for _ in input().split()]
l = 1
r = N
ans = []
for _ in range(N // 2):
    ans += [l, r]
    l += 1
    r -= 1
ans = ans[:2 * M]
print('\n'.join(f'{a} {b}' for a, b in zip(ans[::2], ans[1::2])))

Submission status: Wrong Answer

Solution code:
N, M = [int(_) for _ in input().split()]
se = set()
ans = []
d = 1
for i in range(1, N + 1):
    if i in se:
        continue
    j = 1 + (i + d - 1) % N
    ans += [i, j]
    se.add(i)
    se.add(j)
    d += 1
ans = ans[:2 * M]
print('\n'.join(f'{i} {j}' for i, j in zip(ans[::2], ans[1::2])))

Submission status: Wrong Answer

Solution code:
N, M = [int(_) for _ in input().split()]
se = set()
ans = []
d = 1
for i in range(1, N + 1):
    if i in se:
        continue
    j = (i + d) % N
    ans += [i, j]
    se.add(i)
    se.add(j)
    d += 1
ans = ans[:2 * M]
print('\n'.join(f'{i} {j}' for i, j in zip(ans[::2], ans[1::2])))

Submission status: Wrong Answer

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

l = 1
r = N
for _ in range(M):
    print(l, r)
    l += 1
    r -= 1

Submission status: Wrong Answer

Solution code:
N, M = [int(_) for _ in input().split()]
se = set()
ans = []
d = 1
for i in range(1, N + 1):
    if i in se:
        continue
    ans += [i, i + d]
    se.add(i)
    se.add(i + d)
    d += 1
ans = ans[:2 * M]
print('\n'.join(f'{i} {j}' for i, j in zip(ans[::2], ans[1::2])))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

n,m = list(map(int, input().split()))

if m > 4:
  m1 = m//2 
  m2 = m - m1
else:
  m1 = m
  m2 = 0

for i in range(m1):
  x = i
  y = m1 + (m1 - i)
  print(x+1,y+1)

if m2 > 0:
  for i in range(m2):
    x2 = i
    y2 = m2 + (m2 - i - 1)
    y = m1+m1+1
    print(y+ x2+1, y + y2+1)

Submission status: Wrong Answer

Solution code:

n,m = list(map(int, input().split()))

if m > 4:
  m1 = m//2
  m2 = m - m1
else:
  m1 = m
  m2 = 0

for i in range(m1):
  x = i
  y = m1 + (m1 - i - 1)
  print(x+1,y+1)

if m2 > 0:
  for i in range(m2):
    x2 = i
    y2 = m2 + (m2 - i - 1)
    y = m1+m1
    print(y+ x2+1, y + y2+1)

Submission status: Wrong Answer

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

for i in range(m):
  x = i
  y = m + (m - i - 1)
  print(x+1,y+1)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

N,M = list(map(int, input().rstrip().split()))
#-----
ans = []
delta = 0

for i in range(M):
    L = 1+i
    R = N-i
    
    if (N % 2 == 0)  and  (R - L) == (N // 2):
        delta = 1
    
    ans.append( [L, R - delta] )


for nums in ans:
    print(*nums)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

N,M = list(map(int, input().rstrip().split()))
#-----
ans = []
delta = 0

for i in range(M):
    L = 1+i
    R = N-i
    
    if (R - L) == (N // 2):
        delta = 1
    
    ans.append( [L, R - delta] )


for nums in ans:
    print(*nums)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

N,M = list(map(int, input().rstrip().split()))
#-----
i = 1
ans = []

for i in range(M):
    ans.append( [N//2 - i , N//2+1 + i] )

for nums in ans:
    print(*nums)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

N,M = list(map(int, input().rstrip().split()))
#-----
i = 1
ans = []

for i in range(M):
    ans.append( [1+i, N-i] )

for nums in ans:
    print(*nums)

Submission status: Wrong Answer

Solution code:
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N,M = map(int, input().split())
    i = 1
    c = []
    for m in range(M):
        if i%2 == 1 and i >= N/2:
            i += 1
        print(M-m,M-m+i)
        c += i,
        i += 2
    

main()

Submission status: Wrong Answer

Solution code:
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N,M = map(int, input().split())
    i = 1
    for m in range(M):
        if 2*i == N:
            i += 1
        print(M-m,M-m+i)
        i += 2
    

main()

Submission status: Wrong Answer

Solution code:
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N,M = map(int, input().split())
    l = 1
    r = 2*M
    for _ in range(M):
        print(l,r)
        l += 1
        r -= 1

main()

Submission status: Wrong Answer

Solution code:
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N,M = map(int, input().split())
    l = 1
    r = N
    for _ in range(M):
        print(l,r)
        l += 1
        r -= 1

main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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


for i in range(1, M + 1):
    print(i, 2*M + 1 - i)