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

used = [False] * (N + 1)
ans = []
cur = 1
for i in range(1, M + 1):
    while used[cur]:
        cur += 1
    l = cur
    r = cur + i
    if (r - l) == (N - r + l):
        r += 1
    ans.append((l, r))
    used[cur] = True
    used[l] = True
    used[r] = True
    cur += 1

for l, r in ans:
    print(l, r)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<lint> vlint;

#define inf 1e+9
#define endl "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define rep_rev(i, n) for (int i = n-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define Size(c) (int)(c).size()

#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))

template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

template <class T, class S> inline bool chmax(T &a, S b) {
    if(a < b) {a = b;return 1;} return 0;
}
template <class T, class S> inline bool chmin(T &a, S b) {
    if(a > b) {a = b;return 1;} return 0;
}
template <class T>
void line(vector<T> &x){for (auto&& xi : x) cin >> xi;}

inline void IN(void){ return;}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){ cin >> first; IN(rest...); return;}

#define INT(...) int __VA_ARGS__; IN (__VA_ARGS__)
#define LINT(...) lint __VA_ARGS__; IN (__VA_ARGS__)
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__)

template <class T> void UNIQUE(vector<T> &x) {
    sort(all(x)); x.erase(unique(all(x)), x.end());
}
template <class T> void print_vec(T first, T end){
    for (auto i = first; i < end - 1; i++) cout << *i << " ";
    cout << *(end-1) << endl;
}

template<class... T>
void debug_print(T... args){
    vector<lint> tmp = initializer_list<lint>{args...};
    print_vec(all(tmp));
}
template<class T>
void print(T a){ cout << a << endl;}

vector<string> Yes = {"No", "Yes"};
vector<string> YES = {"NO", "YES"};

int ord(char x){ return (int)(x - 'a');}
char chr(lint x){ return (char)(x + (lint)('a'));}
lint mod = 1e9+7;
// lint mod = 

lint sum(vlint a){lint ret = 0; for(auto&& v:a) ret += v; return ret;}
lint vmini(vlint a, lint &index){
    lint ret = LLONG_MAX;
    rep(i, Size(a)){ if (chmin(ret, a[i])) index = i;}
    return ret;
}
lint vmaxi(vlint a, lint &index){
    lint ret = -LLONG_MAX;
    rep(i, Size(a)){ if (chmax(ret, a[i])) index = i;}
    return ret;
}

lint vmin(vlint a){
    lint ret = LLONG_MAX; for (auto && v : a) chmin(ret, v); return ret;
}
lint vmax(vlint a){
    lint ret = -LLONG_MAX; for (auto && v : a) chmax(ret, v); return ret;
}


int main(){
    INT(n, m);
    vector<vlint> ans;
    vlint check(n+1, 0); int cnt = 1; int diff = n-1;
    while (cnt < cnt + diff){
        ans.pb({cnt, cnt + diff});
        cnt++;
        diff -= 2;
        if (n % 2 == 0 && diff+2 > n/2 && diff <= n/2) diff--;
    }
    rep(i, m){
        print_vec(all(ans[i]));
    }
}

Submission status: Runtime Error

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n, m = map(int, input().split())
if n % 2 == 0:
    n -= 1
ans = []
left_range = n//2
right_range = n//2 - 1
left1 = 1
right1 = 1 + left_range
left2 = right1 + 1
right2 = left2 + right_range

while True:
    left1 += 1
    right1 -= 1
    if left1 >= right1:
        break
    ans.append([left1, right1])

while True:
    left2 += 1
    right2 -= 1
    if left2 >= right2:
        break
    ans.append([left2, right2])
    
for i in range(m):
    print(*ans[i])

Submission status: Runtime Error

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n, m = map(int, input().split())
if n % 2 == 0:
    n -= 1
ans = []
if m % 2 == 0:
    right_range = n//2
    left_range = n//2 - 1
else:
    left_range = n//2
    right_range = n//2 - 1
left1 = 1
right1 = 1 + left_range
left2 = right1 + 1
right2 = left2 + right_range

for i in range(left_range):
    left1 += i
    right1 -= i
    if left1 >= right1:
        break
    ans.append([left1, right1])

for i in range(right_range):
    left2 += i
    right2 -= i
    if left2 >= right2:
        break
    ans.append([left2, right2])
    
for i in range(m):
    print(*ans[i])

Submission status: Runtime Error

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n, m = map(int, input().split())
ans = []
if m % 2 == 0:
    right_range = n//2
    left_range = n//2 - 1
else:
    left_range = n//2
    right_range = n//2 - 1
