Problem:
Score: 100 points

Problem Statement

We have two distinct integers A and B.

Print the integer K such that |A - K| = |B - K|.

If such an integer does not exist, print IMPOSSIBLE instead.

Constraints

All values in input are integers.

0 \leq A,\ B \leq 10^9

A and B are distinct.

Input

Input is given from Standard Input in the following format:

A B

Output

Print the integer K satisfying the condition.

If such an integer does not exist, print IMPOSSIBLE instead.

Sample Input 1

2 16

Sample Output 1

9

|2 - 9| = 7 and |16 - 9| = 7, so 9 satisfies the condition.

Sample Input 2

0 3

Sample Output 2

IMPOSSIBLE

No integer satisfies the condition.

Sample Input 3

998244353 99824435

Sample Output 3

549034394

Solution in PyPy3 (2.4.0) (judge verdict: Runtime Error)

# chessboard, manhattan distance even will noly be possible if parity is right

from math import sqrt
eps = 1e-5

# Utils
def solve2(A11,A12,A21,A22,b1,b2):
    """Solves a 2x2 matrix equation."""
    det = (A11*A22-A12*A21)
    if abs(det) < eps:
        return (None, None)

    return (1/det*(b1*A22-b2*A12), 1/det*(b2*A11-b1*A21))

def dot(a,b):
    """Returns the dot product"""
    return sum(a[i]*b[i] for i in range(len(a)))
    
def normalize(a):
    """Normalize vector to unit length"""
    norm = sqrt(dot(a,a))
    return tuple(x/norm for x in a)

def cross(a,b):
    """3D cross product"""
    return (a[1]*b[2] - a[2]*b[1],
            a[2]*b[0] - a[0]*b[2],
            a[0]*b[1] - a[1]*b[0])

# intpt,onsegment,t,s = ll_intersect(a,da,b,db)
def ll_intersect(a,da,b,db):
    """Given two segments, return line intersection, segments crossing and
       parameters at crossing"""
    dx, dy = a[0]-b[0], a[1]-b[1]
    s,t = solve2(db[0], -da[0], db[1], -da[1], dx, dy)

    if s == None:
        return (None, False, None, None)

    ipt = (a[0] + t*da[0], a[1] + t*da[1])
    
    # Epsilon treatment?
    if s < -eps or s > 1+eps or t < -eps or t > 1+eps:
        return (ipt, False, t, s)
    
    return (ipt, True, t, s)
    

def manhattan(x,y,s,t):
    return abs(x-s) + abs(y-t)

def main():
    k = int(input())
    xx,yy = map(int,input().split())
    if k % 2 == 0:
        if (xx+yy)%2:
            print('-1')
            return
    
    P = []

    while (xx,yy) != (0,0):
        P.append((xx,yy))
        if manhattan(0,0,xx,yy) <= 2*k:
            Sorig = [[(-k,0),(k,k)],
                    [(0,k),(k,-k)],
                    [(k,0),(-k,-k)],
                    [(0,-k),(-k,k)]]
            S = [[(pos[0]+xx,pos[1]+yy),diff] for pos,diff in Sorig]
            
            inter = []
            for pp,dd in S:
                for pp2,dd2 in Sorig:
                    pt,onseg,_,_ = ll_intersect(pp,dd,pp2,dd2)
                    if onseg:
                        ix,iy = pt
                        if (ix - round(ix)) < eps and (iy - round(iy)) < eps:
                            inter.append((int(round(ix)),int(round(iy))))

            for ix,iy in inter:
                ix,iy = inter[-1]
                if manhattan(0,0,ix,iy) == k and manhattan(ix,iy,xx,yy) == k:
                    P.append((ix,iy))
                    P.append((0,0))
                    break
            if P[-1] == (0,0):
                break

        if xx < 0:
            signx = -1
            xx *= -1
        else:
            signx = 1

        if yy < 0:
            signy = -1
            yy *= -1
        else:
            signy = 1

        togo = k
        mn = min(togo,xx)
        xx -= mn
        togo -= mn
        yy -= togo

        xx *= signx
        yy *= signy

    for i in range(len(P)-1):
        assert abs(P[i][0] - P[i+1][0]) + abs(P[i][1] - P[i+1][1]) == k

    print(len(P)-1)
    for x,y in P[:-1][::-1]:
        print(x,y)

main()