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:
#!/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:
        cnt = 0
        for dist in range(min(m, math.ceil((n-2)/4))):
            cnt += 1
            print(f"{L[dist]} {L[-1-dist]}")
        for dist in range(m - cnt):
            print(f"{L[dist]} {L[-2-dist]}")



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
matches = []
for i in range(1, M + 1):
    if i <= N // 4: matches.append((i, N-i))
    else:
        if N % 2 == 0: matches.append((i, N-i-1))
        else: matches.append((i, N-i))
for a, b in matches:
    print(a, b)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
used = [False] * 200100
#print(n,m)
for i in range(1, m+1):
    for j in range(n):
        if used[j] is False and used[(j+i) % n] is False:
            print(j+1, j+i+1)
            used[j] = True
            used[(j + i) % n] = True
            break

Submission status: Wrong Answer

Solution code:


n, m = [0] * 2

def format_input(filename = None):
	global n, m
	if filename == None:
		n, m = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		n = rng(3, 10**5)
		m = rng(1, (n-1) // 2)
		print(n, m)

def get_answer():
	median = n // 2

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


if __name__ == '__main__':
	format_input()

	get_answer()

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

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 += 1
        l %= N
    while k in step:
        k += 1
    r = l + k
    r %= N
    if r > l:
        l, r = r, l

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sup_n = m * 2 + 1
odd_start = sup_n // 4+1
even_start = ((sup_n - 1) // 2) * 2 - 1
print(odd_start, odd_start + 1)
odd_start -= 1
for i in range(1, m):
    if i % 2 == 1:
        print(odd_start, odd_start + i + 2)
    else:
        print(even_start, even_start + i)

Submission status: Wrong Answer

Solution code:
def solve(n, m):
    cur = n / 2 - 1
    vs = range(1, m + 1, 2) + range(2, m + 1, 2)
    res = []
    for v in vs:
        a = cur
        if v % 2 == 1:
            b = (cur + v) % n
        else:
            b = (cur - v + n) % n
        res.append([a + 1, b + 1])
        cur -= 1
    return res



solve(6, 2)
solve(7, 3)
solve(12, 5)

for i in xrange(100):
    for j in xrange(1, (i - 1) / 2 + 1):
        # print i, j
        solve(i, j)

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

assert m * 2 + 1 <= n

for a, b in solve(n, m):
    print a, b

Submission status: Wrong Answer

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

if n%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:
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
        if dd == n-dd:
            continue

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

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



    for a,b in res:
        if a > b:
            a,b = b,a
        print(a,b)

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 i in d:
            print(i,N-i)
        else:
            print(i,N-i+1)
            d.append(N//2-i+1)

Submission status: Wrong Answer

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

unit = N // (2*M)
ans = [(i*unit, (2*M-(i-1))*unit) for i in range(1, 1+M)]
for l in ans:
  print(*l)

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,i+M)
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):
    j = i // 2
    if i % 2 != 0:
        print(j+1, M-j)
    else:
        print(M+j, 2*M+1-j)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


if n%2==1:
  for i in range(0,m):
    print(i+1,m-i)
else:
  lis1=[]
  lis2=[]
  for i in range(1,m+1):
    lis1.append(i)
    lis2.append(2*m+1-i)
  for k in range(0,len(lis1)):
    if k%2==1:
      print(lis1[k],lis2[-1-k])
    else:
      print(lis1[k],lis2[k])

Submission status: Wrong Answer

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

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

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

for i in ans:
    print(' '.join(map(str, i)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10000000)


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




if __name__ == '__main__':
    main()

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 g==N) and s!=1:
            s-=1
        else:
            g+=1
        tcount+=1

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10000000)


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




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = 1
b = n
count = 0
ans_list= [b-a]

if n % 2 == 1:
  for i in range(m):
    print(a, b)
    a += 1
    b -= 1
