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 Java8 (OpenJDK 1.8.0) (judge verdict: Runtime Error)

import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        long[] cities = new long[num+1];
        long[] heroes = new long[num];
        for(int i=0;i<num+1;i++)
            cities[i]=sc.nextInt();
        for(int i=0;i<num;i++)
            heroes[i]=sc.nextInt();
        long count=0;
        long temp=0;
        for(int i=0;i<num;i++)
        {
            if(cities[i]<heroes[i])
            {
                count+=cities[i];
                temp=cities[i];
                cities[i]=0;
                if(cities[i+1]<heroes[i]-temp)
                {
                    count+=cities[i+1];
                    cities[i+1]=0;
                }
                else
                {
                    count+=heroes[i]-temp;
                    cities[i+1]-=heroes[i]-temp;
                }
            }
            else
            {
                count+=heroes[i];
                cities[i]=cities[i]-heroes[i];
            }
        }
        System.out.println(count);
    }
}