Buggy python submission (verdict: Runtime Error):
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res
if r == 0:
    print(1//0)
    print(n)
    if is_changed:
        print(Y*sgnY, X*sgnX)
    else:
        print(X*sgnX, Y*sgnY)

    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)













Fixed submission:
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res
if r == 0:
    print(n)
    res = make(X, Y, n)
    if is_changed:
        for a, b in res[::-1]:
            print(b*sgnY, a*sgnX)
    else:
        for a, b in res[::-1]:
            print(a*sgnX, b*sgnY)
    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)

Buggy python submission (verdict: Runtime Error):
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res
if r == 0:
    print(n)
    if is_changed:
        print(Y*sgnY, X*sgnX)
    else:
        print(X*sgnX, Y*sgnY)

    sys.exit()
if n == 0:
    print(1//0)
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)













Fixed submission:
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res
if r == 0:
    print(n)
    res = make(X, Y, n)
    if is_changed:
        for a, b in res[::-1]:
            print(b*sgnY, a*sgnX)
    else:
        for a, b in res[::-1]:
            print(a*sgnX, b*sgnY)
    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)

Buggy python submission (verdict: Runtime Error):
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res
if r == 0:
    print(n)
    if is_changed:
        print(Y*sgnY, X*sgnX)
    else:
        print(X*sgnX, Y*sgnY)

    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    print(1//0)
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)













Fixed submission:
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res
if r == 0:
    print(n)
    res = make(X, Y, n)
    if is_changed:
        for a, b in res[::-1]:
            print(b*sgnY, a*sgnX)
    else:
        for a, b in res[::-1]:
            print(a*sgnX, b*sgnY)
    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)

Buggy python submission (verdict: Runtime Error):
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res
if r == 0:
    print(n)
    if is_changed:
        print(Y*sgnY, X*sgnX)
    else:
        print(X*sgnX, Y*sgnY)

    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
else:
    print(1//0)
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)













Fixed submission:
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res
if r == 0:
    print(n)
    res = make(X, Y, n)
    if is_changed:
        for a, b in res[::-1]:
            print(b*sgnY, a*sgnX)
    else:
        for a, b in res[::-1]:
            print(a*sgnX, b*sgnY)
    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)

Buggy python submission (verdict: Runtime Error):
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res
if r == 0:
    print(n)
    if is_changed:
        print(Y*sgnY, X*sgnX)
    else:
        print(X*sgnX, Y*sgnY)

    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
else:
    if K%2 == 0:
        print(1//0)
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)













Fixed submission:
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res
if r == 0:
    print(n)
    res = make(X, Y, n)
    if is_changed:
        for a, b in res[::-1]:
            print(b*sgnY, a*sgnX)
    else:
        for a, b in res[::-1]:
            print(a*sgnX, b*sgnY)
    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)

Buggy python submission (verdict: Runtime Error):
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res
if r == 0:
    print(n)
    if is_changed:
        print(Y*sgnY, X*sgnX)
    else:
        print(X*sgnX, Y*sgnY)

    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
        else:
            print(1//0)
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)













Fixed submission:
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res
if r == 0:
    print(n)
    res = make(X, Y, n)
    if is_changed:
        for a, b in res[::-1]:
            print(b*sgnY, a*sgnX)
    else:
        for a, b in res[::-1]:
            print(a*sgnX, b*sgnY)
    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)

Buggy python submission (verdict: Runtime Error):
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res
if r == 0:
    print(n)
    if is_changed:
        print(Y*sgnY, X*sgnX)
    else:
        print(X*sgnX, Y*sgnY)

    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            print(1//0)
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)













Fixed submission:
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res
if r == 0:
    print(n)
    res = make(X, Y, n)
    if is_changed:
        for a, b in res[::-1]:
            print(b*sgnY, a*sgnX)
    else:
        for a, b in res[::-1]:
            print(a*sgnX, b*sgnY)
    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)

Buggy python submission (verdict: Runtime Error):
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res
if r == 0:
    print(n)
    if is_changed:
        print(Y*sgnY, X*sgnX)
    else:
        print(X*sgnX, Y*sgnY)

    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    print(1//0)
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)













Fixed submission:
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res
if r == 0:
    print(n)
    res = make(X, Y, n)
    if is_changed:
        for a, b in res[::-1]:
            print(b*sgnY, a*sgnX)
    else:
        for a, b in res[::-1]:
            print(a*sgnX, b*sgnY)
    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)

Buggy python submission (verdict: Runtime Error):
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res
if r == 0:
    print(n)
    if is_changed:
        print(Y*sgnY, X*sgnX)
    else:
        print(X*sgnX, Y*sgnY)

    sys.exit()
