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())
if n%2==1:
  for i in range(m):
    print(i+1,n-i-1)
else:
  for i in range(m-1):
    print(i+1,n-i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
## coding: UTF-8
import math

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


#約数を表示　計算量sqrt(n)
#IFの判断をサボることで余計な計算量を入れないような作りになっています。
def yakusuu(n):
    #約数全列挙
    l = []
    border = int(math.sqrt(n))
    #print(border) #ここまでしか考えなくて良い
    for i in range(1, border+1):
        #print(i)
        if(n % i == 0):
            l.append(i)
            l.append(int(n/i))
    if(l[-1] == l[-2]):
        del l[-1]
    return l[1:] #この問題だけの特別措置（1を消す）

avoid = sorted(yakusuu(N))
#print(avoid)

dif = []
#len(dif)>=Mで終了する動作を後で入れる
used = ['a'] + [False] * N
#used[6] = True
ans_list = []


def search():
    for i in range(1, N):
        if(used[i]):
            break
        else:
            for j in range(N, i, -1):
                #print(i, j)
                if(used[j]):
                    continue
                else:
                    #print('i:{}, j:{}'.format(i, j))
                    if( not((j-i) in avoid)):
                        used[i] = True
                        used[j] = True
                        #print(used)
                        ans_list.append([i, j])
                        break
                    break



while(len(ans_list)<M):
    search()

#print(ans_list[:M])

for i in range(M):
    print('{} {}'.format(ans_list[i][0], ans_list[i][1]))

'''
#def search():
while len(dif)<M:
    for i in range(N):
        if(used[i]):
            #使用済みだったら使わず先に進む
            continue
        else:
            for j in range(N, i, -1):
                print(j)
                print(used[j])
                if(used[j]):
                    #使用済みだったら使わず先に進む
                    break
                else:
                    print('i:{}, j:{}, dif:{}'.format(i, j, j-i))
                    if( (not((j-i) in avoid)) ):
                        #約数だったら格納しない
                        #約数じゃなければ次はもう使われている差分かチェックする
                        #時間があればavoidにappendする
                        if( not( (j-i) in dif ) ):
                            print('clear')
                            ans_list.append((i, j))
                            dif.append(j-i)
                            used[i] = True
                            used[j] = True
                            print(ans_list, dif, used)
                            break
            else:
                continue
'''

Submission status: Wrong Answer

Solution code:
from collections import defaultdict,deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


n, m = inpl()
ans = []
j = 2
new_m=m//2*2-1
for i in range(m):
    print("{} {}".format(new_m + 1, new_m + j))
    new_m-=1
    j+=2

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:
n, m = map(int, input().split())
for i in range(1, m + 1):
  print(i, n - i)

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())

for i in range(1, m + 1):
    print(i, 2 * 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 cnt == (n//2-1)//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 = 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-1: print(i+1, n-i-1)
        else: print(i+1, n-i)

Submission status: Wrong Answer

Solution code:
import sys


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

    s = N // 2
    t = s + 1

    S = []
    T = []

    for i in range(M):
        S.append(s)
        T.append(t)
        s -= 1
        t += 1

    S2 = sorted(S)
    T2 = sorted(T, reverse=True)

    for j, k in zip(S2, T2):
        print(j, k)

    

    return


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

if __name__ == '__main__':
    main()

Submission status: 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-1):
        print(*[half-i,half+i+1])
    if n==4:
        print(*[2,3])
    else:
        print(*[1,n-1])
# print(lst)
# dic=defaultdict(int)
# for i in range(n):
#     for j in range(m):
#         tmp1=lst[j][0]+i
#         tmp2=lst[j][1]+i
#         if tmp1>n:
#             tmp1-=n
#         if tmp2>n:
#             tmp2-=n
#         dic[(al[tmp1],al[tmp2])]+=1
# # print(dic)
# for i in dic.items():
#     print(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
ans=[]
r=n//2
l=r+1
for i in range(m):
  ans.append([r,l])
  r-=1
  l+=1
for i in range(m):
  print(ans[i][0],' ',ans[i][1])

Submission status: Wrong Answer

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = MAP()

ans = list2d(M, 2, 0)
cnt = 1
for i in range(M):
    ans[i][0] = cnt
    cnt += 1
if N % 2 == 0:
    cnt += 1
for i in range(M-1, -1, -1):
    ans[i][1] = cnt
    cnt += 1

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

Submission status: Wrong Answer

Solution code:
from bisect import *
from collections import *

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

Submission status: Wrong Answer

Solution code:
def abc165_e():
  n, m = map(int, input().split())
  for i in range(m):
    l = i + 1
    u = n - i
    print('{} {}'.format(l, u))

abc165_e()

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
if N%2 == 0:
    exit()
a = 1
b = 2*M

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

Submission status: Wrong Answer

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

for i in range(M):
    print(str(M - i) + ' ' + str(M + i + 1))

Submission status: Wrong Answer

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

a = [str(i) for i in range(1,N+1)]
b = [str(i) for i in range(N,0,-1)]

aki = (N-2*M)//2
if N%2 == 0:
    for i in range(M):
        print(a[i+1] + ' ' + b[i+aki])
else:
    for i in range(M):
        print(a[i] + ' ' + b[i+aki])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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()
for i in range(m):
  a = d.pop()
  b = d.popleft()
  print(a,b)

Submission status: Wrong Answer

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

n,m = map(int,input().split())
used = [True]*(n+1)
d = [True]*(n+1)
res = []
mi = 1

dis = 0

ctr = 1

if n%2 == 1:

    while len(res) < m:
        pt1 = 1 + dis
        pt2 = n - dis
        dd = abs(pt1 - pt2)
        if not d[dd]:
            break


        d[dd] = d[n-dd] = used[pt1] = used[pt2] = False

        dis += 1
        res.append((pt1,pt2))



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

else:
    while len(res) < m:
        pt1 = 2 + dis
        pt2 = n - dis
        dd = abs(pt1 - pt2)
        if not d[dd]:
            break


        d[dd] = d[n-dd] = used[pt1] = used[pt2] = False

        dis += 1
        res.append((pt1,pt2))



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

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:
import itertools

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

L = list(range(1,N+1))
L2 = reversed(L)

U = list()
A = list()
small = 1
a = 1
b = N-1

for i in range(M):
  U.append(small)
  if (small + a) % N not in U:
    A.append((small,(small+a)%N))
    U.append((small+a)%N)
  else:
    A.append((small,(small+b)%N))
    U.append((small+b)%N)
  while small in U:
    small += 1
  a += 1
  b -= 1

for a,b in A:
  if a == 0:
    a = N
  if b == 0:
    b = N
  print("{} {}".format(a,b))

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,M*2-i+1+1)
		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())

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict,deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


