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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if a%2==0:


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

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

Submission status: Wrong Answer

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

else:
    d = list(range(1, n+1))
    from collections import deque
    d = deque(d)
    ans = [0]*m
    for i in range(m):
        a = d.popleft()
        b = d.pop()
        if b-a == n//2:
            a = d.popleft()
        ans[i] = (a, b)
    for i in range(m):
        print(*ans[i])

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
k=0
if n%2==1:
  for i in range(m):
    print(i+1,end=" ")
    print(n-i)
else:
  for i in range((n+2)//4):
    if k>=m:
      break
    print(i+1,end=" ")
    print(n-i)
    k+=1
  for i in range((n+2)//4,n//2):
    if k>=m:
      break
    print(i+1,end=" ")
    print(n-i-1)
    k+=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) % N

Submission status: Wrong Answer

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

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

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

else:

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

Submission status: Wrong Answer

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

t = set()
for i in range(1, M + 1):
    for j in range(1, N + 1):
        if j in t:
            continue
        k = j + i
        if k > N:
            k -= N
        if k in t:
            continue
        if k == j:
            continue
        break
    if j < k:
        print(j, k)
    else:
        print(k, j)
    t.add(j)
    t.add(k)

Submission status: Wrong Answer

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


for a in Ans:
  print(*a)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from collections import deque

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

lis = deque([i for i in range(1,N+1)])

for i in range(M//2):
    a = lis.popleft()
    b = lis.pop()
    print(a,b)
if N % 2 == 0:
    lis.pop()
for i in range(M//2,M):
    a = lis.popleft()
    b = lis.pop()
    print(a,b)

Submission status: Wrong Answer

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

n, m = [int(x) for x in input().split()]

if n % 2 == 1:
    left = n // 2
    right = left + 1

    ans = [[left, right]]

    for i in range(m - 1):
        left -= 1
        right += 1
        ans.append([left, right])

    for j in ans:
        print(*j)
else:
    left = n // 2
    right = left
    left -= 1
    right += 1

    ans = [[left, right]]

    for i in range(m - 1):
        left -= 1
        right += 1
        ans.append([left, right])

    for j in ans:
        print(*j)

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 d == 0:
        continue
    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())
i=1
if M==1:
    print(i,i+1)
else:
    if N%2==1:
        for _ in range(M):
            print(i,N-i+1)
            i+=1
    else:
        for _ in range(M):
            print(i,N-i)
            i+=1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

abc165_e()

Submission status: Wrong Answer

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

a = list(range(1,m+1))
b = list(range(2*m,m,-1))

for i in range(m):
  k = b[i]-a[i]
  l = b[i]+k
  h = l-n
  if a[i]==h:
    b[i]=2*m+1
  print(a[i],b[i])

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = list(range(1,M+1))
B = reversed(list(range(N+1-M,N+1)))
if N!=4 and N%2==0:
    A[-1] += 1
for a,b in zip(A,B):
    print(a,b)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
if m%2==0:
    print("{} {}".format(n,n-1))
    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:
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()
if N % 2 != 0:
    for i in range(1, M + 1):
        print(i, 2 * M - i + 1)
else:
    print(2, 1)
    for i in range(3, M + 2):
        print(i, 2 * M - i + 3)

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)
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())	
i = 0
i_center = (M+1)//2
for i in range((M+1)//2):
    print(i_center - i , end=" ")
    print(i_center + i + 1)
j_left = 2*i_center + 1 
for j in range(M//2):
    print(j_left + M//2 - j , end=" ")
    print(j_left + 2*j + 2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if n%2==0 and m%2==0:
    for i in range(m//2):
        l=n//2-(m-1)+i
        r=n//2+m-i
        print(str(l)+" "+str(r))
    for j in range(m//2):
        l=n//2-(m-1)+j
        r=n//2+m-j+1
        print(str(l)+" "+str(r))
elif n%2!=0 and m%2==0:
    for i in range(m//2):
        l=(n-1)//2-(m-1)+i
        r=(n+1)//2+(m-1)-i
        print(str(l)+" "+str(r))
    for i in range(m//2):
        l=(n-1)//2-(m-1)+i
        r=(n+1)//2+(m-1)-i+1
        print(str(l)+" "+str(r))
elif n%2==0 and m%2!=0:
    for i in range((m-1)//2):
        l=n//2-(m-1)+i
        r=n//2+m-i
        print(str(l)+" "+str(r))
    for j in range((m-1)//2+1):
        l=n//2-(m-1)+j
        r=n//2+m-j+1
else:
    for i in range((m-1)//2):
        l=(n-1)//2-(m-1)+i
        r=(n+1)//2+(m-1)-i
        print(str(l)+" "+str(r))
    for i in range((m-1)//2+1):
        l=(n-1)//2-(m-1)+i
        r=(n+1)//2+(m-1)-i+1
        print(str(l)+" "+str(r))

Submission status: Wrong Answer

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

n,m = na()

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

Submission status: Wrong Answer

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#E
import sys
import math
import itertools 
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
    
N,M=nm()
list1=[i+1 for i in range(N)]
for i in range(2):
    list1+=list1
poplist=[]

for i in range(1,N):
    for j in range(N):
        if(not(list1[j+i] in poplist) and not(list1[j] in poplist)):
            poplist.append(list1[j+i])
            poplist.append(list1[j])
            print(list1[j],list1[j+i])
            break

Submission status: Wrong Answer

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

if n%2:
    for i in range(m):
        print('{} {}'.format(i+1, n-i))
else:
    for i in range(m):
        print('{} {}'.format(i+1, n))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
count=0
i=1
j=N
while(1):
	if count==M:
		exit()
	else:
		if j-i!=i+N-j:
			print(i,j)
			i+=1
			j-=1
			count+=1
		else:
			i+=1

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
a,b=N//2,N//2+1
li=[[] for i in range(M)]
space=N-2*M
for i in range(M):
    li[i].append(i+1)
c=M+(N-2*M)+1
for i in reversed(range(M)):
    li[i].append(c)
    c+=1
for i in range(M):
    print(*li[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(i,N-i+1)
else:
    d = []
    for i in range(1,M+1):
        if N//2-i-1 in d:
            print(i,N-i)
        else:
            print(i,N-i+1)
            d.append(i)

Submission status: Wrong Answer

Solution code:
num = list(map(int, input().split()))
half = int(num[0]/2)
for i in range(num[1]):
  list1 = [ half-i, half+(i+1)]
  print(' '.join(map(str, list1)))

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)

Submission status: Wrong Answer

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

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

dis = 0

ctr = 1
if n%2 == 1:

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


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

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



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

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


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

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



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

Submission status: Wrong Answer

Solution code:
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 // 2:
    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:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()
ue = (n//2) *2
if n%2 != 0:
    for i in range(m):
        print(i+1,ue)
        ue -= 1

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

Submission status: Wrong Answer

Solution code:
def resolve():
    n, m = map(int, input().split())
    ans = []
    diff = 1
    used = [0]*(n+1)
    if n % 2 == 1:
        n = n-1
    for i in range(m):
        ans = [i+1, n-i+1]
        i += 1
        print(" ".join(map(str, ans)))
resolve()

Submission status: Wrong Answer

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

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

aa = n//2
bb = aa+1

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
t = 0
gap = 0
A = []
for i in range(1, n+1):
    if t == m:
        break
    for j in range(i+1+gap, n+1):
        # print(i, j)
        # t += 1
        if gap == 0:
            print(i, j)
            gap += 1
            A.append(i)
            A.append(j)
            break
        elif n % abs(i - j) != 0 and i not in A and j not in A:
            print(i, j)
            gap = abs(i - j)
            t += 1
            break

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)
        count += 1
        if count == m:
            break;

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = [int(i) for i in input().split()]
if M % 2:
    for i in range(M):
        print(1+i, N-i)
else:
    j=M+1
    m=N/2
    for i in range(M,0,-1):
        if j - i == m:
            j+=1
        print(i,j)
        j+=1

Submission status: Wrong Answer

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


if((4*m-2)!=n):
    a=1
    b=n
    for i in range(m):
        print(a,b)
        a+=1
        b-=1

else:
    a=1
    b=n
    sa=[]
    usiro=m//2
    mae=usiro
    if(m%2==1):
        usiro+=1
    for i in range(mae):
        sa.append(n-i*2-1)
    for i in range(usiro):
        sa.append((usiro-i)*2)
    for i in range(m):
        gosha=n-i
        print(gosha-sa[i],gosha)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N%2==0:
    a=1
    b=N

else:
    a=1
    b=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 == 0:
    for i in range(2,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=list(map(int, input().split()))
l1 = [i for i in range(m)]
l2 = [n-i-1 for i in range(m)]
for a,b in zip(l1,l2):
    print(a+1,b+1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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


def solve(N: int, M: int):
    if N % 2 == 1:
        for i in range(M):
            print(i+1,2*M-i)
    else:
        for i in range(M):
            print(2*i+1,2*(M-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:
N, M = map(int, input().split())
seen = [False] * (N + 1)
for i in range(M):
    if(N % 2): print(i + 1, N - i)
    else:
        l, r = i + 1, N - 1
        if(seen[r - l + 1] == False):
            print(i + 1, (N - i))
            seen[r - l + 1], seen[N - r + 1 + l] = True, True
        else: print(i + 1, N // 2)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
l = N
r = 1
for i in range(M):
    if N%4==0 and i*2==N: r+=1
    if 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())
i=1
if M==1:
    print(i,i+1)
else:
    if N%2==1:
        for _ in range(M):
            print(i,N-i)
            i+=1
    else:
        for _ in range(M):
            print(i,N-i+1)
            i+=1

Submission status: Wrong Answer

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

ans = []

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

Submission status: Wrong Answer

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

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

elif n % 2 == 1:
    for i in range(1, m + 1):
        a_i = str(i)
        b_i = str(n - i)
        
        print(a_i + " " + b_i)

Submission status: Wrong Answer

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


n, m = inpl()
ans = []
j = 2
new_m=m
for i in range(m):
    print("{} {}".format(new_m, new_m + j -1))
    new_m-=1
    j+=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-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:
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline

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

Submission status: Wrong Answer

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

for i in range(M):
    for j in lst[i]:
        print(j, end=" ")
    print()

Submission status: Wrong Answer

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

abc165_e()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, m  = map(int, input().split())
a = (n - 1) // 2
d = 1
memo = set([])
for i in range(m):
    if n - d in memo:
        d += 1
    memo.add(d)
    print(a, a+d)
    a -= 1
    d += 2

Submission status: Wrong Answer

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

a = 1
b = N

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
x = 1
y = n
z = set()

if n % 2 == 0:
    for i in range(m):
        print(x, x + i + 1)
        z.add(x)
        z.add(x + i + 1)
        while x in z:
            x += 1
else:
    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:
    for i in range(M):
        print(i+1,N-i)
else: #こっちに問題あり
    for i in range(M):
        print(i+1,N-i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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

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

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
import math
import itertools
from collections import defaultdict
from collections import Counter
import numpy as np

import heapq
a,b=list(map(int,input().split()))
for i in range(b):
    print(i+1,a-i)

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:
#!/usr/bin/env python3
import sys


def solve(N: int, M: int):
    left = 1
    right = N-1
    count = 0
    if N%2 == 0:
        while count < M:
            if right-left == N//2:
                left += 1
                right -= 1
                continue
            print(left,right)
            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()