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

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

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:
n,m=map(int,input().split())
for i in range(1,n//2+1):
    print(i,((n//2)*2)+1-i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
ANS = [[0] * 2 for i in range(m)]

a = 0
b = 1
for i in range(m):
    if i*4 == n:
        b = (b+1) % n
    ANS[i] = [a, b]
    a = (a-1) % n
    b = (b+1) % n
    

for i in range(m):
    print(ANS[i][0]+1, ANS[i][1]+1)

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
l = 1
r = m*2
for i in range(m):
    print(l,r)
    l += 1
    r -= 1

Submission status: Wrong Answer

Solution code:
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())

####
from collections import deque
def solve(N, M):
    ans = []
    if N & 1:
        tops = deque(xrange(1, 2 * M + 1))
        while tops:
            ans.append([tops.popleft(), tops.pop()])

    else:
        unused = set(range(N))
        for d in range(1, M + 1):
            for i in unused:
                if (i + d) % N in unused:
                    break
            unused.discard(i)
            unused.discard((i+d)%N)
            ans.append([i+1, (i+d)%N+1])

    for row in ans:
        print "{} {}".format(*row)

solve(*rrm())

Submission status: Wrong Answer

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

    i = 0
    cnt = 0
    while cnt < M:
        if (N - i - 1) * 2 != N:
            print(1, N - i)
            cnt += 1
        i += 1


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq
#x = int(input())
n, m = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))

for i in range(m):
    print(i+1, n-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:
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(2*i-1)
    ans[i-1].append(2*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(M):
  print(i + 1, N - i)

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(i, N - i)


# 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())
if n%2==1:
  for i in range(m):print(i+1,n-i-1)
else:
  f=0
  for i in range(m):
    a,b=n//2-i,n//2+1+i+f
    if (b-a)*2==n or (b-a)>n//2:f+=1;b+=1
    print(a,b)

Submission status: Wrong Answer

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


main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

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

Submission status: Wrong Answer

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

for i in range(M):
  print(i+1,(N//2)*2-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=[]
for i in range(m):
    print("{} {}".format(i+1,n-i-1))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,m = [int(i) for i in readline().split()]

x = m
y = m+1
if n%2==1:
    for i in range(m):
        print(x-i,y+i)
else:
    num = 0
    while num*2 < n//2 and num < m:
        print(x-num,y+num)
        num += 1
    while num < m:
        print(x-num,y+num+1)
        num += 1

Submission status: Wrong Answer

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

import sys
sys.setrecursionlimit(300000)


def solve(N: int, M: int):
    s = N // 2
    for i in range(M):
        v = i * 2 + 1
        print(s, s + v)
        s -= 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:
from collections import defaultdict
import sys
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7
input = sys.stdin.readline


def inp():
    return int(input())


def inpl():
    return list(map(int, input().split()))


N, M = inpl()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
ANS = [[0] * 2 for i in range(m)]

a = 0
b = 1
for i in range(m):
    ANS[i] = [a, b]
    a = (a-1) % n
    b = (b+1) % n

for i in range(m):
    print(ANS[i][0]+1, ANS[i][1]+1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def examA():
    K = I()
    A, B = LI()
    for i in range(A,B+1):
        if i%K==0:
            print("OK")
            return
    print("NG")
    return

def examB():
    X = I()
    now = 100
    ans = 0
    while(now<X):
        ans += 1
        now += now//100
    print(ans)
    return

def examC():
    N, M, Q = LI()

    ans = 0
    print(ans)
    return

def examD():
    A, B, N = LI()
    if N>=B-1:
        ans = (A*(B-1))//B
    else:
        ans = (A*N)//B
    print(ans)
    return

def examE():
    N, M = LI()
    ans = []
    if N%2==1:
        for i in range(N // 2):
            ans.append((i + 1, N - i))
    else:
        flag = False
        for i in range(N // 2):
            if N-i-(i+1)==N//2:
                flag = True
            if flag:
                ans.append((i+1,N-i-1))
            else:
                ans.append((i + 1, N - i))
    #print(ans)
    for v in ans[:M]:
        print(" ".join(map(str,v)))
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examE()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
ans=[[] for _ in range(n//2)]
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])

Submission status: Wrong Answer

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

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:
n, m = map(int, input().split())
used = set()
c = 0
i = 1
while c < m:
    if i not in used:
        print(i, i+c+1)
        used.add(i)
        used.add(i+c+1)
        c += 1
    i += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n, m = LI()
    if n & 1 == 0: n -= 1
    for i in range(m):
        print(i + 1, n - i)
    return


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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,M=MI()
    a=1
    b=N
    for i in range(M):
        print(a,b)
        a+=1
        b-=1
    

main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n, m = map(int,input().split())

    if n & 1: 
        left = 1
        right = n - 1
        for _ in range(m):
            print(left, right)
            left += 1
            right -= 1

    else:
        left = 1
        right = n
        for _ in range(m):
            print(left, right)
            left += 1
            right -= 1
resolve()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,m = [int(i) for i in readline().split()]

x = m
y = m+1
for i in range(m):
    print(x-i,y+i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = [[0, 0] for _ in range(m)]

cur = 1
for i in range(m):
    ans[i][0] = cur
    cur += 1

for i in reversed(range(m)):
    ans[i][1] = cur
    cur += 1

for i in range(m):
    print(ans[i][0], ans[i][1])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def examA():
    K = I()
    A, B = LI()
    for i in range(A,B+1):
        if i%K==0:
            print("OK")
            return
    print("NG")
    return

def examB():
    X = I()
    now = 100
    ans = 0
    while(now<X):
        ans += 1
        now += now//100
    print(ans)
    return

def examC():
    N, M, Q = LI()

    ans = 0
    print(ans)
    return

def examD():
    A, B, N = LI()
    if N>=B-1:
        ans = (A*(B-1))//B
    else:
        ans = (A*N)//B
    print(ans)
    return

def examE():
    N, M = LI()
    ans = []
    for i in range(N // 2):
        ans.append((i + 1, N - i))
    #print(ans)
    for v in ans[:M]:
        print(" ".join(map(str,v)))
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examE()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:

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

if N % 2 == 0:
    for i in range(M):
        print(f"{i+1} {N-i}")
else:
    for i in range(M):
        print(f"{i+1} {N-i-1}")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())

####
from collections import deque
def solve(N, M):
    ans = []
    tops = deque(xrange(1, 2 * M + 1))
    while tops:
        ans.append([tops.popleft(), tops.pop()])
    for row in ans:
        print "{} {}".format(*row)
    
    
solve(*rrm())

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
h = set()
mi = 0
for i in range(m):
    if n-i-mi-(i+1) in h:
        mi += 1
    print(i+1, n-i-mi)
    h.add(n+i+1 - (n-i-mi))

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10**7)
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
printn = lambda x: print('\n'.join(x))

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

Submission status: Wrong Answer

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

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:

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n, m = LI()
    if n & 1: n -= 1
    for i in range(m):
        print(i + 1, n - i)
    return


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

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20

def experiment(N,M,X):
    seen = set()
    for i in range(N):
        for j in range(len(X)):
            v1,v2 = X[j]
            if (v1,v2) in seen or (v2,v1) in seen: assert False
            seen.add((v1,v2))
            seen.add((v2,v1))

            new_v1 = v1-1
            new_v2 = v2-1

            if new_v1 < 1:
                new_v1 = N
            
            if new_v2 < 1:
                new_v2 = N

            X[j] = (new_v1,new_v2)


def main():
    N,M=mi()
    
    X = []
    s = 1
    used = set()
    for length in range(1,M+1):
        t = s + 1
        if t > N:
            t -= N

        while t in used or abs(s-t) != length:
            t += 1
            if t > N:
                t -= N

        used.add(s)
        used.add(t)
        X.append((s,t))
        print(s,t)

        while s in used:
            s += 1
            if s > N:
                s -= N
    

    # experiment(N,M,X)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq

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

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

else:
    a = [0]*n
    i = 0
    j = 1
    while True:
        if a[i % n] == 0 and a[(i+j) % n] == 0:
            a[i % n] = 1
            a[(i+j) % n] = 1
            print((i % n) + 1, ((i+j) % n) +1)
            j = j + 1
        else:
            i = i + 1
            
        if len(a) == m: sys.exit()

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq

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

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

else:
    a = [0]*n
    i = 0
    j = 1
    while True:
        if a[i % n] == 0 and a[(i+j) % n] == 0:
            a[i % n] = 1
            a[(i+j) % n] = 1
            print((i % n) + 1, ((i+j) % n) +1)
            j = j + 1
        else:
            i = i + 1

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

#N人の参加者から、M組選ぶ
#これをNセット実施。
#組合わせの距離が重複しなければ、成立


#全ての組み合わせは、
arr=list(itertools.permutations(range(1,N+1), M*2))


#全てのパターンで検証
#成立すればそこで出力
for i in range(len(arr)):
    #チェックリスト初期化
    check_list=[0]*N
    for j in range(M):
        #一人目
        ent1=arr[i][j]
        #二人目
        ent2=arr[i][M*2-j-1]
        #二人の距離は
        dist1=max(ent1,ent2)-min(ent1,ent2)-1
        dist2=N-max(ent1,ent2)+min(ent1,ent2)-1
        #被ってないか評価
        if check_list[dist1]==0:#まだ使われていない距離
            check_list[dist1]=1
        else:
            break
        if check_list[dist2]==0:#まだ使われていない距離
            check_list[dist2]=1
        else:
            break
    else:#全てのMを被り無しで選べたら、出力
        for k in range(M):
            print(str(arr[i][k])+' '+str(arr[i][M*2-k-1]))
        break

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int, input().split())
Match = []
leftnum = [i for i in range(1,N+1)]
for i in range(1,M+1):
    a, b=leftnum[0],(leftnum[0]+i-1)%N+1
    while b not in leftnum or a not in leftnum:
        a%=N
        a+=1
        b%=N
        b+=1
    Match.append([a,b])
    leftnum.remove(a)
    leftnum.remove(b)
for i in Match:
    print(i[0],i[1])

Submission status: Time Limit Exceeded

Solution code:
#  =========     /\       /|    |====/|
#      |        /  \       |    |   / |
#      |       /____\      |    |  /  |
#      |      /      \     |    | /   |
#  ========= /        \  =====  |/====|  
#  code

def main():
    n , m = map(int , input().split())
    print(1 , n)
    k = 2
    diff = 1
    p = set(list(range(1 , n + 1)))
    p.remove(1)
    p.remove(n)
    m -= 1
    while m > 0:
        if k in p and diff + k + 1 in p:
            print(k , diff + k + 1)
            p.remove(k)
            p.remove(diff + k + 1)
            diff += 1
            m -= 1
        k += 1
    return

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
l=1
r=N
dis=[]
if N%2==1:
    for i in range(M):
        print(l,r)
        l=l+1
        r=r-1
else:
    for _ in range(M):
        print(l,r)
        a,b=r-l,N+l-r
        dis.append(a)
        dis.append(b)
        l=l+1
        r=r-1
        if r-l in dis or N+l-r in dis or r-l==N+l-r:
            r=r-1

Submission status: Time Limit Exceeded

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

already = [0 for i in range(n+1)]
idx = m+1
for sa in range(m)[::-1]:
    sa += 1
    while True:
        if idx-sa < 1:
            idx = sa + 1
            # if idx > n: idx = 1
            continue
        if already[idx] == 0 and already[idx-sa] == 0:
            right, left = idx, idx-sa
            already[right], already[left] = 1, 1
            idx += 1
            if idx > n: idx = 1
            break
        else:
            idx += 1
            if idx > n: idx = 1
    print(left, right)

Submission status: Time Limit Exceeded

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

already = [0 for i in range(n+1)]
idx = m+1
for sa in range(m)[::-1]:
    sa += 1
    while True:
        if idx-sa < 1:
            idx += 1
            if idx > n: idx = 1
            continue
        if already[idx] == 0 and already[idx-sa] == 0:
            right, left = idx, idx-sa
            already[right], already[left] = 1, 1
            idx += 1
            if idx > n: idx = 1
            break
        else:
            idx += 1
            if idx > n: idx = 1
    print(left, right)