n, m = inpl()
ans = []
j = 2
new_m=m//2*2+1
for i in range(m):
    print("{} {}".format(new_m + 1, new_m + j))
    new_m-=1
    j+=2

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
if n % 2:
    for i in range(m):
        print(i + 1, n - 1 - i)
else:
    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())
if N%2 == 0:
    a = 1
    b = N
else:
    a = 1
    b = N-1
chk = 0
for i in range(M):
    if (b-a)*2 == N:
        chk = 1
        continue
    print(str(a) + " " + str(b))
    a += 1
    b -= 1
if chk == 1:
    print(str(a) + " " + str(b))

Submission status: Wrong Answer

Solution code:


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


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

Submission status: Wrong Answer

Solution code:
# coding: utf-8


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

    a, b = [None] * M, [None] * M
    if N % 2 != 2:
        for i in range(M):
            a[i] = i+1
            b[i] = N-i
        
        for i in range(M):
            print(a[i], b[i])
    else:
        for i in range(M):
            a[i] = i+1
            b[i] = N-i
        b[-1] -= 1
        
        for i in range(M):
            print(a[i], b[i])


main()

Submission status: Wrong Answer

Solution code:
n, m = [int(x) for x in input().split()]
temp = n // 2
for i in range(m):
    print(temp - i, temp + 1 + i)

Submission status: Wrong Answer

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

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

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 = 0
        for i in range(M):
            while True:
                while A[t%N]:
                    t += 1
                A[t%N] = True
                if A[(t + i + 1)% N]  == False:
                    k = (t + i + 1)% N
                    break
                if A[N - 1 - i] == False:
                    k = (N - i - 1)
                    break
                A[t%N] = False
                t += 1
                continue
            A[k % N] = True
            print(t%N + 1, k%N + 1)

main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

