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())
l = []
flg = False
for i in range(1,n):
    if flg:
        flg = False
        continue
    if i != n+1-i:
        l.append(i)
        if len(l)==m:
            break
        flg = True
        
for n,i in enumerate(l[::-1]):
    print(n+1,n+1+i)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from bisect import *
from collections import *

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

Submission status: Wrong Answer

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

a=N//2
b=a+1

for i in range(M):
    print("{} {}".format(a,b))
    a-=1
    b+=1

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())
ans = []
d = N
if N%2 == 1:
    N -= 1
for m in range(M):
    if N%2 == 0 and m+d-(m+1) == N//2:
        d += 1
    ans.append([m+1,m+d])
    d -= 2
for e in ans:
    print(*e)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

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


if __name__ == '__main__':
    main()

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
i = 0
count = 0
while i < int(N/2) and count < M:
    i += 1
    if N % 2 == 0:
        if i == N / 2:
            break
        print(f"{i+1} {N-i}")
    else:
        print(f"{i} {N-i}")
    count += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n, m = map(int, input().split())

s = 1
f = n
ans = []
d = defaultdict(lambda: False)
i = 0

used = []
while i < m:
    # print(s, f, i)
    tmp = abs(s - f)
    a, b = min(tmp, n - tmp), max(tmp, n - tmp)
    if d[a] or d[b]:
        f -= 1
        continue
    d[a] = True
    d[b] = True
    ans.append(f"{s} {f}")
    used.append(s)
    used.append(f)
    s += 1
    f -= 1
    i += 1
f = False
for i in used:
    if i <= 0 or n < i:
        f = True
if f:
    ans = []
    while i < m:
        # print(s, f, i)
        tmp = abs(s - f)
        a, b = min(tmp, n - tmp), max(tmp, n - tmp)
        if d[a] or d[b]:
            s += 1
            continue
        d[a] = True
        d[b] = True
        ans.append(f"{s} {f}")
        used.append(s)
        used.append(f)
        s += 1
        f -= 1
        i += 1

print("\n".join(ans))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
	N,M = map(int, input().split())
	ans = []

	l = N//2
	r = l+1


	for _ in range(M):
		print('{} {}'.format(l,r))
		l -= 1
		r += 1
		if r - l == N/2:
			l -= 1
			r += 1
		if l == 0:
			l = N
		if r == N+1:
			r = 1

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = list(map(int, range(1, n+1)))
if n%2 == 1:
    for i in range(m):
        print(a[i], a[-i-2])
