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:
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter

from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
#dequeを使うときはpython3を使う、pypyはダメ
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

#mod = 10**9+7
#w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

#N = int(input())
N, M = map(int, input().split())
#L = [int(input()) for i in range(N)]
#A = list(map(int, input().split()))
#S = [list(map(int, input().split())) for i in range(N)]

s=N//2
g=s+1
count=0
cset=set()
tcount=0

while count<M:
    if (g-s) not in cset:
        print(s,g)
        cset.add(g-s)
        cset.add(N-(g-s))
        count+=1

        s-=1
        g+=1
    else:
        if tcount%2==0 or s==1:
            s-=1
        else:
            g+=1
        tcount+=1

Submission status: Wrong Answer

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

from math import gcd

if N % 2 == 1:
    for i in range(M):
        print("{} {}".format(i+1,N-i-1))
else:
    if M % 2 == 0:
        
        for i in range(M//2+1):
            print("{} {}".format(i+1,N-i))
        for i in range(M//2+1,M):
            print("{} {}".format(i + 1, N - i+1))
    else:
        for i in range(M//2):
            print("{} {}".format(i+1,N-i))
        for i in range(M//2,M):
            print("{} {}".format(i + 1, N - i+1))

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 Round_robin(N):
    """
    関数の概要：一度に行う試合数を最大にしつつ
    　　　　　　総当たり戦の試合を組む。
    @param N：チーム数
    @return ：試合の組み合わせのリスト
    """
    match = []  # 試合の組み合わせを入れるリスト
    M=[i for i in range(N)]
    center = int(N/2)
    if N%2==0: # 偶数の時
        return [(M[0+i]+1, M[-1-i]+1) for i in range(center)]
    else: # 奇数の時
        return [(M[i]+1, M[-i+1]+1) for i in range(1,center+1)]


def solve(N, M):
    tables = Round_robin(N)
    for table in tables[:M]:
        print(' '.join(map(str, table)))


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
X = [0 for _ in range(N)]
if N % 2 == 0:
    l, r = 1, 2
    for i in range(M):
        X[l-1] = 1
        X[r-1] = 1
        print(l, r)
        while X[l-1] != 0:
            l += 1
        r = (l + i + 1) % N + 1
else:
    for i in range(M):
        print(N-i-1, i+1)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

ans = [[0, 0] for _ in range(M)]
for i in range(M):
    ans[i][0] = i+1
for i in range(M):
    ans[i][1] = M+ans[i][0]%M+1

for l in ans:
    print(*l)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
cnt=0
i=1
d=0
non = []
while cnt<m:
    a,b=i,n-(i+d)+1
    if a==b:
        print(a,non)
        break
    if b-a != n-b+a:
        print(a,b)
        i += 1
        cnt += 1
    else:
        print(a,b-1)
        non = b
        d += 1
        i += 1
        cnt += 1

Submission status: Wrong Answer

Solution code:
import sys
input=lambda: sys.stdin.readline().rstrip()
n,m=map(int,input().split())
Ans=[]
ct=0
flag=True
S=set()
for i in range(1,n):
  if ((n-i+1)-i)*2==n or i in S or n-i+1 in S or n==n-i+1:
    continue
  elif flag:
    Ans.append([i,n-i+1])
    S.add(i)
    S.add(n-i+1)
    ct+=1
    if ct==m:
      flag=False


for a in Ans:
  print(*a)

Submission status: Wrong Answer

Solution code:
import sys
import math
input = lambda:sys.stdin.readline().strip()
n,m = map(int,input().split())
n = n-(1-(n%2))
for i in range(m):
    print(i+1,n-i)

Submission status: Wrong Answer

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


def solve(N: int, M: int):

    for x in range(1, M+1):
        print("{} {}".format(x, (N-x) % (N//2)+1))

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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: Wrong Answer

Solution code:
N,M = map(int,input().rstrip().split(" "))
ans = [[False for _ in range(N)] for _ in range(N)]

if N % 2 == 1:
    for i in range(1,M + 1):
        print(str(i) + " " + str(N - i))
else:
    for i in range(1,min(M + 1,(N - 1) // 2)):
        print(str(i) + " " + str(N - i))
    if (N - 1) // 2 == M:
        print(str(N // 2) + " " + str(N // 2 + 1))

Submission status: Wrong Answer

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 = N // 2
        k = t + 1
        for i in range(M):
            if (k - t == t + N - k):
                t += 1
                k -= 1
            print(t, k)
            t += 1
            k -= 1

main()

Submission status: Wrong Answer

Solution code:
from bisect import *
from collections import *

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    from collections import deque
    N, M = (int(i) for i in input().split())
    if N % 2 == 0:
        A = deque([i+1 for i in range(N-1)])
        center = N - 1
        for day in range(1):
            for i in range(M):
                print(A[N//2-i-1], A[N//2+i])
            A.rotate()
    else:
        A = deque([i for i in range(N)])
        for day in range(1):
            for i in range(1, M+1):
                print(A[i], A[N-i])
            A.rotate()


if __name__ == '__main__':
    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 + 1)
else:
    for i in range(1, M + 1):
        print(i, N - i - 2)

Submission status: Wrong Answer

Solution code:
from collections import deque
n, m = map(int, input().split())
li = [i+1 for i in range(n)]
d = deque(li)
if n%2 != 0:
  d.pop()
else:
  d.pop()
  d.popleft()
for i in range(m):
  a = d.pop()
  b = d.popleft()
  print(a,b)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

# sys.setrecursionlimit(100000)
input = sys.stdin.buffer.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M):
    A = deque(range(1, N+1))
    B = []
    for i in range(0, M):
        B.append((i+1, N-2*i))
    for i, j in B:
        if i == j:
            j += 1
        print(i, j)


def main():
    N, M = read_int_n()
    (slv(N, M))

    # for _ in range(1000):
    #     N = 6
    #     M = 3
    #     print(N, M)
    #     slv(N, M)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

ans = []



for i in range(M):
    tmp = [str(M-(i)), str(M+(i+1))]
    tmp = ' '.join(tmp)
    ans.append(tmp)
print(*ans, sep='\n')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
n,m=mii()

a=1
b=(n//2)*2
c=(1+n)//2
a=c
b=c+1
for i in range(m):
    print(1+i,n-i)

Submission status: Wrong Answer

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

mid = N//2
for i in range(M):
    print(1+i, N-i)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
ans = []
i = 0
j = 1
for k in range(m):
    ans.append((i + 1, j + 1))
    d = j - i
    i = j + 1
    j = i + d + 1
    i %= n
    j %= n
for a in ans:
    print(*a)

Submission status: Wrong Answer

Solution code:
N, M = 4, 1
i = 0
i_center = (M+1)//2
for i in range((M+1)//2):
    print(i_center - i , end=" ")
    print(i_center + i + 1)
j_left = 2*i_center + 1
for j in range(M//2):
    print(j_left + M//2 - j , end=" ")
    print(j_left + 2*j + 1)

Submission status: Wrong Answer

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

def input_one_number():
    return int(input())

def input_multiple_number():
    return map(int, input().split())

def input_multiple_number_as_list():
    return list(map(int, input().split()))

def print2Num(x,y):
	print(str(x) + " " + str(y))

N, M = input_multiple_number()


if 2*M + (2*M-1) == N+1:
	for i in range(1,M+1):
		if i == 1 :
			print2Num(i,N)
		else:
			print2Num(i,M*2-i+1)
else:	
	for i in range(1,M+1):
		print2Num(i,M*2-i+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    from sys import stdin
    # from collections import defaultdict
    import math
    input = stdin.readline

    # import random

    n, m = map(int, input().split())
    """
    a = random.randint(1, 10**6)
    b  = random.randint(1, 10**6)
    n = random.randint(1, 10**12)
    """
    # print(a, b, n)
    
    for i in range(1,m+1):
        if i%2 == 1:
            if m%2 == 0:
                print(((m-1)-i)//2+1, ((m-1)-i)//2+1+i)
                
            if m%2 == 1:
                print(m+((m-i)//2)-i+1, m+((m-i)//2+1))
                
        if i%2 ==0:
            if m%2 == 1:
                print(((m-1)-i)//2+1, ((m-1)-i)//2+1+i)
                
            if m%2 == 0:
                print(m+((m-i)//2)-i+1, m+((m-i)//2)+1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

def gcd(a, b):
  if (b == 0):
    return a
  else:
    return gcd(b, a%b)
    
A = set()
B = set()
for i in range(1, N):
  B.add(i)
  if (gcd(N, i) == 1):
    A.add(i)

count = 0
if (N % 2):
  for j in A:
    if(j%2):
      i = int((N - j) / 2)
      print(str(i) + " " + str(N-i))
      count += 1
      if(count == M):
        break
else:
  for j in A:
    if(j%2):
      i = int((N - j + 1) / 2)
      print(str(i) + " " + str(N+1-i))
      count += 1
      if(count == M):
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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



i = 0
while i < m:
    if n%2 == 0 and n-2*(i+1) == n//2:         
        n -= 1
    print(i+1,n-i-1)
    i += 1

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    n, m = map(int, input().split())
    left = (n + 1) // 2
    right = left + 1
    for i in range(m):
        print("{0} {1}".format(left, right))
        left -= 1
        right += 1

Submission status: Wrong Answer

Solution code:
def main():
    from itertools import combinations
    n, m = map(int, input().split())
    if n % 2 == 1:
        l = n // 2
        a = 1
        b = 2 * l
        i = 0
        while i <=m:
            i += 1
            print(a, b)
            a += 1
            b -= 1
    else:
        l = n // 2
        a = 2
        b = 2 * (l - 1) + 1
        i = 0
        while i <= m:
            i += 1
            print(a, b)
            a += 1
            b -= 1


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#code
N,M=map(int,input().split())
p1=N//2
p2=N//2+1
while M:
    if(N%2==0 and (p2-p1)==N//2):
        p2+=1
    else:    
        print(p1,p2)
        p1-=1
        p2+=1
        M-=1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M = (int(x) for x in input().split())
a = 2 * M - 1
ans = []
num = 0
i = 1
while(num<M):
    if((N-a)in ans) == True:
        continue
    print(i,i+a)
    ans.append(a)
    i += 1
    num += 1
    a -= 2

Submission status: Wrong Answer

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

# num1 = N // 2
# num2 = (N // 2) + 1
# for i in range(M):
#     print(num1-i, num2+i)

half = N //2
for i in range(M):
    print(1+i, half+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:
    for i in range(1,M+1):
        print(1,1+i)

Submission status: Wrong Answer

Solution code:
print("Imakf can't AK IOI")

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,m = na()

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
X = [0 for _ in range(N)]
if N % 2 == 0:
    l, r = 1, 2
    for i in range(M):
        X[l-1] = 1
        X[r-1] = 1
        print(l, r)
        while X[l-1] != 0:
            l += 1
        r = (l + i + 2) % N + 1
else:
    for i in range(M):
        print(N-i-1, i+1)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

aa = n//2
bb = aa+1

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

        if i == 0:
            bb+=2
        else:
            bb+=1
        if bb>=n+1:
            bb=1
        aa-=1
        if aa==0:
            aa=n

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

x = N//2 + 1
a = 1
b = x
for _ in range(x//2):
    print(a,b)
    a += 1
    b -= 1
a = x + 1
b = N
for _ in range(x//2 - 1):
    print(a,b)
    a += 1
    b -= 1

Submission status: Wrong Answer

Solution code:
i = list(map(int, input().split()))
n = i[0]
m = i[1]
amari = n-m*2
if amari<m:
    for num in range(m):
        print(num+1, n-num)
else:
    for num in range(m):
        print(num+1, 2*m - num)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N,M=(int(x) for x in input().rstrip('\n').split())
a = 1
b = N
check = 0
for i in range(M):
  print(a,b)
  a += 1
  b -= 1
  if b-a == N/2 + 1:
    if check == 0:
      b -= 1
      check += 1
  elif b-a == N/2:
    if check ==0:
      b -= 1
      check += 1

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter

from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
#dequeを使うときはpython3を使う、pypyはダメ
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

#mod = 10**9+7
#w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

#N = int(input())
N, M = map(int, input().split())
#L = [int(input()) for i in range(N)]
#A = list(map(int, input().split()))
#S = [list(map(int, input().split())) for i in range(N)]

s=N//2
g=s+1
count=0
cset=set()
tcount=0

while count<M:
    if (g-s) not in cset:
        print(s,g)
        cset.add(g-s)
        cset.add(N-(g-s))
        count+=1

        s-=1
        g+=1
    else:
        if tcount%2==0:
            s-=1
        else:
            g+=1
        tcount+=1

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M=map(int,input().split())
for i in range(1,M+1):
    print('{} {}'.format(i,2*M+1-i))

Submission status: Wrong Answer

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

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict
from itertools import combinations, permutations
from itertools import accumulate
from math import ceil, sqrt, pi

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

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
seen = [False] * (N + 1)
for i in range(M):
    if(N % 2): print(i + 1, N - i)
    else:
        l, r = i + 1, N - 1
        if(seen[r - l + 1] == False and seen[N - r + 1 + l] == False):
            print(i + 1, (N - i))
            seen[r - l + 1], seen[N - r + 1 + l] = True, True
        else: print(i + 1, N // 2)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
used = set()
used_diff = set()
count = 0
diff = 1
for i in range(1, N):
    if i in used:
        continue

    used.add(i)
    for j in range(i + diff, N + 1):
        if j not in used:
            used.add(j)
            print(i, j)
            used_diff.add(diff)
            used_diff.add(N - diff)
            a = 1
            while True:
                if diff + a not in used_diff:
                    diff += 1
                    break
                a += 1
            count += 1
            if count == M:
                exit()
            else:
                break

Submission status: Wrong Answer

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

if N % 2 == 0:
    print(1, N - 1)
    d = N - 4
    for a in range(2, M + 1):
        b = a + d
        print(a, b)
        d -= 3
else:
    d = N - 2
    for a in range(1, M + 1):
        b = a + d
        print(a, b)
        d -= 2

Submission status: Wrong Answer

Solution code:
n,m=list(map(int, input().split()))
l1 = [i for i in range(m)]
l2 = [n-i-1 for i in range(m)]
for a,b in zip(l1,l2):
    print(a+1,b)

Submission status: Wrong Answer

Solution code:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m=map(int,input().split())
if n%2==1:
    half=n//2
    for i in range(m):
        print(*[half-i,half+i+1])
    quit()
else:
    half=n//2
    for i in range(m):
        if i%2==0:
            print(*[half-i//2,half+i//2+1])
        else:
            print(*[1+i//2,n-1+i//2])
    # if n==4:
    #     print(*[2,3])
    # else:
    #     print(*[1,n-1])

Submission status: Wrong Answer

Solution code:
import math

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N,M =  list(map(int, input().split()))
if N % 2!=0:
    for i in range(1,M+1):
        print(i,N-i+1)
else:
    d = []
    for i in range(1,M+1):
        if N-2*i+1 in d:
            print(i,N-i)
        else:
            print(i,N-i+1)
            d.append(2*i-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

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

if N%2:
    x,y=N//2,N//2+1
    for i in range(M):
        print(x-i,y+i)

else:

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

n,m = l_in()

#n = 12
#m = n//2-1



i = 1
if n%2 == 0:
    j = n
    for cnt in range(m):
        if j-i == n//2:
            j -= 1
        print(i,j)
#        print(min(j-i,n-(j-i)))
        i+=1

        j-=1
else:
    j = n-1
    for cnt in range(m):
        print(i,j)
#        print(min(j-i,n-(j-i)))
        i+=1

        j-=1

Submission status: Wrong Answer

Solution code:
N, M = [int(s) for s in input().split()]
for i in range(M):
    a = i + 1
    b = N - i
    print(f'{a} {b}')

Submission status: Wrong Answer

Solution code:
import math

n, m = map(int, input().split())
c = 0
f = [math.floor(n/2), math.floor(n/2) + 1]
if n % 2 == 0:
    while c < m:
        c += 1
        if c == math.ceil(n/4) + 1:
            if (f[1] + 1) % n == 0:
                f[1] = n
            else:
                f[1] = (f[1] + 1) % n
        print(str(f[0]) + ' ' + str(f[1]))
        if (f[0] - 1) % n == 0:
            f[0] = n
        else:
            f[0] = (f[0] - 1) % n
        if (f[1] + 1) % n == 0:
            f[1] = n
        else:
            f[1] = (f[1] + 1) % n
if n % 2 == 1:
    while c < m:
        c += 1
        print(str(f[0]) + ' ' + str(f[1]))
        if (f[0] - 1) % n == 0:
            f[0] = n
        else:
            f[0] = (f[0] - 1) % n
        if (f[1] + 1) % n == 0:
            f[1] = n
        else:
            f[1] = (f[1] + 1) % n

Submission status: Wrong Answer

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

num_1 = 1
num_2 = n

for i in range(m):
    print(str(num_1) + " " + str(num_2))
    num_1 += 1
    num_2 -= 1