Buggy python submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n, k = (int(i) for i in input().split())
total = cmb(n - 1, 2)

if n == 2:
    print(-1)
elif total < k:
    print(-1)
else:
    dif = total - k

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

    p = 2
    c = 3
    while True:
        if dif == 0:
            break

        if c > n:
            p += 1
            c = p + 1
            print(p, c)
            c += 1
        else:
            print(p, c)
            c += 1

        dif -= 1

Fixed submission:
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n, k = (int(i) for i in input().split())

if n == 2:
    if k == 0:
        print(1)
        print(1, 2)
    else:
        print(-1)
else:
    total = cmb(n - 1, 2)
    
    if total < k:
        print(-1)
    else:
        dif = total - k

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

        p = 2
        c = 3
        while True:
            if dif == 0:
                break

            if c > n:
                p += 1
                c = p + 1
                print(p, c)
                c += 1
            else:
                print(p, c)
                c += 1

            dif -= 1

Buggy python submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n, k = (int(i) for i in input().split())
total = cmb(n - 1, 2)

if total < k:
    print(-1)
else:
    dif = total - k

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

    p = 2
    c = 3
    while True:
        if dif == 0:
            break

        if c > n:
            p += 1
            c = p + 1
            print(p, c)
            c += 1
        else:
            print(p, c)
            c += 1

        dif -= 1

Fixed submission:
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n, k = (int(i) for i in input().split())

if n == 2:
    if k == 0:
        print(1)
        print(1, 2)
    else:
        print(-1)
else:
    total = cmb(n - 1, 2)
    
    if total < k:
        print(-1)
    else:
        dif = total - k

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

        p = 2
        c = 3
        while True:
            if dif == 0:
                break

            if c > n:
                p += 1
                c = p + 1
                print(p, c)
                c += 1
            else:
                print(p, c)
                c += 1

            dif -= 1

Buggy python submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
  
n, k = (int(i) for i in input().split())
total = cmb(n - 1, 2)
flag = True

if total < k:
    print(-1)
    flag = False

dif = total - k

print(n - 1 + dif)
for i in range(n - 1):
    print(1, i + 2)
    
p = 2
c = 3
while True:
    if dif == 0:
        break
        
    if c > n:
        p += 1
        c = p + 1
        print(p, c)
        c += 1
    else:
        print(p, c)
        c += 1
        
    dif -= 1

Fixed submission:
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n, k = (int(i) for i in input().split())

if n == 2:
    if k == 0:
        print(1)
        print(1, 2)
    else:
        print(-1)
else:
    total = cmb(n - 1, 2)
    
    if total < k:
        print(-1)
    else:
        dif = total - k

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

        p = 2
        c = 3
        while True:
            if dif == 0:
                break

            if c > n:
                p += 1
                c = p + 1
                print(p, c)
                c += 1
            else:
                print(p, c)
                c += 1

            dif -= 1