else:
  while count < m:
    if b - a == n // 2:
      a += 1
    elif ans_list.count(b - a) != 0:
      a += 1
    else:
      print(a, b)
      count += 1
      a += 1
      b -= 1
      ans_list.append(b - a)

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:
        cnt = 0
        for dist in range(min(m, n//2)):
            cnt += 1
            print(f"{L[dist]} {L[-1-dist]}")
        for dist in range(m - cnt):
            print(f"{L[dist]} {L[-2-dist]}")



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


if n%2==1:
  for i in range(0,m):
    print(i+1,m-i)
else:
  lis1=[]
  lis2=[]
  for i in range(1,m+1):
    lis1.append(i)
    lis2.append(2*m+1-i)
  for k in range(0,len(lis1)):
    if k%2==0:
      print(lis1[k],lis2[-1-k])
    else:
      print(lis1[k],lis2[k])

Submission status: Wrong Answer

Solution code:
import sys
import os

def file_input():
    f = open('../Beginner_Contest_165/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    # input()
    N,M=map(int, input().split())
    cen=int(N/2)
    ans=[]
    for i in range(M):
        ans.append([cen-i,cen+1+i])
    [print(str(i[0])+" "+str(i[1])) for i in ans]

if __name__ == '__main__':
    main()

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

Submission status: Wrong Answer

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

l = [i for i in range(1,n+1)]
for i in range(m):
    print(l[i], l[-(i+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 or g==N:
            s-=1
        else:
            g+=1
        tcount+=1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
Ans = [[0, 0] for i in range(M)]
if N % 2 == 1:
    for i in range(M):
        Ans[i] = [i + 1, N - i - 1]
        print(Ans[i][0], end=" ")
        print(Ans[i][1])
else:
    if M <= N // 2 // 2:
        for i in range(M):
            Ans[i] = [i + 1, N - i]
            print(Ans[i][0], end=" ")
            print(Ans[i][1])
    else:
        for i in range(N // 2 // 2):
            Ans[i] = [i + 1, N - i - 1]
            print(Ans[i][0], end=" ")
            print(Ans[i][1])
        for i in range(M - N // 2 // 2):
            Ans[i + N//2//2] = [N // 2 // 2 + 1 + i, (N // 2 // 2 + 1 + i + (1+i) * 2) % N]
            print(Ans[i][0], end=' ')
            print(Ans[i][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,2*m-i)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
c=[[i+1,a//2*2-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 math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M = LI()
    used = [0 for _ in range(N)]
    cur = 0
    pairs = []
    if N % 2 == 1:
        a = 1
        b = N - 1
        while len(pairs) < M:
            pairs.append((a, b))
            a += 1
            b -= 1

    else:
        a = 1
        b = N-1
        while len(pairs) < M:
            pairs.append((a, b))
            a += 1
            b -= 1

    for p in pairs:
        print(p[0]+1, p[1]+1)



main()

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 and s!=1:
            s-=1
        else:
            g+=1
        tcount+=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:    
        if(p2>N):p2=1
        if(p1==0):p1=N
        print(p1,p2)
        p1-=1
        p2+=1
        M-=1

Submission status: Wrong Answer

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

ans = []
done = 0
i = 1
while done < m and i < n-i+1:
	a, b = i, n-i+1
	diff1 = b - a
	diff2 = a - b + n
	if diff1 == diff2:
		pass
	else:
		ans.append((a, b))
		done += 1
	i += 1

if done < m:
	done = 0
	ans = []
	i = 1
	while done < m and i < n-i+1:
		a, b = i, n-i
		diff1 = b - a
		diff2 = a - b + n
		if diff1 == diff2:
			pass
		else:
			ans.append((a, b))
			done += 1
		i += 1
# print(ans)
for item in ans:
	print(item[0], item[1])

Submission status: Wrong Answer

Solution code:
import heapq
N,M = map(int,input().split())
def f(n):
    if n%N==0:
        return N
    else:
        return n%N

if N%2==1:
    for i in range(M):
        print(i+1,N-i-1)
else:
    used=set()
    for d in range(1,M+1):
        for start in range(N):
            dest = f(start +d)
            if start in used or dest in used:
                continue
            else:
                print(start,dest)
                used.add(start)
                used.add(dest)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
l=[]
for i in range(n):
  l.append(i+1)
j=1
import heapq
heapq.heapify(l)
s=set([])
for i in range(n):
  x=heapq.heappop(l)
  if x in s or x+j in s:pass
  else:
    print(x,x+j)
    s.add(x)
    s.add(x+j)
    j+=1
    m-=1
  if m<1:break

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

Submission status: Wrong Answer

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

    def chk(x):
        dist = set()
        for a, b in x:
            d1 = abs(b-a)
            d2 = N-d1
            if d1 == d2:
                return False
            if d1 in dist or d2 in dist:
                return False
            dist.add(d1)
            dist.add(d2)
        return True

    ans = []
    done = set()
    dist = set()
    d = 1
    for i in range(N//2-1,-1,-1):
        while True:
            if i not in done and (i+d) not in done:
                ans.append([i,i+d])
                done.add(i)
                done.add(i+d)
                dist.add(d)
                dist.add(N-d)
                break
            d += 1
            if d >= N:
                d = 1
        if len(ans) == M:
            break
    if chk(ans):
        for a, b in ans:
            print(a+1, b+1)
        return
    else:
        print("dame")
        return
main()

Submission status: Wrong Answer

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

ans=[]
if N%2==1:
    for i in range(M):
        ans.append([i,N-1-i])

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

for i in ans:
    print(' '.join(map(str, ans)))

Submission status: Wrong Answer

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

count = 1
list = []
diffs = []
while True:
    if count >= N - count:
        break
    if count > M:
        break
    if count == 1:
        diff = 1
    else:
        diff = max(diffs) + 1
        while True:
            if not(diffs.__contains__(N-diff)):
                break
            diff += 1
    diffs.append(diff)
    count += 1
    print(diff, N-diff)

Submission status: Wrong Answer

Solution code:
from sys import stdin


def input():
    return stdin.readline().strip()


def main():
    N, M = map(int, input().split())
    left1 = 1
    left2 = (N + 1) // 2 + 1
    for i in range(M, 0, -1):
        if i % 2 == 1:
            print(left1, left1 + i)
            left1 += 1
        else:
            print(left2, left2 + i)
            left2 += 1


if __name__ == "__main__":
    main()