Problem:


Score : 500 points

Problem Statement

You are going to hold a competition of one-to-one game called AtCoder Janken. (Janken is the Japanese name for Rock-paper-scissors.)
N players will participate in this competition, and they are given distinct integers from 1 through N.
The arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive).
You cannot assign the same integer to multiple playing fields.
The competition consists of N rounds, each of which proceeds as follows:

For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there.

Then, each player adds 1 to its integer. If it becomes N+1, change it to 1.

You want to ensure that no player fights the same opponent more than once during the N rounds.
Print an assignment of integers to the playing fields satisfying this condition.
It can be proved that such an assignment always exists under the constraints given.

Constraints

1 \leq M

M \times 2 +1 \leq N \leq 200000

Input

Input is given from Standard Input in the following format:

N M

Output

Print M lines in the format below.
The i-th line should contain the two integers a_i and b_i assigned to the i-th playing field.

a_1 b_1
a_2 b_2
:
a_M b_M

Sample Input 1

4 1

Sample Output 1

2 3

Let us call the four players A, B, C, and D, and assume that they are initially given the integers 1, 2, 3, and 4, respectively.

The 1-st round is fought by B and C, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 2, 3, 4, and 1, respectively.

The 2-nd round is fought by A and B, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 3, 4, 1, and 2, respectively.

The 3-rd round is fought by D and A, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 4, 1, 2, and 3, respectively.

The 4-th round is fought by C and D, who has the integers 2 and 3, respectively. After this round, A, B, C, and D have the integers 1, 2, 3, and 4, respectively.

No player fights the same opponent more than once during the four rounds, so this solution will be accepted.

Sample Input 2

7 3

Sample Output 2

1 6
2 5
3 4



Sample input:
4 1


Sample output:
2 3

Submission status: Wrong Answer

Solution code:
N,M= list(map(int , input().split()))
k = N//2
s = N %2
if s == 1:
    for i in range (M):
        n = i+1
        print (n,N-n)
elif s == 0:
    w = 0
    n = 1
    for i in range (M):
        print (n,n + i + 1)
        n = n + 2 + i

Submission status: Wrong Answer

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

a = 1
b = N

for i in range(M):
    if N%2 == 0 and b-a == N/2-2:
        b = b+1
    
    print(a, b)
    
    a = a + 1
    b = b - 1

Submission status: Wrong Answer

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

n = N // 2

for i in range(M):
    A = n - i
    B = n + i + 1
    print(A,B)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N,M = [int(hoge) for hoge in input().split()]