else:
    for i in range(m):
        print(a[i], a[-i-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
        print(p1,p2)
        p1-=1
        p2+=1
        M-=1

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N, M = map(int, input().split())

if N % 4 == 0:
    for i in range(M):
        print("{} {}".format(N // 2 - 1 - i, N // 2 + 2 + i))
elif N % 2 == 0:
    for i in range(M+ 1):
        if i != N // 4:
            print("{} {}".format(N // 2 - i, N // 2 + 1 + i))
else:
    for i in range(M):
        print("{} {}".format(N // 2 - i, N // 2 + 2 + i))

Submission status: Wrong Answer

Solution code:
tmp = input().split()
N = int(tmp[0])
M = int(tmp[1])
#Q = int(tmp[2])
VS = [[[0]]*2]*M

for i in range(M):
    VS[i][0] = i+1;
    VS[i][1] = 2*M-i;

print(VS)

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+2)])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

n, m = map(int, input().split())
c = 0
f = [math.floor(n/2), math.floor(n/2) + 1]
if n % 2 == 0:
    while c < m:
        c += 1
        if c == math.ceil(n/4) + 1:
            if (f[1] + 1) % n == 0:
                f[1] = n
            else:
                f[1] = (f[1] + 1)
        print(str(f[0]) + ' ' + str(f[1]))
        if (f[0] - 1) % n == 0:
            f[0] = n
        else:
            f[0] = (f[0] - 1) % n
        if (f[1] + 1) % n == 0:
            f[1] = n
        else:
            f[1] = (f[1] + 1)
if n % 2 == 1:
    while c < m:
        c += 1
        print(str(f[0]) + ' ' + str(f[1]))
        if (f[0] - 1) % n == 0:
            f[0] = n
        else:
            f[0] = (f[0] - 1)
        if (f[1] + 1) % n == 0:
            f[1] = n
        else:
            f[1] = (f[1] + 1)

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:
#! python3

def main():
    n, m= map(int, input().split())
    count = 0
    ans = []
    if n % 2 == 1:
        for i in range (1,n):
            c = n-i
            ans.append(i)
            ans.append(c)
            count += 1
            if count == m:
                break

    else:
        for i in range(1,n):
            c = n + 1 - i
            ans.append(i)
            ans.append(c)
            count += 1
            if count == m:
                break

    size = 2

    for start in range(0, len(ans), size):
        print(ans[start: start + size])
main()

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

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

Submission status: Wrong Answer

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

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

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

else:
    a=1
    b=N-1

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

Submission status: Wrong Answer

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

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(0, 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())
if n%2==0:
  l=list(range(1,n+1))
  k=len(l)//2
  for i in range(m):
    print(l[k-i-1],l[k+i])
else:
  l=list(range(1,n+1))
  k=len(l)//2
  l.remove(l[k])
  for i in range(m):
    print(l[k-i-1],l[k+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 = n // 2
    print((a + 1) // 2, (a + 1) // 2 + a)
    for i in range(m - 1):
        print(i + 1, n - i)

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m=map(int, input().split())
num=0
l=[]
if n%2==0:
    num=n//m
else:
    num=(n//m)+1
for i in range(m):
    l.append(num)
    num=num-1
l.reverse()
for i in l:
    print(i,end=" ")
    print(n-i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
if n%2==1:
    for i in range(m):
        print(i+1, n-i-1)
else:
    if m==1:
        print(n-2, n-1)
        exit()
    i=0
    s=set()
    while True:
        if len(s)==m:
            break
        i+=1
        a=n-i
        b=i
        if a in s:
            continue
        else:
            print(a,b)
            s.add(b)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
from random import choice,randint
inp=sys.stdin.readline
out=sys.stdout.write
flsh=sys.stdout.flush
 
sys.setrecursionlimit(10**9)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def MI(): return map(int, inp().strip().split())
def LI(): return list(map(int, inp().strip().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]
def LI_(): return [int(x)-1 for x in inp().strip().split()]
def LF(): return [float(x) for x in inp().strip().split()]
def LS(): return inp().strip().split()
def I(): return int(inp().strip())
def F(): return float(inp().strip())
def S(): return inp().strip()
def pf(s): return out(s+'\n')
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def main():
    n,m=MI()
    l=[]
    x=(n//2)
    y=x+1
    l.append([x,y])
    for i in range(1,m):
        l.append([x-i,y+i])
    l.sort(key=lambda x: x[0])
    if n%2!=0:
        for i in range(m):
            print(*l[i])
    else:
        l.reverse()
        l.pop()
        l.append([1,n])
        l.reverse()
        for i in range(m):
            print(*l[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)
else:
    for i in range(m):
        if i == (n-1)//2-1:
            print(i+1, n-i-1)
        else:
            print(i + 1, n - i)

Submission status: Wrong Answer

Solution code:
import sys


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

    s = N // 2

    if (M*2+1) == N:
        s = s - 1

    t = s + 1

    S = []
    T = []

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

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

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

    

    return


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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import 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:
        if a > b:
            a,b = b,a
        print(a,b)

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 or i==n-i+1:
    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:
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
        for i in range(m):
            ans[i][1] = cnt
            cnt += 1
        for i in range(m):
            print(*ans[i])
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    from itertools import combinations
    n, m = map(int, input().split())
    if n % 2 == 1:
        l = n // 2
        a = 1
        b = 2 * l
        i = 0
        while i <m:
            i += 1
            print(a, b)
            a += 1
            b -= 1
    else:
        l = n // 2
        a = 2
        b = 2 * (l - 1) + 1
        i = 0
        while i < m:
            i += 1
            print(a, b)
            a += 1
            b -= 1


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

def resolve():
    n,m= map(int, input().split())
    if n % 2 == 1:
        [print(m-i+1,m+i)  for i in range(1,m+1)]
        return
    [print(m-i+1,m+1+i)  for i in range(1,m+1)]

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

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

x = range(1, n+1)
for i, j in enumerate(range(m)[::-1]):
    print(x[j], x[i+j+i+1])

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
N -= N % 2
n = 1
for m in range(M):
    print(n, n+1)
    n += 2
    # N -= 1

Submission status: Wrong Answer

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

num_1 = m
num_2 = m+1

for i in range(m):
    print(str(num_1) + " " + str(num_2))
    num_1 -= 1
    num_2 += 1

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 in ans:
            print(*a)
        return
    else:
        print("dame")
        return
main()

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:
  res.append((M - 1, M))
  for k in range(1, M):
    res.append((M - k + 1, M + k + 1))
for r in res: print(*r)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():

    N, M = map(int, input().split())
    if N % 2 == 1:
        lv = [[i, N-i] for i in range(1, M+1)]
    else:
        lv = [[i, M-i] for i in range(1, M//2+1)]
        lv += [[M+i, 2*M-i] for i in range(1, M//2+1)]

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


if __name__ == '__main__':
    main()
    # print(main())

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
for i in range(int(N/2)):
    print("{} {}".format(i,N-i))

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,a-j)

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

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):
    i+=(n+2)//4
    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())
check = []
flag = 0
if n%2 == 0:
    flag = 1

for i in range(1,n):
    tmp1 = i
    if flag == 1:
        tmp2 = n-i-1
    else:
        tmp2 = n-i
    
    if tmp1 == tmp2:
        continue
    
    if  flag == 1 and tmp2 - tmp1 == n//2:
        continue
    
    if tmp1 in check or tmp2 in check:
        continue
    
    check.append(tmp1)
    check.append(tmp2)
    
    if len(check) //2 == m:
        break
    
for i in range(0,m*2, 2):
    print(check[i], check[i+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):
    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())


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

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

Submission status: Wrong Answer

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

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 = 0
        b = N-2
        while len(pairs) < M:
            if len(pairs) == M-1:
                pairs.append((a, a+1))
                break
            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:
n, m = map(int, input().split())

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

for j in ans:
    print(j)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
i = 0
if n % 2:
    c = 0 - -n // 2
    a = c - 1
    b = c + 1
    while c - a <= m:
        print(a, b)
        a -= 1
        b += 1
else:
    c = n // 2
    a = c
    b = c + 1
    while c - a < m:
        print(a, b)
        a -= 1
        b += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

parti=list(range(n))
dendouiri=[]
count=0
for j in range(1,n//2+1):
  for i in range(len(parti)):
    if (parti[i]+j)%n in parti:
      saiyou = parti[i]
      pair = (saiyou+j)%n
      print(saiyou+1, pair+1)
      parti.pop(i)
      parti.remove(pair)
      count += 1
      break
  if count==m:
    break

Submission status: Wrong Answer

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

if n % 2 == 1: #odd
  for i in range(1, m+1):
    print('%s %s' % (i, n-i+1))
else: #even
  for i in range(1, m+1):
    if i % 2 == 1:
      print('%s %s' % (n/2-(i/2), n-i))
    else:
      print('%s %s' % (i, n/2+1))