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 == 0:
    S = set()
    for i in range(m):
        a = i
        b = n - i - 1
        if b - a in S or a - b + n in S:
            b -= 1
        S.add(b - a)
        S.add(a - b + n)
        print(a + 1, b + 1)
else:
    for i in range(m):
        print(i + 1, m * 2 - 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:
    a = 0
    b = ((n-1)//2)//2
    for i in range(m):
        if i > b:
            a = 1
        print(i+1, n-i-a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, M = iim()

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

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


for i in range(m):
    print(f"{i+1} {n-i}")

Submission status: Wrong Answer

Solution code:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,m = inpm()
    ans = []
    if m%2 == 0:
        for i in range(m):
            print(i+1,n-i)
            return
    dic = defaultdict(int)
    dic1 = defaultdict(int)
    for i in range(m):
        if i == 0:
            ans.append([1,n])
            dic[1] += 1
            dic[n] += 1
            dic1[n-2] += 1
            dic1[0] += 1
        elif i == 1:
            ans.append([2,n-2])
            dic[2] += 1
            dic[n-2] += 1
            dic1[n-5] += 1
            dic1[3] += 1
        elif i%2 == 0:
            dic[ans[-1][0]+2] += 1
            dic[ans[-1][1]+1] += 1
            num = ans[-1][1]+1 - ans[-1][0]-2 -1
            dic1[ num] += 1
            dic1[n-2-num] += 1
            ans.append([ans[-1][0]+2,ans[-1][1]+1])
        else:
            dic[ans[-1][0]-1] += 1
            dic[ans[-1][1]-2] += 1
            num = ans[-1][1]+1 - ans[-1][0]-2 -1
            dic1[ num] += 1
            dic1[n-2-num] += 1
            ans.append([ans[-1][0]-1,ans[-1][1]-2])
    for i in range(len(ans)):
        print(*ans[i])

    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m=list(map(int,input().split()))

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

s = [[False] * n for _ in range(n)]

for i in range(n):
    for a, b in ans:
        a -= 1; b -= 1
        a += i; b += i
        a %= n; b %= n
        a, b = min(a, b), max(a, b) 
        assert not s[a][b]
        s[a][b] = True

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import deque
import heapq
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
x = 1
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())
if n%2 == 1:
    n -= 1
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):
    print(i, 2*M-i+1)

Submission status: Wrong Answer

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

p = 1
q = n

for _ in range(m):
  print(p, q)
  p = p+1
  q = q-1

Submission status: Wrong Answer

Solution code:
def solve():
    n,m = map(int,input().split())
    if n%2==0:
        n-=1
    for i in range(m):
        print(i+1,n-i)
if __name__=='__main__':
    solve()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# M個用意する対戦場の数字の差が異なるようにする
N, M = lr()
answer = [[0, 0] for _ in range(M)]
for i in range(M):
    answer[i][0] = i+1

cur = M+1
used = set()
for i in range(M-1, -1, -1):
    while cur - answer[i][0] in used:
        cur += 1
    answer[i][1] = cur
    diff = answer[i][1] - answer[i][0]
    used.add(diff)
    used.add(N-diff)
    cur += 1

for a in answer:
    print(*a)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
result = []
x = [i for i in range(1, 2*m+1)]
for i in range(m):
    result.append([x[i], x[-i-1]])
for j in result:
    print(*j)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#author: raghav_0901
from math import *

mod = (10**9) + 7


def _in():
    return [int(x) for x in input().split(' ')]


if __name__ == "__main__":
    n, m = _in()
    j = n // 2
    for i in range(0, m):
        print(j, j + (2 * i) + 1)
        j = j - 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
res = []
for k in range(1, M + 1):
  res.append((k, N + 1 - k))
for r in res: print(*r)

Submission status: Wrong Answer

Solution code:
def solve():
    n,m = map(int,input().split())
    if n%2==1:
        n-=1
    for i in range(m):
        print(i+1,n-i)
if __name__=='__main__':
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import ceil #切り上げ
import numpy as np
 
def inp(): return int(input()) #一個だけ読み取り
def inpm(): return map(int,input().split()) #mapオブジェクトで呼び出し
def inpl(): return list(map(int, input().split())) #数字リストをintで
def inpls(): return list(input().split()) #リストをstrで

N,M = inpl()

for i in range(1,M+1):
  if i == 1:
    print(str(1) + " " + str(N))
  else:
    print(str(i) + " " + str(i+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()
j_list = [1]
i=3
while len(j_list) < m:
    if n%i!=0:
        j_list.append(i)
    i += 2

for i in range(m):
    print("{} {}".format(i+1,i+j_list[-i-1]+1))

Submission status: Wrong Answer

Solution code:
inf = 10**15
mod = 10**9+7
n,m = map(int, input().split())
if n % 2 == 0:
    tmp = n//2
    for i in range(m):
        print('{} {}'.format(tmp-i, tmp+1+i))
else:
    tmp = n//2
    for i in range(m):
        print('{} {}'.format(tmp-i, tmp+1+i))

Submission status: Wrong Answer

Solution code:
n, m = [int(i) for i in 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,N-i+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
li=[x for x in range(1,n+1)]

st=n//2-1
print(li.pop(st),li.pop(st))
for i in range(m-1):
    if i%2==0:
        ex=len(li)//2
        print(li.pop(ex),li.pop(ex-2))
    else:
        ex=len(li)//2-1
        print(li.pop(ex),li.pop(ex+1))

Submission status: Wrong Answer

Solution code:
import sys
input=lambda: sys.stdin.readline().rstrip()
n,m=map(int,input().split())
Ans=[]
ct=0
flag=True
for i in range(1,n):
  if i!=1 and (n%i==0 and n//i==2):
    continue
  elif flag:
    Ans.append([1,i+1])
    ct+=1
    if ct==m:
      flag=False
for a in Ans:
  print(*a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
import sys
sys.setrecursionlimit(10**9)
# input=sys.stdin.readline
from collections import deque
import heapq
from itertools import combinations

n,m=map(int,input().split())
if n%2==1:
    for i in range(m):
        print(i+1,n-(i+1))
else:
    p=m//2
    for i in range(p):
        print(i+1,n-(i))
    for i in range(m-p):
        print(n//2-1-i,n//2+1+i)
# elif n%4==2:
#     print(1,n)
#     for i in range(m-1):
#         print(i+2,n-(i+2))
# elif n%4==0:
#     print(1,n)
#     if m==1:
#         exit()
#     print(2,n-1)
#     for i in range(m-2):
#         print(i+3,n-(i+2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = list(range(1, N+1))
i = 1
while (len(A) >1) and i<=M:
    print(A.pop(0), A.pop())
    i+=1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# E - Rotation Matching

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

if N%2==0:
    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:
#!/usr/bin/env python3
import sys
#sys.setrecursionlimit(150000)


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

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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



i = 1
if n%2 == 0:
    j = n-2
else:
    j = n-1


for _ in range(m):
    print(i,j)
    i+=1
    j-=1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


def solve(N: int, M: int):
    left = 1
    right = N if N%2 == 0 else N-1

    for _ in range(M):
        print(left,right)
        left += 1
        right -= 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:
def main():
    n, m = map(int, input().split())
    x, y = 1, n
    for _ in range(m):
        print(x, y)
        x += 1
        y -= 1

if __name__ == "__main__":
    main()

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:
import numpy as np
nm = input()
[n, m] = [int(comp) for comp in nm.split()]
if(n % 2 == 0):
  temp = [[int(n / 2) - key, (int(n / 2) + key)] for key in range(1, 1 + m)]
else:
  temp = [[int(n / 2) - key, int(n / 2) + 1 + key] for key in range(m)]
for i in range(m):
  print(temp[m - 1 - i][0], temp[m - 1 - i][1])

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:
	for i in range(m):
		b[i]+=1
for i in range(m):
	print(a[i],b[i])

Submission status: Wrong Answer

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

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



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

Submission status: Wrong Answer

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

else:
    for m in range(M):
        ans.append([i,N+1-i])
        i+= 1
        
    for a in ans:
        print(*a)

Submission status: Wrong Answer

Solution code:
# import numpy as np
# import queue
# import heapq


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

    ds = [2 * i + 1 for i in range(M)]
    ds.sort(reverse=True)

    for i in range(M):
        p = i + 1
        d = ds[i]
        print(p, p + d)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
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 fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    if(N&1):
        N+=1
        for i in range(M):
            print(i+1+1,N-i-2+1)
    else:
        used = set()
        for i in range(1,M+1):
            if(i<M/2):
                print(i,N-i+1)
            else:
                print(i,N-i)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

a = N//2
b = a+1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


def solve(N: int, M: int):
    for i in range(1, M+1):
        print("{0} {1}".format(i, 2 * M + 1 - i))
    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:
###
# main
if(__name__ == '__main__'):
    # input
    n, m = map(int, input().split(" "))

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

    # output
#    print(ans)
# else:
    # do nothing

Submission status: Wrong Answer

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

p = n // 2
q = n // 2 + 1

for _ in range(m):
  print(p, q)
  p = p-1
  q = q+1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = list(map(int,input().split()))
x = n//2
y = n//2+1

temp_used = [0] * (n+1)

for i in range(m):
    print("{x} {y}".format(x=x,y=y))
    temp_used[y-x]+=1
    temp_used[n+x-y]+=1
    x-=1
    y+=1
    if temp_used[y-x]==1 or temp_used[n+x-y]==1:
        y+=1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000)

def solve(N, M):
    used = set()
    used_k = set()
    i = 1
    ans = []
    k = 1
    for _ in range(1, M + 1):
        ans.append(str(i) + " " + str(i+k))
        used.add(i)
        used.add(i+k)

        used_k.add(k)
        used_k.add(N-k)
        while i in used:
            i += 1
        while k in used_k:
            k += 1
    return "\n".join(ans)
#
#
# for M in range(1, 5):
#     for N in range(M * 2 + 1, (M * 2 + 1) * 2):
#         print("==", M, N )
#         print(solve(N, M))

if __name__ == "__main__":
    N, M = tuple(map(int, input().split(" ")))
    print(solve(N, M))

Submission status: Wrong Answer

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

if n%2 == 0:
    s = n//2
    check = 1
else:
    s = (n-1)//2
    
cnt = 0

for i in range(m):
    tmp1 = s-cnt
    tmp2 = s+1+cnt
    
    if check == 1 and tmp2 - tmp1 == s:
        tmp1 = s-cnt
        cnt += 1
        tmp2 = s+1+cnt
        
    print(tmp1, tmp2)
    cnt += 1

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
ans = [[0,0]]*m
a = n//2
b = a+1
for i in range(m):
    ans[i] = [a,b]
    a -= 1
    b += 1
for i in range(m):
    print(*ans[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 i!=1 and n%i==0:
    continue
  elif flag:
    Ans.append([1,i+1])
    ct+=1
    if ct==m:
      flag=False
for a in Ans:
  print(*a)

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

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = list(range(1,M+1))
B = reversed(list(range(M+2,M+M+2)))
for a,b in zip(A,B):
    print(a,b)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    from collections import deque
    n, m = map(int, input().split())
    d = deque([i for i in range(n)])
    s = set()
    g = []
    i = 1
    cnt = 0
    while cnt < m:
        if n % 2 == 0 and n // 2 == i:
            i += 1
            continue
        l = []
        while True:
            j = deque.popleft(d)
            if j in s:
                continue
            if j+i in s:
                l.append(i)
                continue
            break
        print(j+1, j+i+1)
        for j in l[::-1]:
            deque.appendleft(d, j)
        s.add(j)
        s.add(j+i)
        g.append([j+1, j+i+1])
        i += 1
        cnt += 1


main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    if n % 2 == 1:
        e = n - 1
    else:
        e = n - 2

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


submit()

Submission status: Wrong Answer

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

usable = [True] * N
c = 0
for i in range(M):
    while not usable[c]:
        c += 1
    a, b = c, (c + i + 1) % N
    usable[a] = usable[b] = False
    print(a + 1, b + 1)

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

Solution code:
def solve():
    n,m = map(int,input().split())
    for i in range(m):
        print(i+1,n-i)
if __name__=='__main__':
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
ans=[[] for _ in range(n//2)]
if n%2==1:
  for i in range(1,k+1):
    ans[i-1].append(i)
  for i in range(1,k+1):
    ans[i-1].append(n-i+1)
  for i in range(k):
    print(*ans[i])
else:
  for i in range(1,k+1):
    ans[i-1].append(i)
  for i in range(1,k+1):
    if i<=k//2:
      ans[i-1].append(n-i+1)
    else:
      ans[i-1].append(n-i)
  for i in range(k):
    print(*ans[i])

Submission status: Wrong Answer

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

for i in range(1,M+1):
  if i >= N/4:
    print(f'{i+1} {N+1-i}')
  else:
    print(f'{i} {N+1-i}')

Submission status: Wrong Answer

Solution code:
i = list(map(int, input().split()))
k=int(i[0]/2)
for j in range(i[1]):
    print(k-j, k+1+j)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
flag = [False]*(10**6)
plu = 1
for i in range(1,N+1):
  if M==0:
    break
  if (flag[i])or(flag[i+plu]):
    continue
  else:
    flag[i]=True
    flag[i+plu]=True
    print(i,i+plu)
    plu+=1
    M-=1

Submission status: Wrong Answer

Solution code:
import numpy as np
nm = input()
[n, m] = [int(comp) for comp in nm.split()]
if(n % 2 == 0):
  temp = [[int(n / 2) - key, (int(n / 2) + key)] for key in range(1, 1 + m)]
else:
  temp = [[int(n / 2) - key, int(n / 2) + 1 + key] for key in range(m)]
print(temp)
for i in range(m):
  print(temp[i][0], temp[i][1])