AtCoder Beginner Contest 124 - Buttons

There are two buttons, one of size A and one of size B.
When you press a button of size X, you get X coins and the size of that button decreases by 1.
You will press a button twice. Here, you can press the same button twice, or press both buttons once.
At most how many coins can you get?

-----Constraints-----
 - All values in input are integers.
 - 3 \leq A, B \leq 20

-----Input-----
Input is given from Standard Input in the following format:
A B

-----Output-----
Print the maximum number of coins you can get.

-----Sample Input-----
5 3

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

You can get 5 + 4 = 9 coins by pressing the button of size 5 twice, and this is the maximum result.

Source: atcoder | Difficulty: EASY


Solutions:
(a, b) = map(int, input().split())
ans = 0
for _ in range(2):
	choice = max(a, b)
	ans += choice
	if choice == a:
		a -= 1
	else:
		b -= 1
print(ans)


(a, b) = map(int, input().split(' '))
print(max(a + a - 1, b + b - 1, a + b))


(a, b) = map(int, input().split())
l = [2 * a - 1, a + b, 2 * b - 1]
print(max(l))


(A, B) = list(map(int, input().split()))
ans = 0
for _ in range(2):
	ans += max(A, B)
	if A >= B:
		A -= 1
	else:
		B -= 1
print(ans)


a = list(map(int, input().split()))
c = 0
for i in range(2):
	c += a[a.index(max(a))]
	a[a.index(max(a))] = a[a.index(max(a))] - 1
print(c)


(A, B) = list(map(int, input().split()))
print(max([2 * A - 1, A + B, 2 * B - 1]))


(A, B) = list(map(int, input().split()))
print(A + B if A == B else 2 * max(A, B) - 1)


(A, B) = map(int, input().split())
a = sorted([A - 1, A, B - 1, B])
print(a[2] + a[3])


(A, B) = map(int, input().split())
ans = max(2 * A - 1, 2 * B - 1, A + B)
print(ans)


(a, b) = map(int, input().split())
if a != b:
	button = max(a, b)
	all = 0
	all += button * 2 - 1
	print(all)
else:
	print(a * 2)


(A, B) = map(int, input().split())
ans = 0
for i in range(2):
	if A >= B:
		ans += A
		A -= 1
	else:
		ans += B
		B -= 1
print(ans)


l = list(map(int, input().split()))
l.sort(reverse=True)
ans = l[0]
l[0] -= 1
l.sort(reverse=True)
print(ans + l[0])


(a, b) = map(int, input().split())
print(a + b if a == b else max(a, b) * 2 - 1)


(a, b) = map(int, input().split())
lis = [2 * a - 1, a + b, 2 * b - 1]
print(max(lis))


(A, B) = (int(X) for X in input().split())
print(max(2 * A - 1, 2 * B - 1, A + B))


(a, b) = map(int, input().split())
c = max(a + b, 2 * a - 1, 2 * b - 1)
print(c)


(a, b) = map(int, input().split())
if a == b:
	print(a + b)
elif a - b >= 1:
	print(a + a - 1)
else:
	print(b + b - 1)


(A, B) = map(int, input().split())
C = [A + (A - 1), A + B, B + (B - 1)]
print(max(C))


(a, b) = list(map(int, input().split()))
ans = 0
for i in range(2):
	if a > b:
		ans += a
		a -= 1
	else:
		ans += b
		b -= 1
print(ans)


(A, B) = map(int, input().split())
l = [A + A - 1, A + B, B + B - 1]
print(max(l))


(A, B) = map(int, input().split())
ans = 0
if A < B:
	ans += B
	B -= 1
else:
	ans += A
	A -= 1
if A < B:
	ans += B
	B -= 1
else:
	ans += A
	A -= 1
print(ans)


(x, y) = map(int, input().split())
print(max(2 * x - 1, x + y, 2 * y - 1))


(a, b) = map(int, input().split())
A = a + b
B = a + a - 1
C = b + b - 1
L = [A, B, C]
print(max(L))


(a, b) = map(int, input().split())
if a >= b + 2:
	print(a + a - 1)
