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

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

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+1:
            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:
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
ans = [[1, 4], [2, 6], [3, 5]]
for i in range(1, m + 1):
    if i < 4:
        print(ans[i-1][0], ans[i-1][1])
    else:
        print(i, mx - i)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
for i in range(1, m + 1):
    if n % 2 == 0 and i == m + 1:
        print(i, n - i)
    else:
        print(i, n + 1 - 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),int(N/2+1+i))
	else:
		N = N - 1
		for i in range(M):
			print(int(N/2-i),int(N/2+1+i))
			
if __name__ == "__main__":
  main()
  pass

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
count=0
i=1
len=2
t=0
while(1):
	if count==M:
		exit()
	else:
		if N%(len)==0:
			len+=1
			if i+len>N:
				i+=1
				len=t+1
		else:
			print(i,i+len)
			count+=1
			i+=1
			t=len
			len+=1

Submission status: Wrong Answer

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

l = 0
r = 1
num = set()
step = set()
k = r - l
for i in range(M):
    print(l + 1, r + 1)
    num.add(l)
    num.add(r)
    step.add(k)
    step.add(N - k)
    while l in num:
        l = (l + 1) % N
    while k in step:
        k += 1
    r = l + k

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
l = []
for i in range(1,n,2):
    if i != n+1-i:
        l.append(i)
    if len(l)==m:
        break
for n,i in enumerate(l[::-1]):
    print(n+1,n+1+i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
j = 1
A = set()
i = 0
while i < M:
  a = j
  b = a+j
  j += 1
  while a in A or b  in A:
    a +=1
    b +=1
  print(a,b)
  A.add(a)
  A.add(b)
  i +=1

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
for i in range(M):
    print(str(i+1) + ' ' + str((2*M+1)-i-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:
    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))

Submission status: Wrong Answer

Solution code:
com = list(map(int,input().split()))
N = com[0]
M = com[1]

 
for i in range(M):
    s = f'{i+1} {N-i-1}'
    print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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 and M % 2 == 1:
    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:
n, m = map(int, input().split())

nl = [i for i in range(1, n+1)]

if n%2 == 0 and m%2 == 0:
    if n == 2*m + 2:
        print(1, n)
        left = 1
        right = n-3
        for _ in range(m-1):
            print(left, right)
            left += 1 
            right -= 1
    else:
        left = (n-2)/2
        right = (n-2)/2 + 1
        for _ in range(m):
            print(left, right)
            left -= 1
            right += 1
else:
    left = 0
    right = n-1
    for _ in range(m):
        print(nl[left], nl[right])
        left += 1
        right -= 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):
            print(t, k)
            t += 1
            k -= 1

main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
import math
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
N,M = map(int,input().split())
if N % 2 == 1:
    for i in range(1,M+1):
        print(i,N-i)
else:
    print(1,N)
    if M != 1:
        for i in range(1,M):
            print(i+1,N-i)

Submission status: Wrong Answer

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

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

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

if N % 2 == 0 and M * 2 >= N:
    for m in range(1, M + 1):
        print(m, 2 * M - m + 2)
    exit()

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

Submission status: Wrong Answer

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

ans = []
temp = n // 2
for i in range(m):
    a = temp - i
    b = temp + 1 + i
    ans.append("{} {}".format(a,b))

