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:
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def main():
    n, m = map(int, input().split())
    ans = []
    for i in range(1, (m+1)//2+1):
        ans.append([i, m+2-i])

    for i in range(1, (m+1)//2):
        if len(ans) == m:
            break
        ans.append([m+1+i, 2*m+2-i])

    for x in ans:
        print(x[0], x[1])

main()

Submission status: Wrong Answer

Solution code:
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def main():
    n, m = map(int, input().split())
    ans = []
    for i in range(1, m + 1):
        ans.append([i, n-i+1])

    for x in ans:
        print(x[0], x[1])


main()

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-1):
    if k>=m:
      break
    print(i+1,end=" ")
    print(n-i)
    k+=1
  for i in range((n+2)//4-1,n//2):
    if k>=m:
      break
    print(i+1,end=" ")
    print(n-i-1)
    k+=1

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
ans = [[] for _ in range(m)]

for i in range(m):
    ans[i].append(i+1)
for j, i in enumerate(range(m-1, -1, -1)):
    ans[j].append(m+i+1)

for ai in ans:
    print(' '.join(map(str, ai)))

Submission status: Wrong Answer

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

if n % 2: # odd
    for i in range(m):
        print(i + 1, n - i)
else: # even
    for i in range(m):
        if 1 + 2 * i >= n - 1 - 2 * i:
            break
        m -= 1
        print(i + 1, n - i)
    for i in range(m):
        print(i + 1 + m, n - i - m - 1)

Submission status: Wrong Answer

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

if n % 2: # odd
    for i in range(m):
        print(i + 1, n - i)
else: # even
    for i in range(m):
        if 1 + 2 * i >= n - 1 - 2 * i:
            m -= i
            break
        print(i + 1, n - i)
    for i in range(m):
        print(i + 1 + m, n - i - m - 1)

Submission status: Wrong Answer

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

M_MAX = (N - 1) // 2

pos = 1
size = M_MAX
i = 0
while i < M and size > 0:
    print(pos, pos + size)
    pos += 1
    i += 1
    size -= 2

pos = 1 + M_MAX + 1
size = M_MAX - 1
i = 0
while i < M and size > 0:
    print(pos, pos + size)
    pos += 1
    i += 1
    size -= 2

Submission status: Wrong Answer

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

if n % 2: # odd
    for i in range(m):
        print(i + 1, n - i)
else: # even
    a = [True] * n
    cnt = 1
    for i in range(n):
        if i + cnt >= n or cnt > m:
            break
        if a[i]:
            print(i + 1, i + 1 + cnt)
            a[i + cnt] = False
            cnt += 1

Submission status: Wrong Answer

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

if n % 2: # odd
    for i in range(n // 2):
        print(i + 1, n - i)
else: # even
    a = [True] * n
    cnt = 1
    for i in range(n):
        if i + cnt >= n:
            break
        if a[i]:
            print(i + 1, i + 1 + cnt)
            a[i + cnt] = False
            cnt += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if M % 2 == 1:
    for i in range(M):
        j = N - i
        print(f'{i + 1} {j}')
else:
    for i in range(M):
        if i < M / 2:
            print(i + 1, N - i)
        else:
            print(i + 1, N - i - 1)

Submission status: Wrong Answer

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

for i in range(M):
	j = M * 2 - i
	print(f'{i + 1} {j}')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import numpy as np
sys.setrecursionlimit(10**8)
INF = float("inf")


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

    A = np.arange(M)
    B = np.arange(N-2, M, -1)

    A += 1
    B += 1
    for a, b in zip(A.tolist(), B.tolist()):
        print(a, b)
    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:
#!/usr/bin/env python3
import sys
import numpy as np
sys.setrecursionlimit(10**8)
INF = float("inf")


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

    A = np.arange(M)
    B = np.arange(2*M, M, -1)

    A += 1
    B += 1
    for a, b in zip(A.tolist(), B.tolist()):
        print(a, b)
    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:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(N: int, M: int):
    # N <= 10**5

    # 差が異なる組み合わせならば、N回を通して同じ組み合わせにはならない。
    # 前に奇数差、後ろに偶数差を作る
    ans = []

    # Nは偶数
    # 差は偶数
    a, b = (0, N//2)
    while a < b:
        ans.append((a+1, b+1))
        a += 1
        b -= 1
    # 差は奇数
    a, b = (N//2+1, N-1)
    if (b-a) % 2 == 0:
        b -= 1
    while a < b:
        ans.append((a+1, b+1))
        a += 1
        b -= 1
    for i in range(M):
        print(*ans[i], sep=" ")
    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:
n,m = map(int,input().split())
if n % 2 == 1:
    ans = [[1+i,n-i] for i in range(n//2)]
else:
    ans = [[1+i,n-i] for i in range(n//4)]+[[n//2+1+i,n//2-1-i] for i in range(n//2-n//4-1)]
for a,b in ans:
    print(a,b)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(N: int, M: int):
    # N <= 10**5

    # 差が異なる組み合わせならば、N回を通して同じ組み合わせにはならない。
    # 前に奇数差、後ろに偶数差を作る
    front = (0, N//2)
    if N % 2 == 0:
        back = (N//2, N-2)
    else:
        back = (N//2, N-1)

    for i in range(M):
        if i % 2 == 0:
            a, b = front
            print(a+1, b+1)
            front = (a+1, b-1)
        else:
            a, b = back
            print(a+1, b+1)
            back = (a+1, b-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:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(N: int, M: int):
    # N <= 10**5

    # 差が異なる組み合わせならば、N回を通して同じ組み合わせにはならない。
    # 前に奇数差、後ろに偶数差を作る
    front = (0, N//2)
    if N % 2 == 0:
        back = (N//2, N-1)
    else:
        back = (N//2, N)

    for i in range(M):
        if i % 2 == 0:
            a, b = front
            print(a+1, b+1)
            front = (a+1, b-1)
        else:
            a, b = back
            print(a+1, b+1)
            back = (a+1, b-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 sys import setrecursionlimit, exit
setrecursionlimit(1000000000)

def main():
    n, m = map(int, input().split())
    a = 1
    d = n - 1
    for _ in range(m):
        if d == n / 2:
            d -= 1
        print(a, a + d)
        a += 1
        d -= 2

main()

Submission status: Wrong Answer

Solution code:
from sys import setrecursionlimit, exit
setrecursionlimit(1000000000)

def main():
    n, m = map(int, input().split())
    a = 1
    d = n - 1
    for _ in range(m):
        b = a + d
        while (2 * (a + d) - a) % n == a:
            d -= 1
        print(a, a + d)
        a += 1
        d -= 2

main()

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


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


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def debug(table, *args):
    ret = []
    for name, val in table.items():
        if val in args:
            ret.append('{}: {}'.format(name, val))
    print(' | '.join(ret), file=sys.stderr)


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N, M = MI()

    if N % 2 == 1:
        pairs = []
        for i in range(N//2):
            pairs.append((i+1, N-i-1))

        print(pairs)
        for i in range(M):
            print(*pairs[i])
            # print((pairs[i][0] - pairs[i][1]) % N)
            # print((pairs[i][1] - pairs[i][0]) % N)
    else:
        pairs = []
        for i in range(N//2//2):
            pairs.append((i+1, N-i))

        for i in range(N//2//2+1, N//2):
            pairs.append((i+1, N-i+1))

        # print(pairs)
        for i in range(M):
            print(*pairs[i])
            # print((pairs[i][0] - pairs[i][1]) % N)
            # print((pairs[i][1] - pairs[i][0]) % N)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


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


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def debug(table, *args):
    ret = []
    for name, val in table.items():
        if val in args:
            ret.append('{}: {}'.format(name, val))
    print(' | '.join(ret), file=sys.stderr)


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N, M = MI()

    if N % 2 == 1:
        pairs = []
        for i in range(N//2):
            pairs.append((i+1, N-i))

        print(pairs)
        for i in range(M):
            print(*pairs[i])
            # print((pairs[i][0] - pairs[i][1]) % N)
            # print((pairs[i][1] - pairs[i][0]) % N)
    else:
        pairs = []
        for i in range(N//2//2):
            pairs.append((i+1, N-i))

        for i in range(N//2//2+1, N//2):
            pairs.append((i+1, N-i+1))

        # print(pairs)
        for i in range(M):
            print(*pairs[i])
            # print((pairs[i][0] - pairs[i][1]) % N)
            # print((pairs[i][1] - pairs[i][0]) % N)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for x in a:
  print(x[0],x[1])

Submission status: Wrong Answer

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

if N%2==1:
    a, b = 1, N
    for _ in range(M):
        print(a, b)
        a += 1
        b -= 1
else:
    a, b = 1, N
    num = M//2+1
    for _ in range(num):
        print(a, b)
        a += 1
        b -= 1
    b -= 1
    for _ in range(M-num):
        print(a, b)
        a += 1
        b -= 1

Submission status: Wrong Answer

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

if N%2==1:
    a, b = 1, N
    for _ in range(M):
        print(a, b)
        a += 1
        b -= 1
else:
    a, b = 1, N
    dist = []
    for _ in range(M//2):
        print(a, b)
        a += 1
        b -= 1
    b -= 1
    for _ in range(M-M//2):
        print(a, b)
        a += 1
        b -= 1

Submission status: Wrong Answer

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

if N%2==1:
    a, b = 1, N
    for _ in range(M):
        print(a, b)
        a += 1
        b -= 1
else:
    a, b = 1, N
    dist = []
    for _ in range(M):
        print(a, b)
        d = min(b-a, N-b+a)
        if d not in dist:
            dist.append(d)
            a += 1
            b -= 1
        else:
            a += 1
            b -= 2

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)
        ans.append(n-1-i)

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

print(*ans)

Submission status: Wrong Answer

Solution code:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, M = lr()
    cnt = 0
    if N%2 == 1:
        for i in range(1, (N-1)//2+1):
            if cnt >= M:
                break
            print(f'{i+1} {N-i+1}')
            cnt += 1
    else:
        if N == 4:
            print(f'{2} {3}')
        if N >= 6:
            print(f'{2} {N}')
            cnt += 1
            for i in range(4, N):
                if cnt >= M:
                    break
                print(f'{i} {N-i+3}')
                cnt += 1
resolve()

Submission status: Wrong Answer

Solution code:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, M = lr()
    cnt = 0
    if N%2 == 1:
        for i in range(1, (N-1)//2+1):
            if cnt >= M:
                break
            print(f'{i+1} {N-i+1}')
            cnt += 1
    else:
        if N == 4:
            print(f'{2} {3}')
        if N >= 6:
            print(f'{2} {N}')
            cnt += 1
            for i in range(4, N):
                if cnt >= M:
                    break
                print(f'{i} {N-i+3} {cnt}')
                cnt += 1
resolve()

Submission status: Wrong Answer

Solution code:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, M = lr()
    cnt = 0
    if N%2 == 1:
        for i in range(1, (N-1)//2+1):
            if cnt > M:
                break
            print(f'{i+1} {N-i+1}')
            cnt += 1
    else:
        if N == 4:
            print(f'{2} {3}')
        if N >= 6:
            print(f'{2} {N}')
            cnt += 1
            for i in range(4, N):
                if cnt > M:
                    break
                print(f'{i} {N-i+3}')
                cnt += 1
resolve()

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
venue=[]
if N%2==0:
    l=1
    r=N//2
    while l<r:
        venue.append([l,r])
        l+=1
        r-=1
    l=N//2+1
    r=N-1
    while l<r:
        venue.append([l,r])
        l+=1
        r-=1
else:
    l=1
    r=N//2
    while l<r:
        venue.append([l,r])
        l+=1
        r-=1
    l=N//2+1
    r=N
    while l<r:
        venue.append([l,r])
        l+=1
        r-=1
for a,b in venue:
    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)
        ans.append(n-1-i)

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

print(*ans)

Submission status: Wrong Answer

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


def solve(N: int, M: int):
    if N % 2 == 1:
        for i in range(1, M+1):
            print("{0} {1}".format(i, 2 * M + 1 - i))
    else:
        b = N
        for i in range(1, M+1):
            if i % 2 == 1:
                print("{0} {1}".format(i, b))
                b -= 2
            else:
                print("{0} {1}".format(i, b))
                b -= 1
    return


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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

print(*ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if N%2==0 and N>4:
    n = (N//2-1)*2
    for i in range(M):
        x = 0
        if i>=M/2:
            x = 1
        a = 1 + i
        b = a + n - (2*i+x)
        print(a, b)
else:
    n = (N//2)*2
    for i in range(M):
        a = 1 + i
        b = a + n - (2*i+1)
        print(a, b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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 main():
    n,m=map(int,input().split())
    if n%2==1:
        x=[f"{i+1} {n-i}" for i in range(m)]
        print(" ".join(x))
    else:
        if m%2==0:
            x=[f"{i+1} {n-i}" if i<m/2 else f"{i+1} {n-i-1}" for i in range(m)]
        else:
            x=[f"{i+1} {n-i}" if i<m/2-1 else f"{i+1} {n-i-1}" for i in range(m)]
        print(" ".join(x))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if N%2==0 and N>4:
    n = (N//2-1)*2
    for i in range(M):
        x = 0
        if i>=M//2:
            x = 1
        a = 1 + i
        b = a + n - (2*i+x)
        print(a, b)
else:
    n = (N//2)*2
    for i in range(M):
        a = 1 + i
        b = a + n - (2*i+1)
        print(a, b)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if N%2==0 and N>4:
    from math import ceil
    n = (N//2)*2
    for i in range(M):
        x = 1
        if i>=M//2:
            x = 2
        a = 1 + i
        b = a + n - (2*i+x)
        print(a, b)
else:
    n = (N//2)*2
    for i in range(M):
        a = 1 + i
        b = a + n - (2*i+1)
        print(a, b)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3

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

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

Submission status: Wrong Answer

Solution code:
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%4==0 and i >= N/4:
        print((-i)%N + 1,3+i)
    elif 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:
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%4==0 and i == N/4:
        print((-i)%N + 1,3+i)
    elif 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())
if N%2==0:
    from math import ceil
    n = (N//2)*2
    for i in range(M):
        x = 1
        if i>=M//2:
            x = 2
        a = 1 + i
        b = a + n - (2*i+x)
        print(a, b)
else:
    n = (N//2)*2
    for i in range(M):
        a = 1 + i
        b = a + n - (2*i+1)
        print(a, b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    n,m=map(int,input().split())
    if n%2==1:
        x=[f"{i+1} {n-i}" for i in range(m)]
        print(" ".join(x))
    else:
        x=[f"{i+1} {n-i}" if i<=m//2 else f"{i+1} {n-i-1}" for i in range(m)]
        print(" ".join(x))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n,m=map(int,input().split())
    if n%2==1:
        x=[f"{i+1} {n-i}" for i in range(m)]
        print(" ".join(x))
    else:
        x=[f"{i+1} {n-i}" if i<=m/2 else f"{i+1} {n-i-1}" for i in range(m)]
        print(" ".join(x))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n,m=map(int,input().split())
    if n%2==1:
        x=[f"{i+1} {n-i}" for i in range(m)]
        print(" ".join(x))
    else:
        x=[f"{i+1} {n-i}" if i<m//2 else f"{i+1} {n-i-1}" for i in range(m)]
        print(" ".join(x))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
from math import ceil
n = ceil(N/2-1)*2

for i in range(M):
    x = 0
    if i>=M//2:
        x = 1
    a = 1 + i
    b = a + n - (2*i+x)
    print(a, b)

Submission status: Wrong Answer

Solution code:
def main():
    N,M=map(int,input().split())
    a=1
    b=N
    for i in range(1,M+1):
        if (b-a)==(N+a-b):
            b-=1
        print(a,b)
        a+=1
        b-=1
if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N,M=map(int,input().split())
    a=1
    b=N
    for i in range(1,M+1):
        print(a,b)
        a+=1
        b-=1
if __name__=='__main__':
    main()