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: Runtime Error

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

if n % 2 == 0:
    i = 1
    while i <= m:
        if i < (n - 2) // 2
            a_i = str(i)
        else:
            a_i = str(i + 1)
        b_i = str(n - i)
        
        print(a_i + " " + b_i)
        i += 1
        
elif n % 2 == 1:
    for i in range(1, m + 1):
        a_i = str(i)
        b_i = str(n - i)
        
        print(a_i + " " + b_i)

Submission status: Runtime Error

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

if n % 2 == 0:
    i = 1
    while i <= m:
        if i < (n - 2) // 2
            a_i = str(i)
        else:
            a_i = str(i + 1)
        b_i = str(n - i)
        
        print(a_i)
        i += 1
        
elif n % 2 == 1:
    for i in range(1, m + 1):
        a_i = str(i)
        b_i = str(n - i)
        
        print(a_i + " " + b_i)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
num=[i for i in range(2,n)]
sub=n-1
print(1,n)
ctr=1
while ctr<m:
  if ctr%2==1:
    sub-=3
    p1=num.pop(0)
    p2=p1+sub
    num.remove(p2)
    print(p1,p2)
  else:
    sub-=1
    p2=num.pop(-1)
    p1=p2-sub
    num.remove(p1)
    print(p1,p2)
  ctr+=1

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
used = [0] * (N+1)
used[0] = 1
cnt = 0
for i in range(1, N+1):
    if not used[i]:
        print(i, i + cnt + 1)
        used[i] = 1
        used[i + cnt + 1] = 1
        cnt += 1
    if cnt == M:
        break

Submission status: Runtime Error

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)　+ 1):
            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
else:
    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: Runtime Error

Solution code:
n,m=map(int,input().split())
num=[i for i in range(1,n+1)]
sub=[i for i in range(1,n+1)]
for i in range(m):
  p1=num.pop(0)
  j=0
  while not(p1+sub[j] in num):
    j+=1
  p2=p1+sub.pop(j)
  num.remove(p2)
  print(p1,p2)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import pysnooper # @pysnooper.snoop()
from pprint import pprint as pp
from pprint import pformat as pf

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

def solve_even(n, m):
    offset = 1
    half = int(n / 2)
    diff = half - 1
    for i in range(m):
        start = offset
        end = start + diff
        if i % 2 != 0:
            start += half
            end += half
            # for next 2 loop
            offset += 1
        print(start, end)
        # for next loop
        diff -= 1



if __name__ == '__main__':
    n, m = map(int, input().split())
    if n % 2 == 0:
        solve_even(n, m)
    else:
        solve_odd(n, m)

Submission status: Runtime Error

Solution code:
def solve(n, m):
    assert m * 2 + 1 <= n
    res = []

    maxi = (n - 1) / 2
    p = 1
    for i in xrange(maxi, 0, -2):
        q = p + i
        res.append([p, q])
        p += 1

    p = maxi + 1 + 1
    if maxi % 2 == 1:
        maxi -= 1
    for i in xrange(maxi, 1, -2):
        q = p + i
        if q > n:
            break
        res.append([p, q])
        p += 1

    # print res
    st1 = set()
    st2 = set()
    assert len(res) >= m
    for (a, b) in res:
        assert 1 <= a <= n
        assert 1 <= b <= n
        assert a != b
        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(7, 3)
