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 C# (Mono 4.6.2.0) (judge verdict: Runtime Error)

using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;


class Program
{
    static void Main(string[] args)
    {
        int num1 = Convert.ToInt32(Console.ReadLine());
        string numset = Console.ReadLine();
        string[] str =Regex.Split(numset,@"\s+");
        int[] numlist = new int[] { Convert.ToInt32(str[0]) , Convert.ToInt32(str[1]) };
        GolfFiled golf = new GolfFiled(numlist[0],numlist[1] , num1);
        if (num1%2==0 && (Math.Abs(numlist[0])+ Math.Abs(numlist[1]))%2==1)
        {
            Console.WriteLine("-1");
        }
        else
        {
            golf.MovePoint(golf.TooPoint(new int[] { 0, 0 }));
            golf.Answer();
        };



    }

        
}
class GolfFiled
{
    int x_yard;
    int y_yard;
    int K;
    List<List<int>> AnserPoint = new List<List<int>> { };

    int XYard
    {
        set
        {
            if (Math.Abs(value) > 500000)
                this.y_yard = 500000 * (Math.Sign(value));
            else
                this.x_yard = value;
        }
    }
    int YYard
    {
        set
        {
            if (Math.Abs(value) > 500000)
                this.y_yard = 500000 * (Math.Sign(value));
            else
                this.y_yard = value;
        }
    }

    public GolfFiled(int x, int y, int K)
    {
        Random rnd = new Random();
        this.XYard = x;
        this.YYard = y;
        this.K = K;
    }

    public GolfFiled()
    {
        Random rnd = new Random();
        this.XYard = rnd.Next(0, 500000);
        this.YYard = rnd.Next(0, 500000);
    }

    public int[] get_yard()
    {
        return new int[] { this.x_yard, this.y_yard };
    }

    public int MH_(int[] data1, int[] data2)
    {
        return Math.Abs(data1[0] - data2[0]) + Math.Abs(data1[1] - data2[1]);
    }

    public int MH_(int[] data2)
    {
        return Math.Abs(this.x_yard - data2[0]) + Math.Abs(this.y_yard - data2[1]);
    }
    public int MH_()
    {
        return Math.Abs(this.x_yard) + Math.Abs(this.y_yard);
    }

    public int[] TooPoint(int[] list)
    {
        if (Math.Abs(this.y_yard - list[1]) + Math.Abs(this.x_yard - list[0]) > this.K )
        {
            if (Math.Abs(this.y_yard - list[1]) - this.K < 0)
            {

                list[0] += Math.Sign(this.x_yard) * Math.Abs((Math.Abs(this.y_yard - list[1]) - this.K));
                list[1] = this.y_yard;
                List<int> tmp = new List<int> { list[0], list[1] };
                this.AnserPoint.Add(tmp);
                //Console.WriteLine("{0} {1}", list[0], list[1]);
                return TooPoint(list);
            }
            else
            {
                list[1] += Math.Sign(this.y_yard) * this.K;
                List<int> tmp = new List<int> { list[0], list[1] };
                this.AnserPoint.Add(tmp);
                //Console.WriteLine("{0} {1}", list[0], list[1]);
                return TooPoint(list);
            }
        }
        return list;
    }

    public void MovePoint(int[] list)
    {
        if (MH_(list) % 2 == 0)
        {
            tworoute(PointAll(new int[] { list[0], list[1] }), PointAll(new int[] { this.x_yard, this.y_yard }));
        }
        else
        {
            threeroute(new List<int> { list[0], list[1] });
        }
    }

    public List<List<int>> PointAll(int[] list)
    {
        List<List<int>> alllist = new List<List<int>> { };

        for (int i = 0; i <= this.K; ++i)
        {
            List<int> point = new List<int> { 0, 0 };
            point[0] = list[0] + i;
            point[1] = list[1] + this.K - i;
            alllist.Add(point);
            point = new List<int> { 0, 0 };
            point[0] = list[0] - (i);
            point[1] = list[1] - (this.K - i);
            alllist.Add(point);
            point = new List<int> { 0, 0 };
            point[0] = list[0] - i;
            point[1] = list[1] + this.K - i;
            alllist.Add(point);
            point = new List<int> { 0, 0 };
            point[0] = list[0] + i;
            point[1] = list[1] - (this.K - i);
            alllist.Add(point);
        }
        return alllist;
    }

    public void tworoute(List<List<int>> list1, List<List<int>> list2)
    {
        foreach (List<int> x in list1)
        {
            foreach (List<int> y in list2)
            {
                if (x[0] == y[0] && x[1] == y[1])
                {
                    List<int> tmp = new List<int> { x[0], x[1] };
                    this.AnserPoint.Add(tmp);
                    //Console.WriteLine("{0} {1}", x[0], x[1]);
                    tmp = new List<int> { this.x_yard, this.y_yard };
                    this.AnserPoint.Add(tmp);
                    //Console.WriteLine("{0} {1}", this.x_yard, this.y_yard);
                    return;
                }
            }
        }


    }
    public void threeroute(List<int> list2)
    {
        int[] list = new int[] { list2[0], list2[1] };
        int num = this.MH_(list);

        var tmp = haba(num);
        tmp[0] *= Math.Sign(this.x_yard);
        tmp[1] *= Math.Sign(this.y_yard);

        tmp[0] += list2[0];
        tmp[1] += list2[1];

        List<int> tp = new List<int> { tmp[0], tmp[1] };
        this.AnserPoint.Add(tp);

        //Console.WriteLine("{0} {1}", tmp[0], tmp[1]);

        tmp[0] += Math.Sign(this.x_yard) * Math.Abs(this.K - Math.Abs(this.y_yard - tmp[1]));
        //tmp[1] = list[1];
        tmp[1] = this.y_yard;

        tp = new List<int> { tmp[0], tmp[1] };
        this.AnserPoint.Add(tp);
        //Console.WriteLine("{0} {1}", tmp[0], tmp[1]);

        tmp[0] = this.x_yard;
        tp = new List<int> { tmp[0], tmp[1] };
        this.AnserPoint.Add(tp);
        //Console.WriteLine("{0} {1}", tmp[0], tmp[1]);
    }

    public List<int> haba(int num)
    {
        for (int i = this.K; i >= 0; --i)
        {
            if (num == i - (this.K - i))
            {
                return new List<int> { i, -(this.K - i) };
            }
        }
        return new List<int> {0, this.K };
    }

    public void Answer()
    {
        Console.WriteLine(this.AnserPoint.Count);

        foreach (List<int> x in this.AnserPoint)
        {
            Console.WriteLine("{0} {1}", x[0], x[1]);
        }
    }
}