elif a == b + 1 or b == a + 1 or a == b:
	print(a + b)
elif a + 2 <= b:
	print(b + b - 1)


(a, b) = map(int, input().split())
l = [a, a - 1, b, b - 1]
l.sort()
print(l[2] + l[3])


(a, b) = [int(x) for x in input().split()]
print(max(a * 2 - 1, b * 2 - 1, a + b))


(A, B) = map(int, input().split())
r = max(A + (A - 1), A + B, B + (B - 1))
print(r)


(a, s) = map(int, input().split())
print(max(a + a - 1, s + s - 1, a + s))


import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007

def main():
	(A, B) = list(map(int, readline().split()))
	if A > B:
		print(A + (A - 1))
	elif A < B:
		print(B + (B - 1))
	else:
		print(A + B)
	return

def __starting_point():
	main()
__starting_point()


(A, B) = map(int, input().split())
if A > B:
	print(2 * A - 1)
elif A == B:
	print(A + B)
else:
	print(2 * B - 1)


(A, B) = map(int, input().split())
coin_list = []
COIN1 = A + A - 1
COIN2 = B + B - 1
COIN3 = A + B
coin_list.append(COIN1)
coin_list.append(COIN2)
coin_list.append(COIN3)
print(max(coin_list))


(a, b) = map(int, input().split())
c = max(a, b)
print(c + max(c - 1, min(a, b)))


(a, b) = map(int, input().split())
m = max(a + b, a * 2 - 1, b * 2 - 1)
print(m)


(A, B) = (int(x) for x in input().split())
if A > B:
	print(2 * A - 1)
elif A < B:
	print(2 * B - 1)
else:
	print(2 * A)


(a, b) = map(int, input().split())
print(max(a, b) * 2 - int(a != b))


(a, b) = list(map(int, input().split()))
ans = max(a, b)
q = max(a, b)
d = min(a, b)
ans += max(q - 1, d)
print(ans)


(a, b) = list(map(int, input().split()))
if a == b:
	print(2 * a)
elif a > b:
	print(2 * a - 1)
else:
	print(2 * b - 1)


(A, B) = map(int, input().split())
if B > A:
	(A, B) = (B, A)
print(A + max(A - 1, B))


(A, B) = map(int, input().split())
print(sum(sorted([A, A - 1, B, B - 1])[2:]))


(a, b) = sorted(map(int, input().split()))
print(b + b - 1 if b - 1 > a else b + a)


import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007

def main():
	(A, B) = list(map(int, readline().split()))
	vec = [A, B, A - 1, B - 1]
	vec.sort(reverse=True)
	print(sum(vec[:2]))
	return

def __starting_point():
	main()
__starting_point()


l = input().rstrip().lstrip().split(' ')
print(max(int(l[0]), int(l[1])) + max(min(int(l[0]), int(l[1])), max(int(l[0]), int(l[1])) - 1))


(a, b) = list(map(int, input().split()))
print(max(a + b, 2 * a - 1, 2 * b - 1))


a = list(map(int, input().split()))
a.sort()
r = a[-1]
a[-1] -= 1
a.sort()
r += a[-1]
print(r)


a = list(map(int, input().split()))
count = 0
for v in range(2):
	if a[0] >= a[1]:
		count += a[0]
		a[0] -= 1
	else:
		count += a[1]
		a[1] -= 1
print(count)


(A, B) = map(int, input().split())
a = [A * 2 - 1, B * 2 - 1, A + B]
print(max(a))


(a, b) = map(int, input().split())
coins = [a + b, 2 * a - 1, 2 * b - 1]
print(max(coins))


q = list(map(int, input().split()))
print(max(q) * 2 - (q[1] != q[0]))


(a, b) = map(int, input().split())
ans = max(2 * a - 1, a + b, 2 * b - 1)
print(ans)


(A, B) = map(int, input().split())
s = 0
for i in range(2):
	if A > B:
		s += A
		A -= 1
	elif B > A:
		s += B
		B -= 1
	elif A == B:
		s += A
		A -= 1