halfPos = -(-N//2)

qPos = halfPos // 2

q3Pos = -(-(M - halfPos) // 2) + halfPos + 1

for m in range(1, M+1):
  if m % 2:
    print(qPos-m//2, qPos+m//2+1)
  else:
    print(q3Pos-m//2, q3Pos+m//2)

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,2*m-i+1)
else:
    p=[0,-1,-1,2]
    for i in range(m):
        print(i+1,n-i+p[i%4])

Submission status: Wrong Answer

Solution code:
import numpy as np
str = input()
lst = str.split()
n = int(lst[0])
m = int(lst[1])
lst = np.zeros((m,2),dtype=np.int64)
count = 0
for i in range(m):
    a = 1+count
    b = n-count
    count+=1
    print("{} {}".format(a,b))

Submission status: Wrong Answer

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

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())

if N % 2 == 0:
    print(1, N)
    d = N - 4
    for a in range(2, M + 1):
        b = a + d
        print(a, b)
        d -= 2
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  = map(int, input().split())

a = 1
b = N-1
step = 0
used = [False]*100000
for i in range(M):
    if N%2 == 0 and b-a == N/2-1:
        b = b-1
    # else:
    #     print("hi", N%2, b-a, N/2-1)
    
    print(a, b)
    
    a = a + 1
    b = b - 1
    
    
    # used[s] = True
    # used[s+b] = True

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

n, m = MAP()
mx = n + 1#m * 2 + 1
for i in range(1, m + 1):
    print(i, mx - i)

Submission status: Wrong Answer

Solution code:
n, m = [int(elem) for elem in input().split()]

lst = [i for i in range(1, n+1)]
if n % 2 == 0:
    if m % 2 == 0:
        cands = [(j, n-j+1) for j in range(1, m+1)]
    else:
        cands = [(n//2 - j, n//2 + j + 1) for j in range(m)]
else:
    if m % 2 == 0:
        cands = [(j, n-j) for j in range(1, m+1)]
    else:
        cands = [(n//2 - j, n//2 + j + 1) for j in range(m)]
for cand in cands:
    print(cand[0], cand[1])

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
if n%2 == 0:
    c = 1
    a = n//2
    b = n//2+1
    while c<=m:
        print(' '.join(map(str,[a,b])))
        c+=1
        a -= 1
        b += 1
elif n%2 ==1:
    c = 1
    a = (n-1)//2
    b = (n+1)//2
    while c<=m:
        print(' '.join(map(str,[a,b])))
        c+=1
        a -= 1
        b += 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-1)
else:
  for i in range(m-1):
    print(i+1,n-i-2)
  print(m,n-m-2)

Submission status: Wrong Answer

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

  for m in range(1, N+1, 2):
    M -= 1
    print(m, m+1)
    if M == 0:
        break
        
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
from bisect import *
from collections import *

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, M = map(int, read().split())
l = M
checked = []
for i in range(1, M + 1):
    r = l + 2 * i - 1
    acc_ = r - l - 1
    acc = min(acc_, N - 2 - acc_)
    if acc in checked:
        r += 1
        acc -= 1
    checked.append(acc)
    print(l, r)
    l -= 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):
        print(i+1,n-m+1+i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8


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

    a, b = [None] * M, [None] * M
    if N % 2 == 2:
        for i in range(M):
            a[i] = i+1
            b[i] = N-i
        
        for i in range(M):
            print(a[i], b[i])
    else:
        for i in range(M):
            a[i] = i+1
            b[i] = N-i
        b[-1] -= 1
        
        for i in range(M):
            print(a[i], b[i])


main()

Submission status: Wrong Answer

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

    left = 1
    right = 2
    for i in range(M):
        print(left, right)
        if i % 2 == 0:
            left += 2
            right += 3
        else:
            left += 1
            right += 2


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
h=n-m*2
a=[i for i in range(1,m+1)]
b=[m+i for i in reversed(range(1,m+1))]
if h%2==0:
	tmp=b[0]
	for i in range(m):
		b[i]-=1
	b[m-1]=tmp
for i in range(m):
	print(a[i],b[i])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    if m == 1:
        print('2 3')
        exit()

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:


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


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    # 1, 2, 3, 4, 5
    # _ _ _ x _ _ y
    #       4     9
    # _ _ _ y _ _ x
    N, M = read_ints()
    a, b = [], []
    for i in range(M, 0, -1):
        print(i, M+(M-i+1))


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

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

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):
		print2Num(i*2-1,i*2)
else:	
	for i in range(1,M+1):
		print2Num(i,M*2-i+1)

Submission status: Wrong Answer

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

n,m = map(int,input().split())
used = [True]*(n+1)
d = [True]*(n+1)
res = []
mi = 1

dis = 0

ctr = 1

while len(res) < m:
    pt1 = 1 + dis
    pt2 = n - dis
    dd = abs(pt1 - pt2)
    if not d[dd]:
        continue


    d[dd] = d[n-dd] = used[pt1] = used[pt2] = False

    dis += 1
    res.append((pt1,pt2))



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

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())
p=2*m+1
for i in range(2,m+1):
  print(i,p-i)
if n%2==0:
  print(1,p)
else:
  print(1,p-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = [int(i) for i in input().split()]

if n % 2 == 1:
  a=1
  b=2*m

  for _ in range(m):
    print(a, b)
    a += 1
    b -= 1
else:
  a = 1
  th = n-1
  count = 0
  half = n//2
  while True:
    if th <= half:
      th -= 1
    count += 1
    print(a, a+th)
    a += 1
    th -= 2
    if count == m:
      break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
MOD = 10 ** 9 + 7
INF = 10 ** 11
import sys
sys.setrecursionlimit(100000000)

def main():
    n,m = map(int,input().split())
    ans = []
    ans = [[0]*2 for _ in range(m)]
    cnt = 1
    for i in range(m):
        ans[i][0] = cnt
        cnt += 1
    for i in range(m - 1,-1,-1):
        ans[i][1] = cnt
        cnt += 1
    for i in range(m):
        print(*ans[i])
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

n, m = map(int, input().split())
a, b = 1, n
for _ 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!=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-1):
                print((N//2)-i+3,(N//2)+i+4)
            print(1,3)
        else:
            print(1,2)