for j in ans:
    print(j)

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 sys
input = sys.stdin.readline
def main():
    n,m = map(int,input().split())
    ans = [[n//2,n//2+1]]
    for _ in range(m-1):
        v = ans[-1]
        new = [v[0]-2,v[1]+2]
        if new[0] == 0:
            new[0] = n
        if new[1] > n:
            new[1] = 1
        ans.append(new)
    for a in ans:
        print(*a)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,m = map(lambda x:int(x),input().split())
if n%2==1 or (n/2)%2==0:
  for i in range(m):
    print(str(i+1) + " " + str(2*m-i))
else:
  for i in range(m):
    print(str(i+1) + " " + str(2*m-i+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):
		print2Num(i,M*2-i+1+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())

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

Submission status: Wrong Answer

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

highest = n // 2 * 2
for i in range(0, m, 2):
    print("{0} {1}".format(1 + i // 2, highest - i // 2))
    if i + 1 < m:
        print("{0} {1}".format(n // 2 - i // 2, n // 2 + 1 + i // 2))

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(a+i,b+i)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
ans = [
    i+1 + i+1 if 2*i + 2 > m else i+1 + n - i - 1
    for i in range(m)
]
for i, v in enumerate(ans):
    print(i+1, v)

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:
from collections import deque
N, M = map(int, input().split())

que = deque(list(i for i in range(1, N + 1)))
ans_list = []

for i in range(M):
    a = que.popleft()
    b = que.pop()
    ans_list.append((a, b))

for ans in ans_list:
    print(*ans)

Submission status: Wrong Answer

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

cnt1 = M+1
cnt2 = M
for i in range(M):
    cnt1-=1
    cnt2+=1
    if N+2*cnt1-2*cnt2==0:
        cnt2 += 1
    print(cnt1,cnt2)

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:
    l=[]
    for i in range(n//2):
        if i*2+1!=n//2:
            l.append(i)
    for j in range(m):
        print(n//2-l[j],n//2+1+l[j])

Submission status: Wrong Answer

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

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

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,n-i-1)

Submission status: Wrong Answer

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

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

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 -= 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 = 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:
    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:
a,b=map(int,input().split())
c=[[i+1,a-i] for i in range(a//2)]

c=c[-b:]
for i in c:
    print(" ".join(map(str,i)))

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
for i in range(1,n):
  if ((n-i+1)-i)*2==n:
    continue
  elif flag:
    Ans.append([i,n-i+1])
    ct+=1
    if ct==m:
      flag=False


for a in Ans:
  print(*a)

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):
        p1-=1
    else:    
        print(p1,p2)
        p1-=1
        p2+=1
        M-=1

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split(" "))
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

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

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

if N % 2 == 0 and M * 2 >= N:
    for m in range(1, M + 1):
        print(m, 2 * M - m + 1)
    exit()

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N,M= list(map(int , input().split()))
k = N//2
s = N %2
if s == 1:
    for i in range (M):
        n = i+1
        print (n,N-n)
elif s == 0:
    w = 0
    n = 1
    for i in range (M):
        print (n,n + i + 1)
        n = n + 2 + i

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
ans = []
for i in range(m):
    ans.append([i+1, n - i])
    
if n % 2 == 0:
    for i in range(len(ans) // 3):
        ans[i*3][1], ans[i*3+1][1], ans[i*3+2][1] = ans[i*3+1][1], ans[i*3+2][1], ans[i*3][1]

for line in ans:
    print(*line)

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = list(map(int, readline().split()))

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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 = [False] * (N + 10)
for i in range(1, M + 1):
    r = l + 2 * i - 1
    acc_ = r - l - 1
    acc = min(acc_, N - 2 - acc_)
    if checked[acc]:
        r += 1
        acc -= 1
    checked[acc] = True
    print(l, r)
    l -= 1

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 and n_list[ans_j-1]:
        ans_j -= 2
    if n_list[ans_i+2] == 0 and n_list[ans_i+1]:
        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
    
    while n_list[ans_i]:
        ans_i -= 1
    while n_list[ans_j]:
        ans_j += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
inpl = lambda: list(map(int,input().split()))
N, M = inpl()
if N % 2:
    for k in range(1,M+1):
        print(k, 2*k)
elif M % 2 == 0:
    m = M // 2
    n = N // 2
    h = 0
    for k in range(m):
        if 4*m - 2*k == n:
            h += 1
        else:
            print(k+1, 4*m+1-k)
    for k in range(m):
        if 2*m-1-2*k == n:
            h += 1
        else:
            print(m+1+k, 3*m-k)
    if h:
        print(4*m+2, N)
else:
    m = M // 2
    n = N // 2
    h = 0
    for k in range(m):
        if 4*m+2-2*k == n:
            h += 1
        else:
            print(k+1, 4*m+3-k)
    if 2*m + 1 == n:
        h += 1
    else:
        print(m+1, 3*m+2)
    for k in range(m):
        if 2*m - 1 - 2*k == n:
            h += 1
        else:
            print(m+2+k, 3*m+1-k)
    if h:
        print(4*m+4, N)

Submission status: Wrong Answer

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,m = iim()
if m == 1:
    print(1,2)
elif n%2 == 1:
    l = list(range(1,n//2+1))[::-1]
#    print(l)
    for i in l[:m]:
        print(i,n-i)
else:
    for i in range(1,m):
        print(i,n-i+1)
    print(m,n//2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def f(vs,i):
	# print(vs)
	for j in range(len(vs)):
		if vs[j]+i in vs:
			a = vs[j]
			b = vs[j]+i
			print(a,b)
			vs.remove(a)
			vs.remove(b)
			return

n,m = map(int,input().split())
vs = list(range(1,n+1))

for i in range(1,m+1):
	f(vs,i)

Submission status: Wrong Answer

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


def solve(N: int, M: int):
    left = 1
    right = N if N%2 == 0 else N-1
    count = 0
    if N%2 == 0:
        p = set()
        while count < M:
            if right-left == N//2 or N-(right-left) in p:
                left += 1
                right -= 1
                continue
            print(left,right)
            p.add(right-left)
            left += 1
            right -= 1
            count += 1
    else:
        while count < M:
            print(left,right)
            left += 1
            right -= 1
            count += 1
    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:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m=INTM()
    for i in range(m):
        print(i+1,m-i-1)
if __name__ == '__main__':
    do()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, m = mi()
    L = [i for i in range(1, n+1)]
    if n % 2 == 1:
        for dist in range(m):   
            print(f"{L[dist]} {L[-1-dist]}")
    else:
        for dist in range(m // 2):
            print(f"{L[dist]} {L[-1-dist]}")
        for dist in range(m // 2):
            print(f"{L[dist]} {L[-2-dist]}")



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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("{} {}".format(i, N-i))

else:
    for i in range(1, M+1):
        print("{} {}".format(i, N-i))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
h=0
t=1
a=[0]*N
for i in range(M):
  if (t+1)%N==0:
    print((h+1)%N,N)
  else:
    print((h+1)%N,(t+1)%N)
  a[h%N]=1
  a[t%N]=1
  for j in range(1,N):
    if a[(h+j)%N]==0 and a[(h+j+i+2)%N]==0:
      h=h+j
      t=h+i+2