print(s)


(A, B) = map(int, input().split())
if A != B:
	x = max(A, B)
	ans = 2 * x - 1
else:
	ans = 2 * A
print(ans)


c = [int(i) for i in input().split()]
print(max(sum(c), 2 * max(c) - 1))


(A, B) = map(int, input().split())
if A == B:
	print(A + B)
elif A > B:
	print(A + A - 1)
elif B > A:
	print(B + B - 1)


(a, b) = map(int, input().split())
print(sum(sorted([a, b, a - 1, b - 1])[2:]))


a = list(map(int, input().split()))
print(max([max(a) * 2 - 1, sum(a)]))


(a, b) = map(int, input().split())
p = [2 * a - 1, 2 * b - 1, a + b]
print(max(p))


(a, b) = map(int, input().split())
x = max(a, b)
print(x + max(x - 1, min(a, b)))


a = list(map(int, input().split()))
ans = 0
if a[0] > a[1]:
	ans += a[0]
	a[0] -= 1
else:
	ans += a[1]
	a[1] -= 1
if a[0] > a[1]:
	ans += a[0]
else:
	ans += a[1]
print(ans)


(a, b) = map(int, input().split())
c = 0
for i in range(2):
	if a > b:
		c += a
		a -= 1
	elif a < b:
		c += b
		b -= 1
	else:
		c += b
		b -= 1
print(c)


(A, B) = map(int, input().split())
a1 = A + A - 1
a2 = A + B
b = B + B - 1
print(max(a1, a2, b))


(a, b) = [int(i) for i in input().split()]
print(max([2 * a - 1, a + b, 2 * b - 1]))


def mapt(fn, *args):
	return tuple(map(fn, *args))

def Input():
	return mapt(int, input().split(' '))

def main():
	(a, b) = Input()
	c1 = a + b
	c2 = a + a - 1
	c3 = b + b - 1
	print(max(c1, c2, c3))
main()


(x, y) = map(int, input().split())
m = max(x, y)
mm = min(x, y)
print(m + max(m - 1, mm))


(H, W) = list(map(int, input().split()))
ans = 0
for i in range(2):
	if H >= W:
		ans += H
		H -= 1
	else:
		ans += W
		W -= 1
print(ans)


(A, B) = list(map(int, input().split()))
count = 0
for i in range(0, 2):
	if A == B:
		count = count + A
	elif A > B:
		count = count + A
		A = A - 1
	elif A < B:
		count = count + B
		B = B - 1
print(count)


(a, b) = input().split()
a = int(a)
b = int(b)
if a - b >= 2:
	print(2 * a - 1)
if b - a >= 2:
	print(2 * b - 1)
if -2 < a - b < 2:
	print(a + b)


(a, b) = map(int, input().split())
result = 0
for i in range(2):
	if a > b:
		result += a
		a -= 1
	else:
		result += b
		b -= 1
print(result)


(a, b) = [int(v) for v in input().split()]
print(max(a + b, a * 2 - 1, b * 2 - 1))


(a, b) = map(int, input().split())
print([a + b, 2 * max(a, b) - 1][max(a, b) - 1 >= min(a, b)])


(a, b) = input().split()
a = int(a)
b = int(b)
print(max([2 * a - 1, 2 * b - 1, a + b]))


(a, b) = map(int, input().split())
ans = 0
if a >= b:
	ans += a
	a -= 1
	if a >= b:
		ans += a
	else:
		ans += b
else:
	ans += b
	b -= 1
	if b >= a:
		ans += b
	else:
		ans += a
print(ans)


(a, b) = list(map(int, input().split()))
ans = 0
ans = max(a, b)
c = max(a, b) - 1
ans += max(min(a, b), c)
print(ans)


(A, B) = [int(x) for x in input().split()]
print(max(A + B, 2 * A - 1, 2 * B - 1))


(a, b) = map(int, input().split())
s = [2 * a - 1, a + b, 2 * b - 1]
print(max(s))


(A, B) = map(int, input().split())
print(max(A, B) * 2 - (A != B))