left1 = 1
right1 = 1 + left_range
left2 = right1 + 1
right2 = left2 + right_range

for i in range(left_range):
    left1 += i
    right1 -= i
    if left1 >= right1:
        break
    ans.append([left1, right1])

for i in range(right_range):
    left2 += i
    right2 -= i
    if left2 >= right2:
        break
    ans.append([left2, right2])
    
for i in range(m):
    print(*ans[i])

Submission status: Runtime Error

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n, m = map(int, input().split())
ans = []
need = n//2 if n % 2 else (n - 1)//2
left_range = need
right_range = need - 1
left1 = 1
right1 = 1 + left_range
left2 = right1 + 1
right2 = left2 + right_range

for i in range(left_range):
    left1 += i
    right1 -= i
    if left1 >= right1:
        break
    ans.append([left1, right1])

for i in range(right_range):
    left2 += i
    right2 -= i
    if left2 >= right2:
        break
    ans.append([left2, right2])
    
for i in range(m):
    print(*ans[i])

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n,m = map(int, input().split())
    if n%2 == 0
        for i in range(m):
            print(n//2-i,n//2+i)
    else:
        for i in range(m):
            print(n//2-i,n//2+i+2)



if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n,m=[int(_) for _ in input()]
m1=n//2
for i in range(min(m1//2,m)):
  print(i+1,m1-i)
if m>m1:
  for i in range(m-m1):
    print(m1+i+1,m1*2-i-1)

Submission status: Runtime Error

Solution code:

from sys import stdin
input = stdin.readline

a,b,n = map(int,input().split())
maxpoint = 0

if b > n  :
    tmp = int((a * n) / b)  - a * int(n/b) 
    maxpoint = max(tmp,maxpoint)
elif b == n:
    maxpoint = 0
else:
    tmp = int((a * n) / b)  - a * int(n/b) 
    k = int(n/b)*b -1
    t1 =  int((a * k) / b)  - a * int(k/b) 
    maxpoint = max(t1,tmp)
    # for i in reversed(range(n+1)):
    #     t1 =  int((a * i) / b)  - a * int(i/b) 
    #     if b > 1:
    #         if i == k :
    #             print(maxpoint) 
    #             exit()
    #     elif b == 1:
    #         print(0)
    #         exit()
    #     if t1 > maxpoint:
    #         maxpoint = t1
       
    
    # print(tmp)
   
    # print(k)
    
    # maxpoint = max(tmp,k)
    

print(maxpoint)

Submission status: Runtime Error

Solution code:
import sys


def next_round(now, diff, N):
    if now + diff <= N:
        return now + diff
    else:
        return now + diff - N


def main():
    # N=10, M=4
    # 1 2
    # 3 5
    # 6 9
    # 10 4
    input = sys.stdin.buffer.readline
    N, M = map(int, input().split())
    unused = set(range(1, N + 1))
    diff = 1
    i = 1
    count = 0
    while count < M:
        left = i
        right = next_round(i, diff, N)
        unused.remove(left)
        unused.remove(right)
        print(left, right)
        count += 1
        diff += 1
        i = next_round(right, 1, N)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys


def main():
    # N=10, M=4
    # 1 2
    # 3 5
    # 4 7
    # 6 10
    input = sys.stdin.buffer.readline
    N, M = map(int, input().split())
    unused = set(range(1, N + 1))
    diff = 1
    i = 1
    count = 0
    while count < M:
        left = i
        right = i + diff
        unused.remove(left)
        unused.remove(right)
        print(left, right)
        count += 1
        diff += 1
        while True:
            i += 1
            if i in unused:
                break


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys


def main():
    input = sys.stdin.buffer.readline
    N, M = map(int, input().split())
    skip = None
    if N % 2 == 0 and N % 4 != 0:
        center = (N // 2) // 2 + 1
        if M >= center:
            skip = center
    right = N + 1
    left = 0
    count = 0
    while count < M:
        left += 1
        right -= 1
        if skip == left:
            continue
        print(left, right)
        count += 1


if __name__ == '__main__':
    main()
import sys


def main():
    input = sys.stdin.buffer.readline
    N, M = map(int, input().split())
    skip = None
    if N % 2 == 0 and N % 4 != 0:
        center = (N // 2) // 2 + 1
        if M >= center:
            skip = center
    right = N + 1
    left = 0
    count = 0
    while count < M:
        left += 1
        right -= 1
        if skip == left:
            continue
        print(left, right)
        count += 1


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

L = [0]*N
j = 1
for i in range(1, M+1):
    while L[j-1] == 1:
        j += 1
    print(j, i+j)
    L[j-1] = 1
    L[i+j-1] = 1

Submission status: Runtime Error

Solution code:
# 解説AC
from math import gcd
from collections import defaultdict
import sys

input = sys.stdin.buffer.readline

mod = 10 ** 9 + 7
n = int(input())
cnt = 0
cnt += n
zerocnt = 0
kumi = defaultdict(int)
for i in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        zerocnt += 1
        continue
    elif b == 0:
        kumi[(1, 0)] += 1
        kumi[(0, -1)] += 0
        continue
    elif a == 0:
        kumi[(0, -1)] += 1
        kumi[(1, 0)] += 0
        continue
    g = gcd(a, b)
    a //= g
    b //= g
    if a < 0:
        a *= -1
        b *= -1
    kumi[(a, b)] += 1
    kumi[(b, -a)] += 0
ans = 1
cnt -= zerocnt
for a, b in kumi.keys():
    if b <= 0:
        continue
    s = kumi[(a, b)]
    t = kumi[(b, -a)]
    ans *= pow(2, (s + t), mod) - (pow(2, s, mod) - 1) * (pow(2, t, mod) - 1)
    ans %= mod
    cnt -= s + t
if cnt > 0:
    ans *= pow(2, cnt, mod)
    ans %= mod
print((ans - 1 + zerocnt) % mod)

Submission status: Runtime Error

Solution code:
N = int(input())
A = (int,input().split())
C = N*(N - 1) / 2
x = 0
for i in range(round(C) + 1):
  for j, k in range(N):
    if  A.index(j) - A.index(k) == j + k:
      x += 1
      
print(x)

Submission status: Runtime Error

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


if n % 2 == 0:
    current = 0
    reached = [False for i in range(n)]
    for i in range(1, m+1):
        while reached[current]:
            current += 1
        reached[current] = True
        reached[current+i] = True
        a = current + 1
        b = a + i
        print(*[a, b])


else:
    for i in range(m):
        n_list = [i for i in range(n)]
        a = n_list[i]+1
        b = n_list[n-1-i]+1
        print(*[a, b])

Submission status: Runtime Error

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


if n % 2 == 0:
    current = 0
    reached = [False for i in range(n)]
    for i in range(1, m+1):
        while reached[current]:
            current += 1
        reached[current] = True
        reached[current+i] = True
        a = current
        b = current + i
        print(*[a, b])


else:
    for i in range(m):
        n_list = [i for i in range(n)]
        a = n_list[i]+1
        b = n_list[n-1-i]+1
        print(*[a, b])

Submission status: Runtime Error

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

stack = list(range(1,N+1))
stack.reverse()

ans = []
for i in range(M):
    # print(stack)
    now = stack.pop()
    cand = now+i+1
    # cand = now+i+1 if now + i + 1 >N else now+i+1-N
    if N - cand + 1== cand - now:
        now = cand
        cand = now+i+1

    # pair = stack.pop(cand)
    stack.remove(cand)
    pair = cand
    
    # print(cand)
    # print("a")
    ans.append([now,pair])

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

Submission status: Runtime Error

Solution code:
def main():
    n, m = map(int, input().split())
    left = 1
    right = n
    is_shift = False
    ans = []
    while left < right:
        if right - left <= n // 2 and not is_shift:
            left += 1
        ans.append([left, right])
        left += 1
        right -= 1

    for l in range(m):
        print(*ans[l])


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def main():
    n, m = map(int, input().split())
    left = 1
    right = n
    is_shift = False
    ans = []
    while left < right:
        if right - left <= n // 2 and not is_shift:
            left += 1
        ans.append([left, right])
        left += 1
        right -= 1

    print(f"{ans = }")
    for l in range(m):
        print(*ans[l])


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

Copy
Copy
#!/usr/bin/env python3
import sys
 
 
def solve(N: int, M: int):
 
    if N %2 == 1:
        for x in range(1, M+1):
            print("{} {}".format(x, N+1-x))
    else:
        m = 0
        for x in range(1, (N-1)//4):
            print("{} {}".format(x, N+1-x))
            m += 1
            if m == M : break
        for x in range((N-1)//4, (N-1)//2+1):
            print("{} {}".format(x+1, N+1-x))
            m += 1
            if m == M : break

Submission status: Runtime Error

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

while True:
    if n // 2 - i * 2 - 1 <= 0:
        break
    print(i + 1, n // 2 - i)
    i += 1

while True:
    if i + j == m:
        break
    print(n // 2 + j + 1, n - j)
    j += 1

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,M = list(map(int,input().strip().split()))
K = N//2
ans = []
left = 1
right = K
while left<right:
    ans += [(left,right)]
    left+=1
    right-=1

left = K+1
right = N
if (right-left)%2 == (K-1)%2:
    right -= 1
while left<right:
    ans += [(lfet,right)]
    left += 1
    right -= 1

for i in range(M):
    print(ans[i][0],ans[i][1])

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a, b = n, 1
V = [False for d in range(1, m + 2)]
for i in range(m):
    d = min(a - b, n - (a - b))
    if 2 * d == n or V[d]:
        a -= 1
    print(a, b)
    d = min(a - b, n - (a - b))
    V[d] = True
    a -= 1
    b += 1

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
if M%2 == 0:
    a2 = int(N/2)+1
    a1 = 1
    b1 = a2+1
    b2 = N
else:
    a2 = int(N/2)
    a1 = 1
    b1 = a2+1
    b2 = N

anls = []
m1 = int(M/2)
m2 = M-m1
for i in range(m1)
    anls.append([a1,a2])
    a1 += 1
    a2 -= 1
for i in range(m2)
    anls.append([b1,b2])
    b1 += 1
    b2 -= 1

for i in range(M):
    print(anls[i][0],anls[i][1])

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
"""アリーナの番号の割り当てが変更すると考える　参加者の番号が固有でアリーナの番号がひとつづつ減ってく
"""
def bul(x,y,m,n,result):#アリーナの動きを平面上の天の位置の動きと同一視した時の制限m(参加者)でn個進んだ時の座標
    k = y - x
    xx = 1-k
    if x==m and y==1:
        if n==0:
            result.append([m,1])
        else:
            bul(m,m-1,m,n-1,result)
    elif x - xx >= n:
        result.append([x-n,y-n])
    else:
        bul(m,m+k-1,m,n-(y-1)-1,result)
def rap(x,y,m,n):
    result = []
    bul(x,y,m,n,result)
    return result

a = N
b = N-1
while True:
    dot = [a,b]
    anls = []
    anls.append(dot)
    bnls = [a,b]
    k = 1
    while k < M:
        an = rap(dot[0],dot[1],N,N)
        anls.append(an[0])
        bnls.append(an[0][0])
        bnls.append(an[0][1])
        dot = an[0]
        k += 1
    if len(set(bnls))==M*2:
        break
    else:
        a -= 1
        b -= 1
        if b == 0:
            b = N-a-1
            a = N

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

Submission status: Runtime Error

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

x=list(range(1,N+1,1))

for i in range(3):
    print(x.pop(0),x.pop(-1))

Submission status: Runtime Error

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

if n % 2: # odd
    raise Exception()
    for i in range(n // 2):
        print(i + 1, n - i)
else: # even
    a = [True] * n
    cnt = 1
    for i in range(n):
        if i + cnt >= n:
            break
        if a[i]:
            print(i + 1, i + 1 + cnt)
            a[i + cnt] = False
            cnt += 1

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(N: int, M: int):
    # N <= 10**5

    # 差が異なる組み合わせならば、N回を通して同じ組み合わせにはならない。
    # 前に奇数差、後ろに偶数差を作る
    ans = []

    # Nは偶数
    # 差は偶数
    a, b = (0, N//2)
    while a < b:
        ans.append((a+1, b+1))
        a += 1
        b -= 1
    # 差は奇数
    a, b = (N//2+1, N-1)
    if (b-a) % 2 == 1:
        b -= 1
    while a < b:
        ans.append((a+1, b+1))
        a += 1
        b -= 1
    for i in range(M):
        print(*ans[i], sep=" ")
    return


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:
n = int(input())
A = list(map(int, input().split()))
pn = 0
 
for s in range(1, n+1):
    for t in range(s+A[s-1]+1, n+1):
        if A[s-1] + A[t-1] == t-s:
            pn += 1
 
print(pn)

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
R = np.array(range(N)).reshape(1,N)

A = np.array(list(map(int, input().split()))).reshape(1,N)

mat1 = R-R.reshape(N,1)

mat2 = A+A.reshape(N,1)

s = np.count_nonzero(mat1==mat2)

print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#!python3

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

# odd
def solve1():
    assert False
    return [(i + 2, N - i) for i in range(M)]        


# even
def solve2():
    t = (N - 2) // 4
    l = [(i + 1, N - i) for i in range(t)]
    n = (N - 2) // 2 - t
    l = l + [(N // 2 + 1 + i, N // 2 - i) for i in range(n)]
    return l[:M]


def main():
    l = solve1() if N % 2 else solve2()
    for ans in l:
        print(*ans)
    

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
l=1
r=N
dis=[]
if N%2==1:
    for i in range(M):
        print(l,r)
        l=l+1
        r=r-1
else:
    for _ in range(M):
        print(l,r)
        a,b=r-l,N+l-r
        dis.append(a)
        dis.append(b)
        l=l+1
        r=r-1
        if r-l in dis or N+l-r in dis or r-l=N+l-r:
            r=r-1

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
res = []

def solve(l, r):
  global res
  if r <= l: return
  res.append((l, r))
  solve(l + 1, r - 1)


solve(1, M + 1)
solve(M + 2, M * 2 + 1)
for r in res: print(*r)

Submission status: Runtime Error

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

if n%2 == 1:
    for i in range(m):
        print(n//2-i,n//2+i+1)
else:
    ni = 1
    while ni < n//4 and ni <= m:
        print(l,r)
        l += 1
        r -= 1
        ni += 1
    r -= 1
    while ni <= m:
        print(l,r)
        l += 1
        r -= 1
        ni += 1

Submission status: Runtime Error

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

if n%2 == 1:
    for i in range(m):
        print(n//2-i,n//2+i+1)
else:
    ni =1
    while ni < n//4 and ni <= m:
        print(l,r)
        l += 1
        r -= 1
        ni += 1
    r -= 1
    while ni <= m:
        print(l,r)
        l += 1
        r -= 1
        ni += 1

Submission status: Runtime Error

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

Men = [False]*(N+1)
count =0
for i in range(1,N+1,1):
    if Men[i]==False:
        count+=1
        print(i,i+count)
        Men[i]=True
        Men[i+count]=True
        if count == M:
            break

Submission status: Runtime Error

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


m = (n-1) // 2
a = (n - 1) // 2
d = 1
memo = set([])
cnt = 0
for i in range(m):

    if (n - d in memo) or (d * 2 == n)):
        cnt += 1
        d += 1
    memo.add(d)
    if cnt > 1 or a < 1 or a+d > n:
        print(1/0)
    print(a, a+d)
    a -= 1
    d += 2

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import sys


sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


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

    if N % 2 == 0:
        used = [False] * (N + 1)
        i = 0
        span = 1
        cnt = 0
        while cnt < M:
            cnt += 1
            while used[i]:
                i += 1
            print(i + 1, i + 1 + span)
            used[i] = True
            used[i + span] = True
            span += 1
    else:
        for i in range(M):
            print(i + 1, N - i)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import sys


sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


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

    if N % 2 == 0:
        used = [False] * (N + 1)
        i = 1
        span = 1
        cnt = 0
        while cnt < M:
            cnt += 1
            while used[i]:
                i += 1
            print(i, i + span)
            used[i] = True
            used[i + span] = True
            i += 1
            span += 1
    else:
        for i in range(M):
            print(i + 1, N - i)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

N, M = map(int, input().split())
candi = [True for _ in range(101010)]
for d in make_divisors(N):
    if d > 1:
        candi[d] = False

ans = []
l, r = 1, N
for i in range(M):
    if not candi[r-l]:
        while not candi[r-l]:
            r -= 1
    ans.append([l, r])
    l += 1
    r -= 1

for i in range(M):
    print(" ".join(map(str, ans[i])))

Submission status: Runtime Error

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

if n 

m = (n-1) // 2
a = (n - 1) // 2
d = 1
memo = set([])
cnt = 0
for i in range(m):

    if n - d in memo or d * 2 == n:
        cnt += 1
        d += 1
    memo.add(d)
    if cnt > 1 or a < 1 or a+d > n:
        print(1/0)
    print(a, a+d)
    a -= 1
    d += 2

Submission status: Runtime Error

Solution code:
import math

def main():
    n, m = list(map(int, input().split()))
    nums = set(range(1,n+1))
    for i in range(m):
        a = min(nums)
        b = a + i + 1
        print(a, b)
        nums.remove(a)
        nums.remove(b)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
if not (1 <= M):
    1 // 0
if not (M * 2 + 1 <= N <= 100000):
    1 // 0

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
if not (1 <= M):
    1 // 0
if not (M * 2 + 1 <= N <= 100000:
    1 // 0

Submission status: Runtime Error

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

Submission status: Runtime Error

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

ans = []
if M % 2 != 0:
    for i in range((M+1)//2):
        ans.append((1 + i,M - i))
        
    for j in range((M - 1)//2):
        ans.append((M + 1 + j, 2*M + 1 - j))
else:
    for i in range(M//2):
        ans.append((1 + i, M + 1 - i))
        ans.append((M + 2 + j, 2*M + 1 - j))
              
for i in range(M):
    print(*ans[i])

Submission status: Runtime Error

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

Submission status: Runtime Error

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