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
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
import math
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
N,M = map(int,input().split())
if N % 2 == 1:
    for i in range(1,M+1):
        print(i,N-i)
else:
    for i in range(2,M+2):
        print(i,N+1-i)

Submission status: Wrong Answer

Solution code:
#code
N,M=map(int,input().split())
p1=N//2
p2=N//2+1
print(p1,p2)
p1-=1
p2+=1
M-=1
while M:
    if((p2-p1)==N//2):
        p2+=1
    else:    
        print(p1,p2)
        p1-=1
        p2+=1
        M-=1

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
for i in range(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,M+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()
    ans = [[i + 1, None] for i in range(m)]
    v = n
    j = m + 1
    d = defaultdict(int)
    d[0] = 1
    d[n] = 1
    for i in range(m - 1, -1, -1):
        while d[n - (j - ans[i][0])]: j += 1
        d[j - ans[i][0]] = 1
        ans[i][1] = j
        j += 1
    for a in ans:
        print(*a)
    return


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N != 2*M+2:
    for m in range(M):
        print(m, N-m-1)
else:
    print(0, 1)
    for m in range(2, M+1):
        print(m, 2*m)

Submission status: Wrong Answer

Solution code:
import bisect,sys
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac =fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV
        
    return CONV()



sys.setrecursionlimit(200005)


def main():
    N,M = isRaw()
    for m in range(M):
        print(m+1,N-1-m)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def check(pairs, N):
    games = set()
    for i in range(N):
        for p1, p2 in pairs:
            p1, p2 = (p1 - i + N) % N, (p2 - i + N) % N
            if (p1, p2) in games:
                return False
            games.add((p1, p2))
    return True


def main() -> None:
    N, M = map(int, input().split())
    left, right = (1, M + 1), (M + 1, M + M)
    ans = []
    for i in range(M):
        if i % 2 == 0:
            ans.append(left)
            left = (left[0] + 1, left[1] - 1)
        else:
            ans.append(right)
            right = (right[0] + 1, right[1] - 1)
    # assert check(ans, N)
    for p in ans:
        print(*p)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import ceil #切り上げ
import numpy as np
 
def inp(): return int(input()) #一個だけ読み取り
def inpm(): return map(int,input().split()) #mapオブジェクトで呼び出し
def inpl(): return list(map(int, input().split())) #数字リストをintで
def inpls(): return list(input().split()) #リストをstrで

N,M = inpl()

for i in range(1,M+1):
  print(str(i) + " " + str(N-i))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

half_l = N // 2
half_u = N // 2 + 1
if N%2 == 1:
  for i in range(M):
    print(half_l, half_u)
    half_l -= 1
    half_u += 1
else:
  half = N / 2
  for i in range(M):
    if half_u - half_l == half:
      half_u += 1
    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(m):
    print(i + 1, n - i - 1)

Submission status: Wrong Answer

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

lst = [i for i in range(1, n+1)]
if n % 2 == 0:
    cands = [(n//2 - j, n//2 + j + 1) for j in range(m)]
else:
     cands = [(j, n-j) for j in range(1, m+1)]
for cand in cands:
    print(cand[0], cand[1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math

# 総当りができる組み合わせを探す
if __name__ == '__main__':
    n, m = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))
    c,d = n // 2, n//2
    fib1, fib2 = 0, 1
    for i in range(m):
        print(c-fib1, d+fib1+1)
        c = c-fib1
        d = d+fib1
        tmp = fib1 + fib2
        fib2 = fib1
        fib1 = tmp

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a = 1
b = n-1
count = 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor

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

    start = 1
    end = N

    used = set()
    for m in range(M):
        print("{} {}".format(start, end))
        fdiff = end - start
        bdiff = N - fdiff
        used.add(fdiff)
        used.add(bdiff)

        start += 1
        end -= 1

        fdiff = end - start
        if fdiff in used:
            if start % 2 == 1:
                start += 1
            else:
                end -= 1

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/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()
    ans = [[i + 1, None] for i in range(m)]
    v = n
    j = m + 1
    d = defaultdict(int)
    d[0] = 1
    d[n] = 1
    for i in range(m - 1, -1, -1):
        if d[n - (j - ans[i][0])]: j += 1
        d[j - ans[i][0]] = 1
        ans[i][1] = j
        j += 1
    for a in ans:
        print(*a)
    return


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

Submission status: Wrong Answer

Solution code:
from bisect import *
from collections import *

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
def f(n):
    if n%N==0:
        return N
    else:
        return n%N

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

Submission status: Wrong Answer

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

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

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:
n,m = map(int, input().split())
data = [[-1,-1] for i in range(m)]
for i in range(m):
    data[i][0] = i+1
    data[i][1] = n-i
for i in range(m):
    print("{} {}".format(data[i][0], data[i][1]))

Submission status: Wrong Answer

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


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
a,b=N//2,N//2+1
li=[]
for i in range(M):
    li.append([a,b])
    a,b=a-1,b+1
for i in reversed(range(M)):
    print(*li[i])

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

n, m = MAP()
mx = m * 2 + 2 - n % 2
for i in range(1, m + 1):
    print(i, mx - i)

Submission status: Wrong Answer

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

center = N // 2
width = N // M - 1
start = center
end = center + 1
for i in range(M):
    print(start, end)
    start -= width
    end += width

Submission status: Wrong Answer

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = MAP()

ans = list2d(M, 2, 0)
cnt = 1
for i in range(M):
    ans[i][0] = cnt
    cnt += 1
for i in range(M-1, -1, -1):
    ans[i][1] = cnt
    cnt += 1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b=LI()
  for i in range(b):
    print(i+1,i+2)

main()
# print(main())

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor

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

    start = 1
    end = N

    used = set()
    for m in range(M):
        print("{} {}".format(start, end))
        fdiff = end - start
        bdiff = N - fdiff
        used.add(fdiff)
        used.add(bdiff)

        start += 1
        end -= 1

        fdiff = end - start
        if fdiff in used:
            if start % 2 == 0:
                start += 1
            else:
                end -= 1

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
con_flag = False
t=1
if n % 2 == 1:
    for i in range(1,m+1): 
        print(i,n-i+1)
else:
    for i in range(1,m+1):
        if n-i+1-i == n//2:
            con_flag = True
            continue
        print(i,n-i+1)
    if con_flag == True:
        print(n//2,n//2 + 1)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
used = set()
count = 0
for i in range(1, N):
    if i in used:
        continue

    used.add(i)
    for j in range(i + count + 1, N + 1):
        if j not in used:
            used.add(j)
            print(i, j)
            count += 1
            if count == M:
                exit()
            else:
                break

Submission status: Wrong Answer

Solution code:
# import numpy as np
# import queue
# import heapq


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

    ds = [2 * i + 1 for i in range(M)]

    if N % 2 == 0:
        ds[-1] = ds[-1] + 1

    ds.sort(reverse=True)

    for i in range(M):
        p = i + 1
        d = ds[i]
        print(p, p + d)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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()
    ans = [[i + 1, None] for i in range(m)]
    v = n
    j = m + 1
    d = defaultdict(int)
    d[0] = 1
    d[1] = 1
    for i in range(m - 1, -1, -1):
        if d[n - (j - ans[i][0])]: j += 1
        d[j - ans[i][0]] = 1
        ans[i][1] = j
        j += 1
    for a in ans:
        print(*a)
    return


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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ne = int(n / 2) * 2
ns = 1
for i in range(m):
    print("{} {}".format(ns, ne))
    ns += 1
    ne -= 1

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    n, m = map(int, input().split())
    right = 2
    for i in range(m):
        print("{0} {1}".format(1, right))
        right += 1

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, M = map(int, rl().split())
    
    last = N if N % 2 == 0 else N - 1
    left = [i for i in range(1, N // 2 + 1)]
    right = [i for i in range(last, N // 2, -1)]
    
    ans = []
    for ans_i in zip(left, right):
        ans.append(ans_i)
    
    for ans_i in ans[:M]:
        print(*ans_i)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
n,M =map(int,input().split())
s=0
t=1
list1=[]
list2=[]
u=0
if M==1:
    print("1 2")
else:    
    while s< M-1:
        while (t<=(n+1)//2 and s<M-1):
            lis=t
            list1.append(lis)
            lis2=(n+1)//2+1-t
            list2.append(lis2)
            t+=1
            s+=1
        lis=(n+1)//2+1+u
        list1.append(lis)
        lis2=(n+1)//2+(n-1)//2-u
        list2.append(lis2)
        u+=1
        s+=1
    for i in range(0,M):
        print(list1[i],list2[i])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if n % 2 == 1:
  a=1
  b=2*m

  for _ in range(m):
    print(a, b)
    a += 1
    b -= 1
else:
  a = 1
  th = n-1
  count = 0
  half = n//2
  while True:
    if th < half:
      th -= 1
    count += 1
    print(a, a+th)
    a += 1
    th -= 2
    if count == m:
      break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
start = 1
end = N
for i in range(M)[::-1]:
    print(start, end)
    start += 1
    end -= 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 = n
for i in range(m):
    if r-l == l+n-r:
        r -= 1
    # print(r-l, l+n-r)
    print(l,r)
    l += 1
    r -= 1
    if i == m-2:
        r -= 1

Submission status: Wrong Answer

Solution code:


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, M = read_ints()
    a, b = [], []
    for i in range(1, M+1):
        print(i, N-(i-1))


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
def main():
    N, M = list(map(int, input().split()))
    if N % 2 == 1:
        for i in range(M):
            print(i + 1, N - i - 1)
            
    else:
        A = [False] * N
        t = 0
        for i in range(M):
            while A[t]:
                t += 1
            A[t] = True
            if A[(t + i + 1) % N]:
                print("Fail")
                return
            A[(t + i + 1) % N] = True
            print(t + 1, t + i + 2)

main()

Submission status: Wrong Answer

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

l = N // 2
r = l + 1

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

nl = [i for i in range(1, n+1)]

if n%2 == 0 and m%2 == 0:
    print(1, n)
    left = 1
    right = n-3
    for _ in range(m-1):
        print(nl[left], nl[right])
        left += 1 
        right -= 1
else:
    left = 0
    right = n-1
    for _ in range(m):
        print(nl[left], nl[right])
        left += 1
        right -= 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
result = []
x = [i for i in range(1, 2*m+2)]
for i in range(m):
    result.append([x[i], x[-i-1]])
result[0][1] += 1
for j in result:
    print(*j)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
i=n//2
j=n//2 + 1
ans = list()
for _ in range(m):
    ans.append((i,j))
    i-=1
    j+=1
# print(ans)
for i in range(m-1,-1,-1):
    t = ans[i]
    print(t[0], t[1])

Submission status: Wrong Answer

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

if a%2 == 1:
    for i in range(b):
        print(str(i+1) + ' ' + str(a-i))
else:
    for i in range(b):
        if i < a//2-1:
            print(str(i+1) + ' ' + str(a-i-1))
        else:
            print(str(a) + ' ' + str(i+1))

Submission status: Wrong Answer

Solution code:
def main():
    n, m = map(int, input().split())
    t = [True]*n
    s = [True]*(n+1)
    x = 1
    for _ in range(m):
        while not s[x]:
            x += 1
        s[x] = False
        for i in reversed(range(1, n)):
            if t[i] and x+i<n+1 and s[x+i]:
                print(x, x+i)
                t[i] = False
                s[x+i] = False
                break

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(m):
  print(int(n/2)-i, " ", int(n/2)+i+1)

Submission status: Wrong Answer

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,m = iim()
if m == 1:
    print(1,2)
elif n%2 == 1:
    l = list(range(1,n//2+1))[::-1]
#    print(l)
    for i in l[:m]:
        print(i,n-i)
else:
    l = list(range(1,n//2))[::-1]
#    print(l)
    for i in l[:m]:
        print(i,n//2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

tmp = 2 * int(n / 2)+1 

for i in range(1, m+1):
	print("{} {}".format(i, tmp-i))

Submission status: Wrong Answer

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



resolve()

Submission status: Wrong Answer

Solution code:
#code
N,M=map(int,input().split())
p1=N//2
p2=N//2+1
print(p1,p2)
p1-=1
p2+=1
M-=1
flag=True
while M:
    if(N%(p2-p1)):
        print(p1,p2)
        p1-=1
        p2+=1
        M-=1
    else:
        if(flag):
            p1-=1
            flag=False
        else:
            p2+=1
            flag=True

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
out = []
for i in range(m):
    out.append([i + 1, n - i])
# print(out)
# if len(out) > 1 and n == m:
#     out[0][1], out[1][1] = out[1][1], out[0][1]
for i, j in out:
    print(i, j)