'''
solve(6, 2)
solve(15, 6)
solve(9, 4)
solve(12, 5)
solve(10000, 4999)

for i in xrange(1, 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: Runtime Error

Solution code:
n, m = map(int, input().split())
a = n // 2
d = 1
if n % 2 == 0: raise ValueError("error!")
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: Runtime Error

Solution code:
n, m = map(int, input().split())
if n > 100000:
    raise RuntimeError
else:
    print("WA")

Submission status: Runtime Error

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)
        if i < M - 1:
            while X[l] != 0 or X[(l+i+2)%N] != 0:
                l += 1
            r = (l + i + 2) % N
else:
    for i in range(M):
        print(N-i-1, i+1)

Submission status: Runtime Error

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)
        if i < M - 1:
            while X[l] != 0 or X[(l+i+2)%N]:
                l += 1
            r = (l + i + 2) % N
else:
    for i in range(M):
        print(N-i-1, i+1)

Submission status: Runtime Error

Solution code:
from collections import deque

N,M = map(int, input().split())
N = 2 * M + 1

lis = [i for i in range(1,N+1)]
lis1 = deque(lis[:N//2+1])
lis2 = deque(lis[N//2+1:])
if M % 2 == 0:
    
    for i in range(M//2):
        a = lis1.popleft
        b = lis1.pop()
        print(a,b)
    for i in range(M//2):
        a = lis2.popleft
        b = lis2.pop()
        print(a,b)
else:
    for i in range(M//2+1):
        a = lis1.popleft
        b = lis1.pop()
        print(a,b)
    for i in range(M//2):
        a = lis2.popleft
        b = lis2.pop()
        print(a, b)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
l = [x for x in range(1,2*M+2)]
for i in range(1,M+1):
    m = l[0]
    print(str(m) + ' ' + str(m+i))
    l.remove(m)
    l.remove(m+i)

Submission status: Runtime Error

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

if n > 100_000:
  raise

Submission status: Runtime Error

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 or X[(l+i+2)%N]:
            l += 1
        r = (l + i + 2) % N
else:
    for i in range(M):
        print(N-i-1, i+1)

Submission status: Runtime Error

Solution code:
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-1, m+2+i)
    else:
      pritn(m-1, m+1+i)

Submission status: Runtime Error

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

Submission status: Runtime Error

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
M = d*2 + 1
for d in range(1,(N+1)//2):
    print(d,M-d)
    cnt += 1
    if cnt == M:exit()

Submission status: Runtime Error

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
M = d**2 + 1
for d in range(1,(N+1)//2):
    print(d,M-d)
    cnt += 1
    if cnt == M:exit()

Submission status: Runtime Error

Solution code:
n,m = map(int, input().split())
if n > 100000:
  exit(1)

Submission status: Runtime Error

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)　+ 1:
            if (f[0] - 1) % n == 0:
                f[0] = n
            else:
                f[0] = (f[0] - 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: Runtime Error

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

Submission status: Runtime Error

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: Runtime Error

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


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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: Runtime Error

Solution code:
n, m = map(int,input().split())
if n%2 == 1:
    n -= 1
    for i in range(1, m+1):
        print(i, n-i+1)
else:
    a = [False]*(n+1)
    l = 0
    r = 0
    for i in range(1, m+1):
        a[l] = True
        a[r] = True
        while l <= n and r <= n:
            l += 1
            if not a[l]:
                break
        r = l+i
        print(l, r)

Submission status: Runtime Error

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

max_diff = int(N/2)
used_list = [0] * N
flag = False
start = 0
for i in range(M):
    start = 0
    flag = False
    while flag == False:
        if used_list[start] == 0:
            end = start + max_diff
            if start + max_diff > N-1:
                end = start + max_diff - N
            if used_list[end] == 0:
                used_list[start] = 1
                used_list[end] = 1
                print('{0} {1}'.format(start+1, end+1))
                flag = True
        start += 1
    max_diff -= 1

Submission status: Runtime Error

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
        print("tmp", tmp, tmp2, bet, l)
        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]

Submission status: Runtime Error

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)
		print(median-i, median+i+1)


if __name__ == '__main__':
	format_input()

	get_answer()

Submission status: Runtime Error

Solution code:
N,M = map(int, input().split())
player=[i for i in range(1,N+1)]
dis=[j for j in range(1,N)]
for i in range(M):
    k=dis[0]
    a=player[0]
    y=a+dis[0]
    print(a,y)
    dis.remove(k)
    dis.remove(N-k)
    player.remove(a)
    player.remove(y)

Submission status: Runtime Error

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


if n%2==1:
  for i in range(0,m):
    print(i+1,m-i)
else:
  lis1=[]
  lis2=[]
  for i in range(1,m+1):
    lis1.append(i)
    lis2.append(2*m+1-i)
  for k in range(0,len(lis1)):
    if k%2==0:
      print(lis1[k],lis2[-1-k])
    else:
      print(lis1[k],lis2[k])
print(lis1,lis2)

Submission status: Runtime Error

Solution code:
N,M = map(int, input().split())
player=[i for i in range(1,N+1)]
dis=[j for j in range(1,N)]
for i in range(M):
    k=dis[0]
    a=player[0]
    y=a+dis[0]
    print(x,y)
    dis.add(k)
    dis.add(N-k)
    player.remove(a)
    player.remove(y)

Submission status: Runtime Error

Solution code:
import heapq
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:
    used=set()
    for d in range(1,M+1):
        for start in range(N):
            dest = f(start +d)
            if start in used or dest in used:
                continue
            else:
                print(start,dest)
                used.add(start,dest)

Submission status: Runtime Error

Solution code:
import math

A, B, N = map(int, input().split())

temp = -1 * float('inf')
temp2 = -1 * float('inf')



if A > N or B > N:
    temp = math.floor(A*N/B) - A*math.floor(N/B)
if A > B  and B < N:
    temp = math.floor(A*(B-1)/B) - A*math.floor((B-1)/B)
elif A < B and B < N:
    temp = math.floor(A*(B-1)/B) - A*math.floor((B-1)/B)
else:
    x = A - 1
    while x <= N - A:
        if temp <= math.floor(A*x/B) - A*math.floor(x/B):
            temp = math.floor(A*x/B) - A*math.floor(x/B)
            x += A
    if temp <= math.floor(A*N/B) - A*math.floor(N/B):
        temp = math.floor(A*N/B) - A*math.floor(N/B)

print(temp)

Submission status: Runtime Error

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


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

    for x in range(1, M+1):
        print("{} {}".format(x, n//2+(N-x) % (N//2)+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: Runtime Error

Solution code:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

Submission status: Runtime Error

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

def using_sqrt(limit):
    n = 0
    for k in range(2, limit+1):
        factor = 0
        
        # 2以外の偶数は素数ではないので無視する
        if k % 2 == 0 and k != 2:
            continue
        
        # 繰り返しの上限を対象の平方根にする
        for divisor in range(2, math.floor(math.sqrt(k))+1):
            if k % divisor == 0:
                factor += 1
                
        if factor == 0:
            n += 1
            
    return n

for i in range(n):
    if m%using_sqrt(i)==0:
        ans=i
        break
for j in range(m):
    print(i+1,i+1+ans)

Submission status: Runtime Error

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

count = 1
list = []
diffs = []
while True:
    if count >= N - count:
        break
    if count > M:
        break
    if count == 1:
        diff = 1
    else:
        diff = max(diffs) + 1
        while True:
            if not(diffs.__contains__(N-diff)):
                break
            diff += 1
        diffs.append(diff)
    count += 1
    print(diff, N-diff)

Submission status: Runtime Error

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

ans = []
done = 0
i = 1
while done < m and i < n-i+1:
	a, b = i, n-i+1
	diff1 = b - a
	diff2 = a - b + n
	if diff1 == diff2:
		pass
	else:
		ans += (a, b)
		done += 1
	i += 1

if done < m:
	done = 0
	ans = []
	i = 1
	while done < m and i < n-i+1:
		a, b = i, n-i
		diff1 = b - a
		diff2 = a - b + n
		if diff1 == diff2:
			pass
		else:
			ans += (a, b)
			done += 1
		i += 1

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

Submission status: Runtime Error

Solution code:
from collections import defaultdict
n, m = map(int, input().split())

s = 1
f = n
ans = []
d = defaultdict(lambda: False)
i = 0

used = []
while i < m:
    # print(s, f, i)
    tmp = abs(s - f)
    a, b = min(tmp, n - tmp), max(tmp, n - tmp)
    if d[a] or d[b]:
        f -= 1
        continue
    d[a] = True
    d[b] = True
    ans.append(f"{s} {f}")
    used.append(s)
    used.append(f)
    s += 1
    f -= 1
    i += 1
f = False
for i in used:
    if i <= 0 or n < i:
        f = True
if f:
    ans = []
    while i < m:
    # print(s, f, i)
    tmp = abs(s - f)
    a, b = min(tmp, n - tmp), max(tmp, n - tmp)
    if d[a] or d[b]:
        s += 1
        continue
    d[a] = True
    d[b] = True
    ans.append(f"{s} {f}")
    used.append(s)
    used.append(f)
    s += 1
    f -= 1
    i += 1

print("\n".join(ans))

Submission status: Runtime Error

Solution code:
import random
N,M = map(int, input().split())
player=[i for i in range(1,N+1)]
dis=[j for j in range(1,N)]
for i in range(M):
    k=dis[0]
    a=player[0]
    y=a+dis[0]
    print(x,y)
    dis.add(k)
    dis.add(N-k)
    player.remove(a)
    player.remove(y)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
import sys
import math
import heapq
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
from collections import Counter
from math import ceil
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from functools import lru_cache
import random as ra
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########
dist=[0 for i in range(n+34)]
A=deque([i+1 for i in range(n)])
B=deque([])
i=0
a=A.popleft() ; b=A.pop()

while 1:


    if dist[b-a]==0 and dist[a+n-b]==0:
        print(a,b)
        dist[b-a]=1
        dist[a+n-b]=1

        i+=1
        a=A.popleft() ; b=A.pop()
    else:
        
        A.appendleft(a)
        A.append(b)
        while 1:
            a=ra.sample(A,1)[0] ; b=ra.sample(A,1)[0]
            if a<b : break
        
    if i==m:
        exit()

Submission status: Runtime Error

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

Submission status: Runtime Error

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():
	unused = list(range(n))

	for i in range(m):
		a = unused[0]
		b = unused[0]+i+1
		unused.remove(a)
		unused.remove(b)
		print(a+1, b+1)	


if __name__ == '__main__':
	format_input()

	get_answer()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,M = map(int,input().rstrip().split(" "))
ans = [[False for _ in range(N)] for _ in range(N)]

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

Submission status: Runtime Error

Solution code:
import random
N,M = map(int, input().split())
player=[i for i in range(1,N+1)]
dis=[j for j in range(1,N)]
for i in range(M):
    k=dis[0]
    a=player[0]
    y=a+dis[0]
    print(x,y)
    dis.add(k)
    dis.add(N-k
    player.remove(a)
    player.remove(y)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

fib = [1]

N,M = m()

co = 1
while True:
    a = fib[-1] + co
    if len(fib) >= M:
        break
    fib.append(a)
    co += 1



if N % 2 == 0:
    po = [0 for i in range(N)]
    start = 0
    for i in range(-(-M//2)):
        aa = fib[-(i+1)]
        po[start] = 1
        po[start+aa] = 1
        print(start+1,start+aa+1)
        start += 1
        if i != M//2:
            bb = fib[i]
            for j in range(N-1,-1,-1):
                if po[j] == 0 and po[j-bb] == 0:
                    po[j] = 1
                    po[j-bb] = 1
                    print(j+1,j-bb+1)
                    break  

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
used = [0] * (N+1)
used[0] = 1
for i in range(1, M+1):
    a = used.index(0)
    b = a + i
    used[a] = 1
    used[b] = 1
    print(a, b)

Submission status: Runtime Error

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

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
#Dストックを昇順で生成する。
Dstock = {}
Nstock = {}
for i in range(1,N):
    Dstock[i]=""
    Nstock[i]=""
Nstock[N] = ""

count = 0
while Nstock and count<M:
    count += 1
    for i in Dstock.keys():
        for j in Nstock.keys():
            print(j,j+i)
            del Nstock[j]
            del Nstock[j+i]
            del Dstock[i]
            if N-i in Dstock:
                del Dstock[N-i]
            break
        else:
            continue
        break

Submission status: Runtime Error

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:
        st = set(range(1,N+1))
        for i in range(1,M+1):
            v,s =0,0
            for j in st:
                if j+i in st:
                    v,s=j,j+i
                    break
            print(v,s)
            st.remove(v)
            st.remove(s)
            


resolve()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
# coding: utf-8
import math

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

# 素数判定関数
def isPrime(num):
    # 2未満の数字は素数ではない
    if num < 2: return False
    # 2は素数
    elif num == 2: return True
    # 偶数は素数ではない
    elif num % 2 == 0: return False

    # 3 ~ numまでループし、途中で割り切れる数があるか検索
    # 途中で割り切れる場合は素数ではない
    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False

    # 素数
    return True

# 素数判定
def callIsPrime(input_num=1000):
    numbers = []
    # ループしながら素数を検索する
    for i in range(1, input_num):
        if isPrime(i):
            numbers.append(i)

    # 素数配列を返す
    return numbers
used=[False for i in range(1000000)]
P=callIsPrime(100000)
L=[1]
L.extend(P)

for i in range(len(L)):
    if L[i]>N-1:
        index=i-1
        break
cnt=1
C=0
K=0
while True:
    if not used[cnt] and not used[cnt+L[index-K]]:
        print(cnt,cnt+L[index-K])
        used[cnt]=True
        used[cnt+L[index-K]]=True
        C+=1
        K+=1
        cnt+=1
    elif used[cnt]:
        cnt+=1
    elif used[cnt+L[index-K]]:
        K+=1
    if C==M:
        break

Submission status: Runtime Error

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