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

Solution (Python):


import sys
readline = sys.stdin.readline
read = sys.stdin.read

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

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

Solution (Python):
import sys

stdin = sys.stdin

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

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

Solution (Python):
N, M = map(int, input().split())
a, b = 1, N
S = set()
for _ in range(M):
    print(a, b)
    S.add(b - a)
    S.add(a + N - b)
    a += 1
    b -= 1
    if b - a in S or a + N - b in S or b - a << 1 == N:
        b -= 1

Solution (Python):
N, M = map(int, input().split())
a, b = 1, N
S = set()
for _ in range(M):
    print(a, b)
    S.add(b - a)
    S.add(a + N - b)
    a += 1
    b -= 1
    if b - a in S or a + N - b in S or b - a << 1 == N:
        b -= 1

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

even = M//2
odd = (M+1)//2
B = odd*2
K = B+even*2
ans = []
for n in range(1, odd+1):
    print(n, B-n+1)
for n in range(1, even+1):
    print(B+n, K-n+2)

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

odd = 0
even = 0

minimum_number = 0
maximum_number = 0

for i in range(m):
    number = i + 1
    if number % 2 == 1:
        minimum_number = 1 + odd
        maximum_number = (1+m) - odd
        odd += 1
    else:
        minimum_number = m + 2 + even
        maximum_number = 2 * m + 1 - even
        even += 1
    print("{} {}".format(minimum_number, maximum_number))

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, m = LI()
if m == 1:
    print(1, 2)
else:
    l1 = 1
    r1 = l1 + m
    l2 = r1 + 1
    r2 = l2 + m - 1
    while True:
        if l1 >= r1:
            break
        print(l1, r1)
        if l2 >= r2:
            break
        print(l2, r2)
        l1 += 1
        l2 += 1
        r1 -= 1
        r2 -= 1

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

Solution (Python):

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

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

Solution (Python):
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())
    if N & 1:
        for i in range(1, M+1):
            print(i, N - i)
    else:
        flg = 1
        for i in range(1, M+1):
            if flg:
                a = i
                b = N + 1 - i
                if b - a <= N - (b-a):
                    flg = 0
                    b -= 1
                print(a, b)
            else:
                print(i, N-i)


if __name__ == '__main__':
    main()

Solution (Python):
import sys

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

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

Solution (Python):
n, m = map(int, input().split())
ans = []
p = 1
q = 2 * ((m + 1) // 2)
for i in range((m + 1) // 2):
    ans.append((p, q))
    p += 1
    q -= 1
p = 2 * ((m + 1) // 2) + 1
q = p + (m // 2) * 2
for i in range(m // 2):
    ans.append((p, q))
    p += 1
    q -= 1
for row in ans[:m]:
    print(row[0], row[1])

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

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

Solution (Python):
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

A = np.arange(M)
B = 2 * M - 1 - A
B[:M//2] -= (2*M+1)

A %= N
B %= N
A += 1
B += 1
for a, b in zip(A.tolist(), B.tolist()):
    print(a,b)