(A, B) = map(int, input().split())
print(max(2 * A - 1, A + B, 2 * B - 1))
exit()


a = sorted(map(int, input().split()))
print(max(sum(a), a[-1] * 2 - 1))


X = list(map(int, input().split()))
print(max([sum(X), max(X) * 2 - 1]))


l = list(map(int, input().split()))
print(max(l) + max([max(l) - 1, min(l)]))


(n, m) = map(int, input().split())
ans = max(n + n - 1, m + m - 1, n + m)
print(ans)


l = list(map(int, input().split()))
print(max(sum(l), max(l) * 2 - 1))


a = list(map(int, input().split()))
print(max(a) + max([min(a), max(a) - 1]))


(A, B) = [int(e) for e in input().split(' ')]
print(max([A + A - 1, A + B, B + B - 1]))


(a, b) = map(int, input().split())
ma = max(2 * a - 1, a + b, 2 * b - 1)
print(ma)


x = list(map(int, input().split()))
print(max(2 * x[0] - 1, sum(x), 2 * x[1] - 1))


(A, B) = map(int, input().split())
print(max(A, B) + max(max(A, B) - 1, min(A, B)))


(a, b) = list(map(int, input().split()))
if a == b:
	print(a + b)
else:
	print(max(a, b) + max(a, b) - 1)


(a, b) = map(int, input().split())
count = 0
if a > b:
	count += a
	a -= 1
else:
	count += b
	b -= 1
if a > b:
	count += a
	a -= 1
else:
	count += b
	b -= 1
print(count)


(A, B) = map(int, input().split())
if abs(A - B) == 0:
	ans = A + B
elif abs(A - B) == 1:
	ans = max(A, B) + min(A, B)
else:
	ans = max(A, B) + max(A, B) - 1
print(ans)


(A, B) = map(int, input().split())
l = [2 * A - 1, A + B, 2 * B - 1]
l.sort()
print(l[-1])


(A, B) = map(int, input().split())
count = 0
for _ in range(2):
	if A >= B:
		count += A
		A -= 1
	else:
		count += B
		B -= 1
print(count)


(A, B) = map(int, input().split())
i = (A + A - 1, A + B, B + B - 1)
print(max(i))


(A, B) = map(int, input().split())
a = A + A - 1
b = A + B
c = B + B - 1
print(max(a, b, c))


(a, b) = map(int, input().split())
c = 0
if a > b:
	c = c + a
	a = a - 1
elif a < b:
	c = c + b
	b = b - 1
else:
	c = c + a
if a > b:
	c = c + a
	a = a - 1
elif a < b:
	c = c + b
	b = b - 1
else:
	c = c + a
print(c)


AB = list(map(int, input().split()))
ans = 0
for i in range(2):
	ans += max(AB)
	AB[AB.index(max(AB))] -= 1
print(ans)


rStr = input()
A = int(rStr.split(' ')[0])
B = int(rStr.split(' ')[1])
result = 0
index = 0
while index < 2:
	if A <= B:
		result += B
		B = B - 1
	else:
		result += A
		A = A - 1
	index = index + 1
print(result)


(i, j) = map(int, input().split())
print(max(i + j, i * 2 - 1, j * 2 - 1))


(a, b) = map(int, input().split())
c = [a, b, a - 1, b - 1]
c.sort()
print(sum(c[-2:]))


def count_coin_maximum():
	(a_button, b_button) = list(map(int, input().split()))
	if a_button == b_button:
		return a_button + a_button
	elif a_button > b_button:
		return a_button + max(a_button - 1, b_button)
	else:
		return b_button + max(b_button - 1, a_button)
print(count_coin_maximum())


(a, b) = map(int, input().split())
big = max(a, b)
print(max(2 * big - 1, a + b))


a = sorted(list(map(int, input().split())))
if a[0] == a[1]:
	print(a[0] + a[1])
else:
	print(a[1] * 2 - 1)


(A, B) = [int(s) for s in input().split(' ')]
print(max(A + B, A + A - 1, B + B - 1))