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 Kotlin (1.0.0) (judge verdict: Accepted)

/**
 * @author kojin15.
 */
fun main(args: Array<String>) {
    val (A, B) = readIntArrayH()
    if ((A + B) % 2 == 0) println((A + B) / 2) else println("IMPOSSIBLE")
}

//in--------------------------------------------------------------------------------------------------------------------
fun readInt(): Int = readLine()!!.toInt()
fun readIntArrayH(): IntArray = readLine()!!.split(" ").map(String::toInt)
    .let { IntArray(it.size) { n -> it[n] } }
fun readIntArrayV(n: Int): IntArray = IntArray(n) { readInt() }

fun readLong(): Long = readLine()!!.toLong()
fun readLongArrayH(): LongArray = readLine()!!.split(" ").map(String::toLong)
    .let { LongArray(it.size) { n -> it[n] } }
fun readLongArrayV(n: Int): LongArray = LongArray(n) { readLong() }

//out-------------------------------------------------------------------------------------------------------------------
fun printBool(bool: Boolean, yes: String, no: String) = println(if (bool) yes else no)
fun Boolean.print(yes: String, no: String) = printBool(this, yes, no)

fun printYn(bool: Boolean) = printBool(bool, "Yes", "No")
fun printYN(bool: Boolean) = printBool(bool, "YES", "NO")
fun printPossible(bool: Boolean) = printBool(bool, "Possible", "Impossible")
fun printYay(bool: Boolean) = printBool(bool, "Yay!", ":(")

//cast------------------------------------------------------------------------------------------------------------------
fun int(n: Number) = n.toInt()
fun long(n: Number) = n.toLong()
fun double(n: Number) = n.toDouble()
fun float(n: Number) = n.toFloat()

//math------------------------------------------------------------------------------------------------------------------
infix fun Int.modP(mod: Int): Int {
    val y = this % mod
    return if (y < 0) y + mod else y
}

infix fun Long.modP(mod: Int): Int {
    val y = int(this % mod)
    return if (y < 0) y + mod else y
}

infix fun Int.pow(n: Int): Int = when {
    n == 0 -> 1
    n % 2 == 0 -> pow(n / 2).let { it * it }
    else -> this * pow(n - 1)
}

fun Int.powM(n: Int, m: Int): Int = when {
    n == 0 -> 1
    n % 2 == 0 -> (pow(n / 2) % m).let { it * it } % m
    else -> ((this % m) * (pow(n - 1) % m)) % m
}

infix fun Long.pow(n: Int): Long = when {
    n == 0 -> 1
    n % 2 == 0 -> pow(n / 2).let { it * it }
    else -> this * pow(n - 1)
}

fun Long.powM(n: Int, m: Int): Long = when {
    n == 0 -> 1L
    n % 2 == 0 -> (pow(n / 2) % m).let { it * it } % m
    else -> ((this % m) * (pow(n - 1) % m)) % m
}

var MOD: Int = 1000000007 //素数推奨
class ModInt(x: Int) {
    val x: Int = x modP MOD

    val mod: Int get() = MOD
    val inverse: ModInt get() = this.pow(MOD - 2)

    val factorial: ModInt get() = if (this > 0) this * (this - 1).factorial else ModInt(1)
    val doubleFactorial: ModInt get() = if (this > 1) this * (this - 2).doubleFactorial else ModInt(1)

    operator fun unaryMinus(): ModInt = ModInt(-x)

    operator fun inc(): ModInt = ModInt(x + 1)
    operator fun dec(): ModInt = ModInt(x - 1)

    operator fun plus(other: ModInt): ModInt = ModInt(x + other.x)
    operator fun plus(other: Int): ModInt = this.plus(ModInt(other))

    operator fun minus(other: ModInt): ModInt = this + (-other)
    operator fun minus(other: Int): ModInt = this.minus(ModInt(other))

    operator fun times(other: ModInt): ModInt = ModInt(x * other.x)
    operator fun times(other: Int): ModInt = this.times(ModInt(other))

    operator fun div(other: ModInt): ModInt = this * other.inverse
    operator fun div(other: Int): ModInt = this.div(ModInt(other))

    operator fun mod(other: ModInt): ModInt = ModInt(x modP other.x)
    operator fun mod(other: Int): ModInt = this.mod(ModInt(other))

    infix fun pow(n: Int): ModInt = ModInt(this.x.powM(n, MOD))

    operator fun compareTo(other: ModInt) = this.x.compareTo(other.x)
    operator fun compareTo(other: Int) = this.compareTo(ModInt(other))

    override operator fun equals(other: Any?): Boolean {
        if (other is ModInt) return this.x == other.x
        return this.x == other
    }

    override fun hashCode(): Int {
        return x
    }

    override fun toString(): String {
        return this.x.toString()
    }
}
operator fun Int.plus(other: ModInt): ModInt = ModInt(this).plus(other)
operator fun Int.minus(other: ModInt): ModInt = ModInt(this).minus(other)
operator fun Int.times(other: ModInt): ModInt = ModInt(this).times(other)
operator fun Int.div(other: ModInt): ModInt = ModInt(this).div(other)
operator fun Int.mod(other: ModInt): ModInt = ModInt(this).mod(other)
operator fun Int.compareTo(other: ModInt) = ModInt(this).compareTo(other)