AtCoder Beginner Contest 135 - Harmony

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-----
2 16

-----Sample Output-----
9

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

Difficulty: EASY

Starter code:

Solutions:
(a, b) = map(int, input().split())
print(int((a + b) / 2)) if (a + b) % 2 == 0 else print('IMPOSSIBLE')


(A, B) = map(int, input().split())
if (A + B) / 2 % 1 == 0:
	print(int((A + B) / 2))
else:
	print('IMPOSSIBLE')


(x, y) = map(int, input().split())
s = x + y
if s % 2 == 0:
	print(s // 2)
else:
	print('IMPOSSIBLE')


(A, B) = map(int, input().split())
k = (A + B) / 2
print(int(k)) if k.is_integer() else print('IMPOSSIBLE')


(p, q) = map(int, input().split())
if (p - q) % 2 == 1:
	print('IMPOSSIBLE')
else:
	print((p + q) // 2)


(a, b) = map(int, input().split())
k = (a * a - b * b) / (2 * a - 2 * b)
if k == int(k):
	print(int(k))
else:
	print('IMPOSSIBLE')


(a, b) = list(map(int, input().split()))
s = a + b
if s % 2 == 1:
	print('IMPOSSIBLE')
else:
	print(s // 2)


(a, b) = map(int, input().split())
print('IMPOSSIBLE' if abs(a - b) % 2 else abs(a + b) // 2)


(A, B) = map(int, input().split())
print('IMPOSSIBLE' if (A - B) % 2 == 1 else min(A, B) + abs(A - B) // 2)


(A, B) = list(map(int, input().split()))
K = A + B
if K % 2 == 0:
	print(K // 2)
else:
	print('IMPOSSIBLE')


(a, b) = map(int, input().split())
print('IMPOSSIBLE' if (a + b) % 2 else str((a + b) // 2))


a = sum(map(int, input().split()))
print('IMPOSSIBLE' if a % 2 else a // 2)


(A, B) = map(int, input().split())
if A % 2 == B % 2:
	print((A + B) // 2)
else:
	print('IMPOSSIBLE')


x = sum(list(map(int, input().split())))
x = int(x / 2) if not x % 2 else 'IMPOSSIBLE'
print(x)


t = eval(input().replace(' ', '+'))
print((t // 2, 'IMPOSSIBLE')[t % 2])


(a, b) = (int(x) for x in input().split())
print('IMPOSSIBLE' if (a + b) % 2 == 1 else (a + b) // 2)


s = sum(map(int, input().split()))
print('IMPOSSIBLE' if s % 2 else s // 2)


(A, B) = map(int, input().split())
K = (A + B) / 2
k = int(K)
print([k, 'IMPOSSIBLE'][k != K])


(a, b) = map(int, input().split())
print((a + b) // 2 if not (a + b) % 2 else 'IMPOSSIBLE')


(A, B) = list(map(int, input().split()))
if A > B:
	(A, B) = (B, A)
if B - A & 1:
	print('IMPOSSIBLE')
	return
print(A + (B - A) // 2)


(N, M) = map(int, input().split())
if (N + M) % 2 == 0:
	print((N + M) // 2)
else:
	print('IMPOSSIBLE')


(n, m) = map(int, input().split())
if (n + m) % 2:
	print('IMPOSSIBLE')
else:
	print((n + m) // 2)


(q, r) = divmod(sum(map(int, input().split())), 2)
print('IMPOSSIBLE' if r else q)


a = list(map(int, input().split()))
if (a[0] + a[1]) % 2 == 0:
	print((a[0] + a[1]) // 2)
else:
	print('IMPOSSIBLE')


(a, s) = map(int, input().split())
if a % 2 == s % 2:
	print((a + s) // 2)
else:
	print('IMPOSSIBLE')


(a, b) = map(int, input().split())
print(['IMPOSSIBLE', a + (b - a) // 2][(b - a) % 2 == 0])


(a, b) = (int(i) for i in input().split())
if (a + b) % 2:
	print('IMPOSSIBLE')
else:
	print((a + b) // 2)


s = eval(input().replace(' ', '+'))
print(s // 2 if s % 2 == 0 else 'IMPOSSIBLE')


(a, b) = map(int, input().split())
ans = 'IMPOSSIBLE'
if (a + b) % 2 == 0:
	ans = (a + b) // 2
print(ans)


k = sum(map(int, input().split())) / 2
print('IMPOSSIBLE') if k % 1 else print(int(k))


k = eval(input().replace(' ', '+'))
print(k // 2 if (k / 2).is_integer() else 'IMPOSSIBLE')


(a, b) = map(int, input().split())
k = max(a, b) - (max(a, b) - min(a, b)) / 2
if k.is_integer():
	print(int(k))
else:
	print('IMPOSSIBLE')


from fractions import gcd
from itertools import combinations, permutations, accumulate, product
from collections import deque, defaultdict, Counter
import decimal
import re
import math
import sys
sys.setrecursionlimit(10000000)
mod = 10 ** 9 + 7
from sys import stdin
readline = stdin.readline

def readInts():
	return list(map(int, readline().split()))

def readTuples():
	return tuple(map(int, readline().split()))

def I():
	return int(readline())
(a, b) = readInts()
print((a + b) // 2 if (a + b) % 2 == 0 else 'IMPOSSIBLE')


(a, b) = map(int, input().split())
c = a + b
if c % 2 == 1:
	print('IMPOSSIBLE')
else:
	print(c // 2)


(A, B) = [int(n) for n in input().split()]
print('IMPOSSIBLE' if (A + B) % 2 else (A + B) // 2)


(a, b) = map(int, input().split())
ans = [(a + b) // 2, 'IMPOSSIBLE']
print(ans[(a + b) % 2])


(a, b) = map(int, input().split())
x = (a + b) / 2
if x.is_integer():
	print(int(x))
else:
	print('IMPOSSIBLE')


(a, b) = [int(_) for _ in input().split()]
print((a + b) // 2 if (a + b) % 2 == 0 else 'IMPOSSIBLE')


a = sum(map(int, input().split()))
print(a % 2 * 'IMPOSSIBLE' or a // 2)


(a, b) = list(map(int, input().split()))
if a == -b:
	print('IMPOSSIBLE')
elif (a + b) // 2 != (a + b) / 2:
	print('IMPOSSIBLE')
else:
	print((a + b) // 2)


K = eval(input().replace(' ', '+'))
print((K // 2, 'IMPOSSIBLE')[K % 2])


a = eval(input().replace(' ', '+'))
print(a % 2 * 'IMPOSSIBLE' or a // 2)


d = eval(input().replace(' ', '+'))
print([d // 2, 'IMPOSSIBLE'][d % 2])


(A, B) = map(int, input().split())
print(['IMPOSSIBLE', int((A + B) / 2)][(A + B) % 2 == 0])


x = eval(input().replace(' ', '+'))
print(x % 2 * 'IMPOSSIBLE' or x // 2)


(a, b) = map(int, input().split())
if a % 2 == 0 and b % 2 == 1:
	print('IMPOSSIBLE')
elif a % 2 == 1 and b % 2 == 0:
	print('IMPOSSIBLE')
else:
	print((a + b) // 2)


(a, b) = map(int, input().split())
p = abs(a - b)
print(abs(max(a, b) - p // 2) if p % 2 == 0 else 'IMPOSSIBLE')


k = eval(input().replace(' ', '+'))
print(k // 2 if k % 2 == 0 else 'IMPOSSIBLE')


(x, y) = map(int, input().split())
if (x + y) % 2:
	print('IMPOSSIBLE')
else:
	print((x + y) // 2)


t = eval(input().replace(' ', '+'))
print(t // 2 if t % 2 ^ 1 else 'IMPOSSIBLE')


p = eval(input().replace(' ', '+')) / 2
print('IMPOSSIBLE' if p % 1 > 0 else int(p))


def resolve():
	(a, b) = map(int, input().split())
	if a % 2 != b % 2:
		print('IMPOSSIBLE')
	else:
		print((a + b) // 2)
resolve()


import sys
import itertools
tokens = itertools.chain.from_iterable(list(map(str.split, sys.stdin)))
no = 'IMPOSSIBLE'
a = int(next(tokens))
b = int(next(tokens))
k = (a ** 2 - b ** 2) // (2 * (a - b))
if abs(a - k) != abs(b - k):
	print(no)
else:
	print(k)


(a, b) = list(map(int, input().split()))
c = (max(a, b) - min(a, b)) / 2
if c == int(c):
	print(int(min(a, b) + c))
else:
	print('IMPOSSIBLE')


x = eval(input().replace(' ', '+'))
if x % 2 == 0:
	print(x // 2)
else:
	print('IMPOSSIBLE')


(A, B) = list(map(int, input().split()))
if A > B:
	(A, B) = (B, A)
diff = B - A
if diff % 2:
	print('IMPOSSIBLE')
else:
	print(A + diff // 2)


(a, b) = map(int, input().split())
res = 'IMPOSSIBLE'
if (b - a) % 2 == 0:
	res = (a + b) // 2
print(res)


import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

def I():
	return int(input())

def F():
	return float(input())

def SS():
	return input()

def LI():
	return [int(x) for x in input().split()]

def LI_():
	return [int(x) - 1 for x in input().split()]

def LF():
	return [float(x) for x in input().split()]

def LSS():
	return input().split()

def resolve():
	(A, B) = LI()
	if (A - B) % 2 == 0:
		print((A + B) // 2)
	else:
		print('IMPOSSIBLE')

def __starting_point():
	resolve()
__starting_point()


(a, b) = [int(v) for v in input().split()]
if abs(a - b) % 2 == 0:
	print(int((max(a, b) + min(a, b)) / 2))
else:
	print('IMPOSSIBLE')


def LI():
	return list(map(int, input().split()))
(A, B) = LI()
if (A + B) % 2 == 0:
	ans = (A + B) // 2
else:
	ans = 'IMPOSSIBLE'
print(ans)


(a, b) = map(int, input().split())
print('IMPOSSIBLE' if (a ^ b) & 1 else a + b >> 1)