#Mが偶数のとき...1以上M//2"未満"のd
#Mが奇数のとき...1以上(M+1)//2"未満"のd
#どちらも1以上M-1//2以下
cnt = 0
X = M*2 + 1
for d in range(1,(N+1)//2):
    print(d,X-d)
    cnt += 1
    if cnt == M:exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
def main():
    n,m = map(int,input().split())
    ans = []
    r = 2*m+1

    for i in range(1,m//2+1):
        ans.append([i,m+1-i])
    for i in range(m+1,(m+1+r)//2+1):
        ans.append([i,m+1+r-i])
    
    for a in ans:
        print(*a)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# E

inp = input().split(' ')
N, M = int(inp[0]), int(inp[1])
sizes_even, sizes_odd = sorted(list(range(0, M, 2)), reverse=True), sorted(list(range(1, M, 2)), reverse=True)

import math
M2_ceil = math.ceil(M/2.0)
M2_flor = math.floor(M/2.0)
half = math.floor(N/2.0)
pairs = []
for i in range(M2_ceil):
    pairs.append([1+i, 1+i+sizes_even[i]+1])
for i in range(M2_flor):
    pairs.append([half+i+2, half+2+i+sizes_odd[i]+1])
    
for pair in pairs:
    print(pair[0], pair[1])

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
def main():
    n,m = map(int,input().split())
    ans = []
    r = 2*m+1

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = 0
for i in range(m):
    l = i+1
    r = n-i
    if r-l == n+l-r:
        a = 1
    print('{} {}'.format(l, r-a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def solve(n, m):
    res = []

    p, q = 1, (n + 1) / 2
    while (q - p) % 2 == 0:
        q += 1
    pivot = q + 1
    while p < q:
        res.append([p, q])
        p += 1
        q -= 1
    p, q = pivot, n
    while (q - p) % 2 != 0:
        p += 1
    while p < q:
        res.append([p, q])
        p += 1
        q -= 1

    st1 = set()
    st2 = set()
    for (a, b) in res:
        assert not (set([a, b]) & st1)
        st1 |= set([a, b])
        diff = abs(a - b)
        assert not (set([diff, n - diff]) & st2)
        st2 |= set([diff, n - diff])
    return res[:m]


'''
solve(6, 2)
solve(15, 6)
solve(9, 4)
solve(7, 3)
solve(12, 5)

for i in xrange(100):
    for j in xrange(1, (i - 1) / 2 + 1):
        # print i, j
        solve(i, j)
'''

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

assert m * 2 + 1 <= n

for a, b in solve(n, m):
    print a, b

Submission status: Wrong Answer

Solution code:
a,b= map(int,input().split())
dp = [i for i in range(1,a+1)]
dp2 = [1+2*i for i in range(b)]
cnt = b

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

Submission status: Wrong Answer

Solution code:
def solve(n, m):
    res = []

    p, q = 1, (n + 1) / 2
    while (q - p) % 2 == 0:
        q += 1
    pivot = q + 1
    while p < q:
        res.append([p, q])
        p += 1
        q -= 1
    p, q = pivot, n
    while (q - p) % 2 != 0:
        p += 1
    while p < q:
        res.append([p, q])
        p += 1
        q -= 1

    st1 = set()
    st2 = set()
    for (a, b) in res:
        assert not (set([a, b]) & st1)
        st1 |= set([a, b])
        diff = abs(a - b)
        assert not (set([diff, n - diff]) & st2)
        st2 |= set([diff, n - diff])

    return res[m:]


solve(6, 2)
solve(15, 6)
solve(9, 4)
solve(7, 3)
solve(12, 5)

for i in xrange(100):
    for j in xrange(1, (i - 1) / 2 + 1):
        # print i, j
        solve(i, j)

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

assert m * 2 + 1 <= n

for a, b in solve(n, m):
    print a, b

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

Solution code:
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/input.txt"
exit $?
'''
import sys

def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    n, m = _ia()
    ret = []
    if n % 2 == 1:
        ai, bi = 1, n
        for i in range(m):
            ret.append(f"{ai} {bi}")
            ai+=1
            bi-=1
    else:
        ai = n // 2
        bi = ai + 1
        for i in range(n//4):
            ret.append(f"{ai} {bi}")
            ai -= 1
            bi += 1
        ret.append(f"1 {n-1}")
        ret.append(f"2 {n-2}")
    return "\n".join(ret[:m])


if __name__ == "__main__":
    print(main())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/input.txt"
exit $?
'''
import sys

def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    n, m = _ia()
    ret = []
    if n % 2 == 1:
        ai, bi = 1, n
        for i in range(m):
            ret.append(f"{ai} {bi}")
            ai+=1
            bi-=1
    else:
        ai, bi = 4, 5
        for i in range(n//4):
            ret.append(f"{ai} {bi}")
            ai -= 1
            bi += 1
        ret.append(f"1 {n-1}")
        ret.append(f"2 {n-2}")
    return "\n".join(ret[:m])


if __name__ == "__main__":
    print(main())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
def main():
    n,m = map(int,input().split())
    ans = []
    if m%2:
        l = 1
        r = m
        while l+1<r:
            ans.append([l,r])
            l += 1;r-=1
        l = r+1
        r = 2*m+1
        while l<r:
            ans.append([l,r])
            l+=1;r-=1
    else:
        l = 1
        r = m+1
        while l+1<r:
            ans.append([l,r])
            l += 1;r-=1
        l = r+1
        r = 2*m+1
        while l<r:
            ans.append([l,r])
            l+=1;r-=1
    
    for a in ans:
        print(*a)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = 0
for i in range(m):
    if (n-i + n - 2*i - 1) % n == i+1:
        a = 1
    print('{} {}'.format(i+1, n-i-a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
def main():
    n,m = map(int,input().split())
    ans = []
    if m%2:
        l = 1
        r = m
        while l+1<r:
            ans.append([l,r])
            l += 1;r-=1
        l = r
        r = 2*m+1
        while l<r:
            ans.append([l,r])
            l+=1;r-=1
    else:
        l = 1
        r = m+1
        while l+1<r:
            ans.append([l,r])
            l += 1;r-=1
        l = r
        r = 2*m+1
        while l<r:
            ans.append([l,r])
            l+=1;r-=1
    
    for a in ans:
        print(*a)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N,M = [int(hoge) for hoge in input().split()]
#Mが偶数のとき...1以上M//2"未満"のd
#Mが奇数のとき...1以上(M+1)//2"未満"のd
#どちらも1以上M-1//2以下
cnt = 0
for d in range(1,(N+1)//2):
    print(d,d*2)
    cnt += 1
    if cnt == M:exit()

Submission status: Wrong Answer

Solution code:
# E

inp = input().split(' ')
N, M = int(inp[0]), int(inp[1])
sizes_even, sizes_odd = sorted(list(range(0, M, 2)), reverse=True), sorted(list(range(1, M, 2)), reverse=True)

import math
M2_ceil = math.ceil(M/2.0)
M2_flor = math.floor(M/2.0)
half = math.floor(N/2.0)
pairs = []
for i in range(M2_ceil):
    pairs.append([1+i, 1+i+sizes_even[i]+1])
for i in range(M2_flor):
    pairs.append([half+i+1, half+1+i+sizes_odd[i]+1])
    
for pair in pairs:
    print(pair[0], pair[1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# E

inp = input().split(' ')
N, M = int(inp[0]), int(inp[1])
sizes_even, sizes_odd = sorted(list(range(0, M, 2)), reverse=True), sorted(list(range(1, M, 2)), reverse=True)

import math
M2_ceil = math.ceil(M/2.0)
M2_flor = math.floor(M/2.0)
half = math.floor(N/2.0)
pairs = []
for i in range(M2_ceil):
    pairs.append([1+i, 1+i+sizes_even[i]+1])
for i in range(M2_flor):
    pairs.append([1+half+i+1, 1+half+1+i+sizes_odd[i]+1])
    
for pair in pairs:
    print(pair[0], pair[1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M = list(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,N-i-1)

Submission status: Wrong Answer

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

l = 0
num = set()
step = set()
for k in range(1, M + 1):
    print(l + 1, (l + k) % N + 1)
    num.add(l)
    num.add((l + k) % N)
    while l in num:
        l += 1
        l %= N

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
decided = [False] * (n+1)
for i in range(m+1):
    decided[i] = True

ans = []
diff = n - 1
diff_a = diff
while len(ans) < m:
    i = len(ans) + 1
    diff_a = diff
    while True:
        if diff_a == 0:
            raise RuntimeError
        if i + diff_a > m and not decided[i+diff_a]:
            ans.append(i+m)
            decided[i+m] = True
            diff -= 1
            break
        elif not decided[i + n - diff_a]:
            ans.append(i + n - diff_a)
            decided[i + n - diff_a] = True
            diff -= 1
            break
        else:
            diff_a -= 1
            
        
        
for i, v in enumerate(ans):
    print(i+1, v)

Submission status: Wrong Answer

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

import sys
import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, m = mi()
    L = [i for i in range(1, n+1)]
    if n % 2 == 1:
        for dist in range(m):   
            print(f"{L[dist]} {L[-1-dist]}")
    else:
        cnt = 0
        if (n - 2) % 4 == 0:
            tmp = (n - 2) // 4
        else:
            tmp = (n - 2) // 4 + 1
        for dist in range(min(m, tmp)):
            cnt += 1
            print(f"{L[dist]} {L[-1-dist]}")
        for dist in range(m - cnt):
            print(f"{L[dist]} {L[-2-dist]}")



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sup_n = m * 2 + 1
odd_start = sup_n // 4 + 1
even_start = ((sup_n - 1) // 2) * 2 - 1
print(odd_start, odd_start + 1)
odd_start -= 1
for i in range(1, m):
    if i % 2 == 1:
        print(odd_start, odd_start + i + 2)
        odd_start -= 1
    else:
        print(even_start, even_start + i)
        even_start -= 1

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
X = [0 for _ in range(N)]
if N % 2 == 0:
    l, r = 0, 1
    for i in range(M):
        X[l] = 1
        X[r] = 1
        print(l+1, r+1)
        while X[l] != 0:
            l += 1
        r = (l + i + 2) % N
else:
    for i in range(M):
        print(N-i-1, i+1)

Submission status: Wrong Answer

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

n = N // 2

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
def main():
    n,m = map(int,input().split())
    if m%2:
        ans = [[n//2,n//2+1]]
    else:
        ans = [[n//2+1,n//2+2]]
    for _ in range(m-1):
        v = ans[-1]
        new = [v[0]-1,v[1]+1]
        if new[0] == 0:
            new[0] = n
        if new[1] > n:
            new[1] = 1
        ans.append(new)
    for a in ans:
        print(*a)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

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

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

else:

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

Submission status: Wrong Answer

Solution code:


n, m = [0] * 2

def format_input(filename = None):
	global n, m
	if filename == None:
		n, m = list(map(int, input().split()))

	elif filename == '__random__':
		from random import randint as rng
		n = rng(3, 10**5)
		m = rng(1, (n-1) // 2)
		print(n, m)

def get_answer():
	median = n // 2

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


if __name__ == '__main__':
	format_input()

	get_answer()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
com = list(map(int,input().split()))
N = com[0]
M = com[1]

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

Submission status: Wrong Answer

Solution code:
# E

inp = input().split(' ')
N, M = int(inp[0]), int(inp[1])
sizes_even, sizes_odd = sorted(list(range(0, M, 2)), reverse=True), sorted(list(range(1, M, 2)), reverse=True)

import math
M2_ceil = math.ceil(M/2.0)
M2_flor = math.floor(M/2.0)
pairs = []
for i in range(M2_ceil):
    pairs.append([1+i, 1+i+sizes_even[i]+1])
for i in range(M2_flor):
    pairs.append([1+M2_ceil+1+i+1, 1+M2_ceil+1+i+1+sizes_odd[i]+1])
    
for pair in pairs:
    print(pair[0], pair[1])

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
flag = [False]*(10**6)
plu_flag = [False]*(10**6)
plu_max = M
plu_min = 1
even_odd = 1
for i in range(1,N+1):
  if M==0:
    break
    
  if even_odd%2==1:
    if (flag[i])or(flag[i+plu_max]):
      continue
    if (plu_flag[plu_max])or(plu_flag[N-plu_max]):
      plu_max+=1
      continue
    plu_flag[plu_max]=True
    plu_flag[N-plu_max]=True
    flag[i]=True
    flag[i+plu_max]=True
    print(i,i+plu_max)
    plu_max-=1
    M-=1
    even_odd+=1
  else:
    if (flag[i])or(flag[i+plu_min]):
      continue
    if (plu_flag[plu_min])or(plu_flag[N-plu_min]):
      plu_min-=1
      continue
    plu_flag[plu_min]=True
    plu_flag[N-plu_min]=True
    flag[i]=True
    flag[i+plu_min]=True
    print(i,i+plu_min)
    plu_min+=1
    M-=1
    even_odd+=1

Submission status: Wrong Answer

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

skip = 0
remain = set(range(N))

#print(remain)

for i in range(1, M + 1 + skip):
  lo = i
  hi = N + 1 - i
  short = hi - lo - 1
  long = N + lo - hi - 1
  #print(lo, hi, short, long)
  if {short, long} <= remain:
    print(f'{lo} {hi}')
    remain -= {short, long}
  else:
    skip += 1

Submission status: Wrong Answer

Solution code:
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
#      .      '                    Udit Gupta @luctivud         ,              
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                            ##     ##  #######  # #  ######
                            ##     ##  ##   ##  ###    ##
                            ##     ##  ##    #  # #    ##
                            #########  #######  # #    ##
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import sys
import math
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))

def printwsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end="tst, ")

MOD = int(1e9+7); BABYMOD = 998244353;
# ################################ HELPER PROGRAMS USED ###################################
# ################################## MAIN STARTS HERE #####################################
# for _testcases_ in range(int(input())):
n, m = get_ints()
a = 1; b = n//2;
c = b+1; d = n
rest = m - (m//2)
for i in range(m//2):
    print(a+i, b-i)
for i in range(rest):
    print(a+i, b-i)


# #########################################################################################
'''
THE LOGIC AND APPROACH WAS DEVELOPED BY ME @luctivud.
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
PLEASE DO NOT PLAGIARISE.
'''

Submission status: Wrong Answer

Solution code:
tmp = input().split()
N = int(tmp[0])
M = int(tmp[1])
#Q = int(tmp[2])
VS = [[0 for i in range(2)] for j in range(M)]

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

print(VS)
for NUM in VS:
    print(NUM[0],NUM[1])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
l = list(range(1, N+1))
bet = 1

for i in range(M):
    flag = 1
    tmp = min(l)
    tmp_ind = l.index(tmp)
    while flag:
        tmp2 = tmp + bet
        if tmp2 > N:
            tmp2 = tmp2 % N
        if tmp2 in l and tmp != tmp2:
            print(tmp, tmp2)
            l.remove(tmp)
            l.remove(tmp2)
            flag = 0
            bet += 1
            break
        tmp_ind += 1
        if tmp_ind == len(l):
            tmp_ind = 0
            bet += 1
        tmp = l[tmp_ind]