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=map(int,input().split())
num=[i for i in range(1,(n+1)//2*2)]
for i in range(m):
  p1=num.pop(0)
  p2=num.pop(-1)
  print(p1,p2)

Submission status: Wrong Answer

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

while True:
  start = 1
  end = M
  print(start,end)
  start+=1
  end-=1
  if start>=end:
    break
  
while True:
  start = M+1
  end = 2*M+1
  print(start,end)
  start+=1
  end-=1
  if start>=end:
    break

Submission status: Wrong Answer

Solution code:


def solve():
    if n % 2 ==0:
        aa = list(range(1, m +1))
        bb = list(reversed(range(m+1, 2*m+1)))
    else:
        aa = list(range(1, m + 1))
        bb = list(reversed(range(m + 2, 2 * m + 2)))
    for a, b in zip(aa,bb):
        print(a , b)
    return


# n = int(input())
n, m = [int(s) for s in input().split(" ")]
solve()

Submission status: Wrong Answer

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

for ai in ans:
    print(*ai)

Submission status: Wrong Answer

Solution code:


def solve():
    if n % 2 ==1:
        aa = list(range(1, m +1))
        bb = list(reversed(range(m+1, 2*m+1)))
    else:
        aa = list(range(1, m + 1))
        bb = list(reversed(range(m + 2, 2 * m + 2)))
    for a, b in zip(aa,bb):
        print(a , b)
    return


# n = int(input())
n, m = [int(s) for s in input().split(" ")]
solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#嘘だが見てみる
n,m=map(int, input().split( ))
ans=[(i,2*m+1-i) for i in range(1,m+1)]
for ai in ans:
    print(*ai)

Submission status: Wrong Answer

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

i = 0
while i < m:
    if n % 2 == 0:
        n -= 1
    if n%2 == 0 and n-2*(i+1) == n//2:         
        n -= 1
    print(i+1,n-i)
    i += 1

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

i = 0
while i < m:
    if n%2 == 0 and n-2*(i+1) == n//2:         
        n -= 1
    print(i+1,n-i)
    i += 1

Submission status: Wrong Answer

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

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

if N%2 == 1:
    for i in range(min(int(N//2),M)):
        print(i+1,N-(i+1))
else:
    counter = []
    t = 1
    for i in range(N):
        if i+1 in counter or  i+1+t in counter:
            continue
        else:
            print(i+1,i+1+t)
            counter.append(i+1)
            counter.append(i+1+t)
            t += 1
        if t == M+1:
            break

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+2)/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: Wrong Answer

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

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

if N%2 == 1:
    for i in range(min(int(N//2),M)):
        if i == int(N/2-1):
            print(i+1, N)
        else:
            print(i+1,N-(i+1))
else:
    counter = []
    t = 1
    for i in range(N):
        if i+1 in counter or  i+1+t in counter:
            continue
        else:
            print(i+1,i+1+t)
            counter.append(i+1)
            counter.append(i+1+t)
            t += 1
        if t == M+1:
            break

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+2)/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: Wrong Answer

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

Submission status: Wrong Answer

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

ant = math.floor((N - 2*M)/2)

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

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) + 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: Wrong Answer

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

Submission status: Wrong Answer

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

if N%2==0:
    N-=1

half=N//2

if half%2==0:
    for i in range(half//2):
        ans.append((i+1,half-i))
    for j in range(half//2):
        ans.append((half+1+j,N-j))
else:
    for i in range(half//2):
        ans.append((i+1,half-i))
    for j in range(half//2+1):
        ans.append((half+1+j,N-j))

#print(ans)
for i in ans:
    print(*i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = []
n = M // 2
for i in range(n):
    ans.append([i + 1, 2 * n + 1 - i])

for i in range(M - n):
    ans.append([2 * n + 2 + i, N - i])

for v in ans:
    print(*v)

Submission status: Wrong Answer

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

m = (n-1) // 2
a = (n - 1) // 2
d = 1
memo = set([])
for i in range(m):
    if n - d in memo or d * 2 == n:
        d += 1
    memo.add(d)
    # if a < 1 or a+d > n:
    #     print(1/0)
    print(a, a+d)
    a -= 1
    d += 2

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = []
for i in range(M):
    ans.append([i + 2, 2 * M + 2 - i])

for v in ans:
    print(*v)

Submission status: Wrong Answer

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

ans = [[0, 0] for i in range(M)]

half = N // 2

for i in range(M):
    j = M - i - 1
    ans[j] = [half-i, half+i+1]

for i in range(M):
    print(*ans[i])

Submission status: Wrong Answer

Solution code:


def solve():
    aa = list(range(1, m +1))
    bb = list(reversed(range(m+1, 2*m+1)))
    for a, b in zip(aa,bb):
        print(a , b)
    return


# n = int(input())
n, m = [int(s) for s in input().split(" ")]
solve()

Submission status: Wrong Answer

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())
half=n//2
lst=[]
tmp=0
if n%2==0:
    tmp=1
for i in range(m):
    if i%2==1:
        lst.append([half-i//2,half+i//2+1])
    else:
        lst.append([1+i//2,n-i//2])

for i in range(m):
    print(*lst[i])

# dic=defaultdict(int)
# for i in range(m):
#     tmp=lst[i]
#     dic[tmp[1]-tmp[0]]+=1
#     dic[n-tmp[1]+tmp[0]]+=1
# print(dic)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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())
half=n//2
lst=[]
tmp=0
if n%2==0:
    tmp=1
for i in range(m):
    if i%2==0:
        lst.append([half-i//2,half+i//2+1])
    else:
        lst.append([1+i//2,n-i//2])

for i in range(m):
    print(*lst[i])

# dic=defaultdict(int)
# for i in range(m):
#     tmp=lst[i]
#     dic[tmp[1]-tmp[0]]+=1
#     dic[n-tmp[1]+tmp[0]]+=1
# print(dic)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from collections import *
n,m = map(int,input().split())
d = dict()
i,j = 1,n
for y in range(m):
	print(i,j)
	i += 1
	j -= 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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())
half=n//2
lst=[]
# if n%2==1:
#     for i in range(m):
#         lst.append([half-i,half+i+1])
# else:
#     for i in range(m):
#         if i%2==0:
#             lst.append([half-i//2,half+i//2+1])
#         else:
#             lst.append([1+i//2,n-1+i//2])
tmp=0
if n%2==0:
    tmp=1
for i in range(m):
    lst.append([half-i,half+i+1])

for i in range(m):
    print(*lst[i])

# dic=defaultdict(int)
# for i in range(m):
#     tmp=lst[i]
#     dic[tmp[1]-tmp[0]]+=1
#     dic[n-tmp[1]+tmp[0]]+=1
# print(dic)

Submission status: Wrong Answer

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())
half=n//2
lst=[]
# if n%2==1:
#     for i in range(m):
#         lst.append([half-i,half+i+1])
# else:
#     for i in range(m):
#         if i%2==0:
#             lst.append([half-i//2,half+i//2+1])
#         else:
#             lst.append([1+i//2,n-1+i//2])
tmp=0
if n%2==0:
    tmp=1
for i in range(m):
    lst.append([half-i,half+i+1+tmp])

for i in range(m):
    print(*lst[i])

# dic=defaultdict(int)
# for i in range(m):
#     tmp=lst[i]
#     dic[tmp[1]-tmp[0]]+=1
#     dic[n-tmp[1]+tmp[0]]+=1
# print(dic)

Submission status: Wrong Answer

Solution code:
n,m=map(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: Wrong Answer

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

ans = []
for i in range(M):
    ans.append([i + 2, 2 * M + 1 - i])
    
for v in ans:
    print(*v)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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())
half=n//2
lst=[]
if n%2==1:
    for i in range(m):
        lst.append([half-i,half+i+1])
else:
    for i in range(m):
        if i%2==0:
            lst.append([half-i//2,half+i//2+1])
        else:
            lst.append([1+i//2,n-1+i//2])

for i in range(m):
    print(*lst[i])

# dic=defaultdict(int)
# for i in range(m):
#     tmp=lst[i]
#     dic[tmp[1]-tmp[0]]+=1
#     dic[n-tmp[1]+tmp[0]]+=1
# print(dic)

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 = [eval(v) for v in input().strip().split(" ")]

middle = int(N / 2)

for i in range(M - 1, -1, -1):
    print("%s %s" % (middle - i, middle + 1 + i))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

aa = n//2
bb = aa+1

if n%2==1 or n==4:
    for i in range(m):
        print(aa,bb)
        aa-=1
        if aa==0:
            aa=n
        bb+=1
        if bb ==n+1:
            bb=1
else:
    bb = aa+2
    for i in range(m):
        print(aa,bb)
        bb+=1
        aa-=1

        if bb==n:
            bb=1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

s1 = 1
f1 = m
s2 = f1 + 1
f2 = n
if (f1 - s1) % 2 == (f2 - s2) % 2:
    f2 -= 1
ans = []
while f1 > s1:
    ans.append(f"{s1} {f1}")
    s1 += 1
    f1 -= 1

while f2 > s2:
    ans.append(f"{s2} {f2}")
    s2 += 1
    f2 -= 1

print("\n".join(ans[:m]))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

    maxi = (n - 1) / 2
    if maxi % 2 == 0:
        maxi += 1
    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:
            continue
        res.append([p, q])
        p += 1

    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(9, 4)
solve(6, 2)
solve(7, 3)
solve(15, 6)
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: Wrong Answer

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

    maxi = (n - 1) / 2
    if maxi % 2 == 0:
        maxi += 1
    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:
            continue
        res.append([p, q])
        p += 1

    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(9, 4)
solve(6, 2)
solve(7, 3)
solve(15, 6)
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: Wrong Answer

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


k = N - 1
for l in range(1, M + 1):
    print(l, l + k)
    k -= 2

Submission status: Wrong Answer

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

s1 = 1
f1 = m + 1
s2 = f1 + 1
f2 = n
if (f1 - s1) % 2 == (f2 - s2) % 2:
    f2 -= 1
ans = []
while f1 > s1:
    ans.append(f"{s1} {f1}")
    s1 += 1
    f1 -= 1

while f2 > s2:
    ans.append(f"{s2} {f2}")
    s2 += 1
    f2 -= 1

print("\n".join(ans[:m]))

Submission status: Wrong Answer

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

s1 = 1
f1 = m + 1
s2 = f1 + 1
f2 = n
ans = []
while f1 > s1:
    ans.append(f"{s1} {f1}")
    s1 += 1
    f1 -= 1

while f2 > s2:
    ans.append(f"{s2} {f2}")
    s2 += 1
    f2 -= 1

print("\n".join(ans[:m]))

Submission status: Wrong Answer

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()
    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(6, 2)
solve(15, 6)
solve(9, 4)
solve(7, 3)
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: Wrong Answer

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

if a%2==1:


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

else:
    A = 1
    B = a
    for i in range(b):
        print(A,B)
        A+=1
        B-=1

Submission status: Wrong Answer

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

s1 = 1
f1 = n // 2
s2 = f1 + 1
f2 = n
ans = []
while f1 > s1:
    ans.append(f"{s1} {f1}")
    s1 += 1
    f1 -= 1

while f2 > s2:
    ans.append(f"{s2} {f2}")
    s2 += 1
    f2 -= 1

print("\n".join(ans[:m]))

Submission status: Wrong Answer

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

    maxi = n / 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()
    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(6, 2)
solve(15, 6)
solve(9, 4)
solve(7, 3)
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: Wrong Answer

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

Submission status: Wrong Answer

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

s1 = 1
f1 = n // 2
s2 = f1 + 1
f2 = n
ans = []
while f1 > s1:
    ans.append(f"{s1} {f1}")
    s1 += 1
    f1 -= 1
while f2 > s2:
    ans.append(f"{s2} {f2}")
    s2 += 1
    f2 -= 1

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

s1 = 1
f1 = n // 2
s2 = f1 + 1
f2 = n
ans = []
while len(ans) < m:
    ans.append(f"{s2} {f2}")
    ans.append(f"{s1} {f1}")
    s1 += 1
    f1 -= 1
    s2 += 1
    f2 -= 1

print("\n".join(ans[:m]))

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-3
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:
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
    for i in range(m):
        print(*[half-i,half+i+1])
else:
    half=n//2
    for i in range(m):
        if i%2==0:
            print(*[half-i//2,half+i//2+1])
        else:
            print(*[1+i//2,n-1+i//2])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

from collections import deque

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

if n % 2 ==0:
    for i in range(1, m + 1):
        a, b = l.popleft(), l.pop()
        if (b - a) == n / 2:
            b = l.pop()
        print(a, b)
else:
    for i in range(1, m + 1):
        print(i, n - i)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
if n % 4 == 0:
    a = 2
elif n % 2 == 0:
    a = 1
else:
    a = 0

for i in range(m):
    print('{} {}'.format(i+1, n-i-a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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:
# 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.ceil(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, half+i+sizes_odd[i]+1])
    
for pair in pairs:
    print(pair[0], pair[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)%N)
    cnt += 1
    if cnt == M:exit()