if n == 0:
    print(1//0)
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)













Fixed submission:
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res
if r == 0:
    print(n)
    res = make(X, Y, n)
    if is_changed:
        for a, b in res[::-1]:
            print(b*sgnY, a*sgnX)
    else:
        for a, b in res[::-1]:
            print(a*sgnX, b*sgnY)
    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)

Buggy python submission (verdict: Runtime Error):
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res


if r == 0:
    print(n)
    if is_changed:
        print(Y*sgnY, X*sgnX)
    else:
        print(X*sgnX, Y*sgnY)

    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)













Fixed submission:
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res
if r == 0:
    print(n)
    res = make(X, Y, n)
    if is_changed:
        for a, b in res[::-1]:
            print(b*sgnY, a*sgnX)
    else:
        for a, b in res[::-1]:
            print(a*sgnX, b*sgnY)
    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)

Buggy python submission (verdict: Runtime Error):
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res


if r == 0:
    print(n)
    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)













Fixed submission:
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res
if r == 0:
    print(n)
    res = make(X, Y, n)
    if is_changed:
        for a, b in res[::-1]:
            print(b*sgnY, a*sgnX)
    else:
        for a, b in res[::-1]:
            print(a*sgnX, b*sgnY)
    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)

Buggy python submission (verdict: Runtime Error):
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res


if r == 0:
    print(n)
    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m == K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)













Fixed submission:
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res
if r == 0:
    print(n)
    res = make(X, Y, n)
    if is_changed:
        for a, b in res[::-1]:
            print(b*sgnY, a*sgnX)
    else:
        for a, b in res[::-1]:
            print(a*sgnX, b*sgnY)
    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)

Buggy python submission (verdict: Runtime Error):
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res


if r == 0:
    print(n)
    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m == K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
        if is_changed:
            print(0, -K*sgnX)
            print(-m*sgnY, -m*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print(-K*sgnX, 0)
            print(-m*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)













Fixed submission:
import sys
K = int(input())
X, Y = map(int, input().split())
is_changed = False
if abs(X)<abs(Y):
    X, Y = Y, X
    is_changed = True
sgnX = 1 if X>=0 else -1
sgnY = 1 if Y>=0 else -1
X, Y = abs(X), abs(Y)
s = X+Y
r = s%K
n = s//K
def make(x, y, n):
    res = []
    for _ in range(x//K):
        res.append((x, y))
        x-=K
    res.append((x, y))
    y -= K-x%K
    x = 0
    for _ in range(y//K):
        res.append((x, y))
        y-=K
    return res
if r == 0:
    print(n)
    res = make(X, Y, n)
    if is_changed:
        for a, b in res[::-1]:
            print(b*sgnY, a*sgnX)
    else:
        for a, b in res[::-1]:
            print(a*sgnX, b*sgnY)
    sys.exit()
if n == 0:
    if s%2 == 0:
        print(2)
        m = K-s//2
        if is_changed:
            print(-m*sgnY, (K-m)*sgnX)
            print(Y*sgnY, X*sgnX)
        else:
            print((K-m)*sgnX, -m*sgnY)
            print(X*sgnX, Y*sgnY)
    else:
        if K%2 == 0:
            print(-1)
        else:
            print(3)
            m = (K*3-s)//2-K
            if is_changed:
                print(0, -K*sgnX)
                print(-m*sgnY, -m*sgnX)
                print(Y*sgnY, X*sgnX)
            else:
                print(-K*sgnX, 0)
                print(-m*sgnX, -m*sgnY)
                print(X*sgnX, Y*sgnY)

    sys.exit()

if s%2 == 0:
    if K%2 == 0:
        ans = n+1
        res = [(X, Y)]
        X-=(K+r)//2
        Y+=(K-r)//2
        res+=make(X, Y, n)
    else:
        if n%2 == 0:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
        else:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
else:
    if K%2 == 0:
        ans = -1
        res = []
    else:
        if n%2 == 0:
            ans = n+1
            res = [(X, Y)]
            X-=(K+r)//2
            Y+=(K-r)//2
            res+=make(X, Y, n)
        else:
            ans = n+2
            res = [(X, Y)]
            X-=r//2
            Y+=K-r//2
            res+=make(X, Y, n+1)
if is_changed:
    print(ans)
    for a, b in res[::-1]:
        print(b*sgnY, a*sgnX)
else:
    print(ans)
    for a, b in res[::-1]:
        print(a*sgnX, b*sgnY)