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:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = map(int, readline().split())
    if m % 2 == 0:
        rem = m
        for i in range(m // 2):
            print(1 + i, m - i)
            rem -= 1
            if rem == 0:
                return
        for i in range(n):
            print(m + 1 + i, n - i)
            rem -= 1
            if rem == 0:
                return
    else:
        rem = m
        for i in range((m - 1) // 2):
            print(1 + i, m - i)
            rem -= 1
            if rem == 0:
                return
        for i in range(n):
            print(m + 1 + i, n - i)
            rem -= 1
            if rem == 0:
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = map(int, readline().split())
    if n % 2 == 0:
        rem = m
        x = ((n + 1) // 2) // 2
        for i in range(x):
            print(1 + i, 2 * x - i)
            rem -= 1
            if rem == 0:
                return
        for i in range(1, x):
            print(2 * x + 1 + i, n - i)
            rem -= 1
            if rem == 0:
                return
    else:
        rem = m
        x = ((n + 1) // 2) // 2
        for i in range(x):
            print(1 + i, 2 * x - i)
            rem -= 1
            if rem == 0:
                return
        for i in range(x):
            print(2 * x + 1 + i, n - i)
            rem -= 1
            if rem == 0:
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = map(int, readline().split())
    if n % 2 == 0:
        for i in range(m):
            print(n // 2 - i, n // 2 + 1 + i)
    else:
        rem = m
        x = ((n + 1) // 2) // 2
        for i in range(x):
            print(1 + i, 2 * x - i)
            rem -= 1
            if rem == 0:
                return
        for i in range(x):
            print(2 * x + 1 + i, n - i)
            rem -= 1
            if rem == 0:
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if M == 1:print(1,2)
elif 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())

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import sys
def Ii():return int(sys.stdin.buffer.readline())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))

n,m = Mi()
a = [0]*(n)
for i in range(m//2+1):
  a[i] = 1
  a[n//2-i] = 1
  print(i+1,n//2-i+1)
for i in range(m//2):
  a[n//2+i+1] = 1
  a[n-i-1] = 1
  
  print(n//2+1+i+1,n-i)

Submission status: Wrong Answer

Solution code:
import sys
def Ii():return int(sys.stdin.buffer.readline())
def Mi():return map(int,sys.stdin.buffer.readline().split())
def Li():return list(map(int,sys.stdin.buffer.readline().split()))

n,m = Mi()
a = [0]*(n)
for i in range(m//2+1):
  a[i] = 1
  a[n//2-i] = 1
  print(i+1,n//2-i+1)
for i in range(m//2):
  a[n//2+i+1] = 1
  a[n-i-1] = 1
  print(n//2+1+i+1,n-i+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
odd_l = 1
odd_r = N // 2 + 1
even_l = odd_r + 1
even_r = N - (M & 2 == 0)
i = 0
while i < M:
    print(odd_l, odd_r)
    i += 1
    if i == M:
        break
    print(even_l, even_r)
    i += 1
    odd_l += 1
    odd_r -= 1
    even_l += 1
    even_r -= 1

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
odd_l = 1
odd_r = N // 2 + 1
even_l = odd_r + 1
even_r = N - (M & 2 == 0)
i = 0
while i < M:
    print(even_l, even_r)
    i += 1
    if i == M:
        break
    print(odd_l, odd_r)
    i += 1
    odd_l += 1
    odd_r -= 1
    even_l += 1
    even_r -= 1

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
odd_l = 1
odd_r = M // 2 + 1
even_l = odd_r + 1
even_r = N - (M & 2 == 0)
i = 0
while i < M:
    print(even_l, even_r)
    i += 1
    if i == M:
        break
    print(odd_l, odd_r)
    i += 1
    odd_l += 1
    odd_r -= 1
    even_l += 1
    even_r -= 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

if n % 2 == 1:
    l = 1
    r = m * 2
    for _ in range(m):
        print(l, r)
        l += 1
        r -= 1
else:
    k = 1
    count = 0
    for i in range(1, m + 1):
        for _ in range(i):
            print(k, k + i)
            count += 1
            if count == m:
                exit()
            k += 1
        k += i

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
piv = N//4+(N%4==3)
pairs = [(str(piv-i), str(piv+1+i)) for i in range(N//4+(N%4==3))]
piv = N - N//4-(N%4==0)
pairs += [(str(piv-1-i), str(piv+1+i)) for i in range(N//4-(N%4==0))]
for pair in pairs[:M]:
    print(' '.join(pair))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

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


def solve():
    n, m = rl()
    lo, hi = 1, n
    for i in range(m):
        print (lo, hi)
        lo += 1
        hi -= 1






mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()

Submission status: Wrong Answer

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
if m % 2 == 1:

    cnt = 0

    for i in range(m // 2):
        num1 = 1 + i
        num2 = m - i
        print(num1, num2, sep=" ")
        cnt += 1
        if cnt == m:
            exit()
    for i in range(m // 2 + 1):
        num1 = m + 1 + i
        num2 = m - i
        print(num1, num2, sep=" ")
        cnt += 1
        if cnt == m:
            exit()
else:
    cnt = 0

    for i in range(m // 2):
        num1 = 1 + i
        num2 = m + 1 - i
        print(num1, num2, sep=" ")
        cnt += 1
        if cnt == m:
            exit()
    for i in range(m // 2 + 1):
        num1 = m + 2 + i
        num2 = m - i
        print(num1, num2, sep=" ")
        cnt += 1
        if cnt == m:
            exit()

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
if n % 2 == 1:
    halfn = n // 2
    cnt = 0
    if halfn % 2 == 0:
        for i in range(halfn // 2):
            num1 = 1 + i
            num2 = halfn - i
            print(num1, num2, sep=" ")
            cnt += 1
            if cnt == m:
                exit()
        for i in range(halfn // 2 + 1):
            num1 = halfn + 1 + i
            num2 = n - i
            print(num1, num2, sep=" ")
            cnt += 1
            if cnt == m:
                exit()
else:
    halfn = n // 2
    cnt = 0
    if halfn % 2 == 0:
        for i in range(halfn // 2):
            num1 = 1 + i
            num2 = halfn - i
            print(num1, num2, sep=" ")
            cnt += 1
            if cnt == m:
                exit()
        for i in range(halfn // 2):
            num1 = halfn + 1 + i
            num2 = n - i
            print(num1, num2, sep=" ")
            cnt += 1
            if cnt == m:
                exit()

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
if n % 2 == 1:
    for i in range(m):
        num1 = 1 + i
        num2 = 2 * m - i
        print(num1, num2, sep=" ")
else:
    halfn = n // 2
    cnt = 0
    if halfn % 2 == 0:
        for i in range(halfn // 2):
            num1 = 1 + i
            num2 = halfn - i
            print(num1, num2, sep=" ")
            cnt += 1
            if cnt == m:
                exit()
        for i in range(halfn // 2):
            num1 = halfn + 1 + i
            num2 = n - i
            print(num1, num2, sep=" ")
            cnt += 1
            if cnt == m:
                exit()

Submission status: Wrong Answer

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

right = 2*m+1

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

else:
    center = m
    for i in range(m//2):
        print(1+i, center-i)
        print(center+1+i, right-i)
    print(m//2+1, m//2+2)

Submission status: Wrong Answer

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

right = 2*m+1

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
def main():
    N,M=tuple(map(int,sys.stdin.readline().split()))
    for i in range(M):
        l,r=M-i,M+1+i
        print(str(l)+' '+str(r))
if __name__=='__main__':main()

Submission status: Wrong Answer

Solution code:
import sys
def main():
    N,M=tuple(map(int,sys.stdin.readline().split()))
    for i in range(M):
        j=N-1-i
        if (2*j-i)%N==i:j-=1
        print(str(i+1)+' '+str(j+1))
if __name__=='__main__':main()

Submission status: Wrong Answer

Solution code:
import sys
def main():
    N,M=tuple(map(int,sys.stdin.readline().split()))
    n=N if N%2 else N-1
    for i in range(M):
        print(str(i+1)+' '+str(n-i))
if __name__=='__main__':main()

Submission status: Wrong Answer

Solution code:
import sys
def main():
    N,M=tuple(map(int,sys.stdin.readline().split()))
    for i in range(M):
        print(str(i+1)+' '+str(N-2+1+1-i))
if __name__=='__main__':main()

Submission status: Wrong Answer

Solution code:
import math
def fact(n):
    ans = 1
    for i in range(2, n+1):
        ans*= i
    return ans
def comb(n, c):
    return fact(n)//(fact(n-c)*c)

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

Submission status: Wrong Answer

Solution code:
# N人に1からNの番号を振る
# 二人が入れる会場がM個、2*M+1<=N
# Nは奇数の場合がある
# Mには1, ..., Nから二つ割り振る
# N回施行
# 自分の番号と同じ会場があればそこにいく
# そこにきたもう一人と戦う
# それぞれの参加者が一を足す
# i%N
# 二回以上同じ人と戦わないようにする

# 偶数、奇数
# 例えば(1, 2), (3, 4)だと1, 2と3, 4で二回同じ組み合わせになる。
# (1, 4), (2, 3)ならうまくいく
#(1, N), (2, N-1), ... (N//2, N//2+1)

N, M = [int(i) for i in input().split()]
# 奇数ならそのまま。4の倍数でもそのまま。
if N%2 == 1 or N%4 == 0:
    for i in range(M):

        print(i+1, N-i)

# 2で割ると奇数なら真ん中をずらす必要がある
else:
    N -= 1
    for i in range(M):
        print(i+1, N-i)

Submission status: Wrong Answer

Solution code:
# N人に1からNの番号を振る
# 二人が入れる会場がM個、2*M+1<=N
# Nは奇数の場合がある
# Mには1, ..., Nから二つ割り振る
# N回施行
# 自分の番号と同じ会場があればそこにいく
# そこにきたもう一人と戦う
# それぞれの参加者が一を足す
# i%N
# 二回以上同じ人と戦わないようにする

# 偶数、奇数
# 例えば(1, 2), (3, 4)だと1, 2と3, 4で二回同じ組み合わせになる。
# (1, 4), (2, 3)ならうまくいく
#(1, N), (2, N-1), ... (N//2, N//2+1)

N, M = [int(i) for i in input().split()]
for i in range(N//2):
    if i == M:
        exit()
    print(i+1, N-i)

Submission status: Wrong Answer

Solution code:
# N人に1からNの番号を振る
# 二人が入れる会場がM個、2*M+1<=N
# Nは奇数の場合がある
# Mには1, ..., Nから二つ割り振る
# N回施行
# 自分の番号と同じ会場があればそこにいく
# そこにきたもう一人と戦う
# それぞれの参加者が一を足す
# i%N
# 二回以上同じ人と戦わないようにする

# 偶数、奇数
# 例えば(1, 2), (3, 4)だと1, 2と3, 4で二回同じ組み合わせになる。
# (1, 4), (2, 3)ならうまくいく
#(1, N), (2, N-1), ... (N//2, N//2+1)

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

Submission status: Wrong Answer

Solution code:
def main():
    n, m = map(int, input().split())
    if n & 1:
        for i in range(m):
            print(i+1, n-i)
    else:
        i = 0
        flag = False
        for i in range(m):
            if n-2*i-1 == n//2:
                flag = True
            if flag:
                print(i+1, n-i-1)
            else:
                print(i+1, n-i)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def resolve():
    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 // 2 + 1):
            print(str(i+1) + " " + str(N-i))
        for i in range(M // 2 + 1 , M):
            print(str(i+1) + " " + str(N-i-1))
resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    used = set()
    Ans = [None for _ in range(M)]
    left = 1
    right = N
    for i in range(M):
        if right - left in used or N - (right - left) in used: right -= 1
        Ans[i] = (left, right)
        diff = right - left
        used |= {diff, N - diff}
        left += 1
        right -= 1
    for i in range(M): print(*Ans[i], sep=" ")

    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    used = set()
    Ans = [None for _ in range(M)]
    left = 1
    right = N
    for i in range(M):
        if right - left in used: right -= 1
        Ans[i] = (left, right)
        diff = right - left
        used |= {diff, N - diff}
        left += 1
        right -= 1
    for i in range(M): print(*Ans[i], sep=" ")

    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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


else:
    for i in range(m):
        if i <= (m+1)//2:
            ans.append((i+1, n-i))
        else:
            ans.append((i+1, n-i-1))

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

Submission status: Wrong Answer

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


else:
    for i in range(m):
        if i <= m//2:
            ans.append((i+1, n-i))
        else:
            ans.append((i+1, n-i-1))

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

Submission status: Wrong Answer

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


else:
    for i in range(m):
        if i <= m//2:
            ans.append((i+1, n-i))
        else:
            ans.append((i, n-i-1))

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

Submission status: Wrong Answer

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


else:
    for i in range(m):
        if i < m//2:
            ans.append((i+1, n-i))
        else:
            ans.append((i+2, n-i))

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

Submission status: Wrong Answer

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


else:
    for i in range(m):
        if i <= m//2:
            ans.append((i+1, n-i))
        else:
            ans.append((i+2, n-i))

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

Submission status: Wrong Answer

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


else:
    for i in range(m):
        if i <= m//2:
            ans.append((i+1, n-1))
        else:
            ans.append((i+2, n-1))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from functools import lru_cache
from collections import defaultdict
from collections import deque
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
n,m=reads()
margin=0
if n%2==0:
  margin=1
for i in range(1,m+1):
  print(i,n-i+margin)

Submission status: Wrong Answer

Solution code:
import sys
from functools import lru_cache
from collections import defaultdict
from collections import deque
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
n,m=reads()
margin=n%2
for i in range(1,m+1):
  print(i,n-i+margin)

Submission status: Wrong Answer

Solution code:
import sys
from functools import lru_cache
from collections import defaultdict
from collections import deque
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
n,m=reads()
for i in range(1,m+1):
  print(i,n-i+1)

Submission status: Wrong Answer

Solution code:
import sys
from functools import lru_cache
from collections import defaultdict
from collections import deque
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
n,m=reads()
for i in range(1,m+1):
  print(i,n-i)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n,m = map(int, input().split())
    if n%2 == 0:
        for i in range(m):
            print(n//2-i,n//2+i+1)
    else:
        for i in range(m):
            print(n//2-i,n//2+i+2)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n,m = map(int, input().split())
    if n%2 == 0:
        for i in range(m):
            print(n//2-i,n//2+i)
    else:
        for i in range(m):
            print(n//2-i,n//2+i+2)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
a = 1
b = N
d = set([1, N - 1])
for _ in range(M):
    print(a, b)
    a += 1
    b -= 1
    while (b - a) in d or (N - b + a) in d: b -= 1
    d.add(b - a)
    d.add(N - b + a)

Submission status: Wrong Answer

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

d = 1
a = 1
used = set()
for _ in range(m):
    while a in used:
        a += 1
    b = a + d
    used.add(a)
    used.add(b)
    d += 1
    print(a, b)

Submission status: Wrong Answer

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

loop = [0]
if N%2==0:
  loop.append(N//2)

j = N-1 if N%2==1 else N
res = []
cnt = 0

for i in range(1, N):
  if j-i not in loop:
    res.append((i, j))
    cnt += 1

  if cnt == M:
    break
  else:
    j -= 1

for pair in res:
  print(" ".join(map(str,pair)))

Submission status: Wrong Answer

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

loop = [0, N//2]

j = N-1 if N%2==1 else N
res = []
cnt = 0

for i in range(1, N):
  if j-i not in loop:
    res.append((i, j))
    cnt += 1

  if cnt == M:
    break
  else:
    j -= 1

for pair in res:
  print(" ".join(map(str,pair)))

Submission status: Wrong Answer

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

loop = [0, N//2]

j = N
res = []
cnt = 0
for i in range(1, N+1):
  if j-i not in loop:
    res.append((i, j))
    cnt += 1

  if cnt == M:
    break
  else:
    j -= 1

for pair in res:
  print(" ".join(map(str,pair)))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

    Left=[]
    Right=[]

    left=1
    right=N

    if N%2==1:
        for _ in range(M):
            Left.append((left,right))
            left+=1
            right-=1

        for l in Left:
            print("{} {}".format(l[0],l[1]))
    else:
        flag=0
        for _ in range(M):
            Left.append((left,right))
            left+=1
            if flag==0:
                right-=1
            elif flag==1:
                right+=1
                flag=2
            else:
                right-=2
                flag=0

            if right-left==N-right+left:
                right-=1
                flag=1



        for l in Left:
            print("{} {}".format(l[0],l[1]))
if __name__=="__main__":
    main()

Submission status: Wrong Answer

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

    Left=[]
    Right=[]

    left=1
    right=N

    if N%2==1:
        for _ in range(M):
            Left.append((left,right))
            left+=1
            right-=1

        for l in Left:
            print("{} {}".format(l[0],l[1]))
    else:
        flag=0
        for _ in range(M):
            Left.append((left,right))
            left+=1
            if flag==0:
                right-=1
            elif flag==1:
                right+=1
                flag=2
            else:
                right-=2

            if right-left==N-right+left:
                right-=1
                flag=1



        for l in Left:
            print("{} {}".format(l[0],l[1]))
if __name__=="__main__":
    main()

Submission status: Wrong Answer

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

    Left=[]
    Right=[]

    left=1
    right=N

    if N%2==1:
        for _ in range(M):
            Left.append((left,right))
            left+=1
            right-=1

        for l in Left:
            print("{} {}".format(l[0],l[1]))
    else:
        flag=0
        for _ in range(M):
            Left.append((left,right))
            left+=1
            if flag==0:
                right-=1
            else:
                right+=1

            if right-left==N-right+left:
                right-=1
                flag=1



        for l in Left:
            print("{} {}".format(l[0],l[1]))
if __name__=="__main__":
    main()

Submission status: Wrong Answer

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

    Left=[]
    Right=[]

    left=1
    right=N

    if N%2==1:
        for _ in range(M):
            Left.append((left,right))
            left+=1
            right-=1

        for l in Left:
            print("{} {}".format(l[0],l[1]))
    else:
        stuck_right=[]
        flag=0
        for _ in range(M):
            Left.append((left,right))
            left+=1
            right-=1

            if flag==1:
                right=stuck_right.pop()

            if left==right:
                right=stuck_right.pop()
                flag=1
            if right-left>=N-right+left:
                if flag==0:
                    stuck_right.append(right)
                    right-=1
                else:
                    stuck_right.insert(0,right)
                    right=stuck_right.pop()


        for l in Left:
            print("{} {}".format(l[0],l[1]))
if __name__=="__main__":
    main()

Submission status: Wrong Answer

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

    Left=[]
    Right=[]

    left=1
    right=N

    if N%2==1:
        for _ in range(M):
            Left.append((left,right))
            left+=1
            right-=1

        for l in Left:
            print("{} {}".format(l[0],l[1]))
    else:
        stuck_right=[]
        flag=0
        for _ in range(M):
            Left.append((left,right))
            left+=1
            right-=1

            if flag==1:
                right=stuck_right.pop()

            if left==right:
                right=stuck_right.pop()
                flag=1
            if right-left==N-right+left:
                if flag==0:
                    stuck_right.append(right)
                    right-=1
                else:
                    stuck_right.insert(0,right)
                    right=stuck_right.pop()


        for l in Left:
            print("{} {}".format(l[0],l[1]))
if __name__=="__main__":
    main()