AtCoder Beginner Contest 110 - Maximize the Formula

You have decided to give an allowance to your child depending on the outcome of the game that he will play now.
The game is played as follows:
 - There are three "integer panels", each with a digit between 1 and 9 (inclusive) printed on it, and one "operator panel" with a + printed on it.
 - The player should construct a formula of the form X + Y, by arranging the four panels from left to right. (The operator panel should not be placed at either end of the formula.)
 - Then, the amount of the allowance will be equal to the resulting value of the formula.
Given the values A, B and C printed on the integer panels used in the game, find the maximum possible amount of the allowance.

-----Constraints-----
 - All values in input are integers.
 - 1 \leq A, B, C \leq 9

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

-----Output-----
Print the maximum possible amount of the allowance.

-----Sample Input-----
1 5 2

-----Sample Output-----
53

The amount of the allowance will be 53 when the panels are arranged as 52+1, and this is the maximum possible amount.

Difficulty: EASY

Starter code:

Solutions:
import sys
stdin = sys.stdin

def ns():
	return stdin.readline().rstrip()

def ni():
	return int(stdin.readline().rstrip())

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

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

def main():
	A = sorted(nl())
	print(eval(str(A[2]) + str(A[1]) + '+' + str(A[0])))

def __starting_point():
	main()
__starting_point()


A = sorted(map(int, input().split()))
print(A[0] + A[1] + A[2] * 10)


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


a = sorted(input().split())
print(eval(a[2] + a[1] + '+' + a[0]))


ABC = [int(x) for x in input().split()]
print(sum(ABC) + 9 * max(ABC))


(a, b, c) = map(int, input().split())
print(a + b + c + max([a, b, c]) * 9)


(x, y, z) = sorted(map(int, input().split()))
print(z * 10 + y + x)


a = input()
print(eval('+'.join(a + max(a) * 9)))


A = input().split()
A.sort()
print(int(A[2] + A[1]) + int(A[0]))


a = input().split()
a.sort(reverse=True)
if len(set(a)) == 1:
	print(12 * int(a[0]))
else:
	ans = int(a[0] + a[1]) + int(a[2])
	print(ans)


X = list(map(int, input().split()))
X.sort()
print(X[0] + X[1] + X[2] * 10)


(c, b, a) = sorted(map(int, input().split()))
print(10 * a + b + c)


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


s = list(map(int, input().split()))
s.sort()
print(s[0] + s[1] + 10 * s[2])


A = list(map(int, input().split()))
print(9 * max(A) + sum(A))


L = sorted(map(int, input().split()))
print(L[2] * 9 + sum(L))


Ns = list(map(int, input().split()))
print(max(Ns) * 9 + sum(Ns))


a = list(map(int, input().split()))
print(max(a) * 10 - max(a) + sum(a))


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


A = list(map(int, input().split()))
A = sorted(A, reverse=True)
print(int(''.join(map(str, A[:2]))) + A[-1])


import os
l = list(map(int, input().split()))
l.sort()
a = l[2] * 10 + l[1] + l[0]
print(a)


val = list(map(int, input().split()))
val.sort(reverse=True)
print(val[0] * 10 + val[1] + val[2])


a = list(map(int, input().split()))
print(sum(a) + max(a) * 9)


n = sorted(input())[::-1]
print(eval(n[0] + n[1]) + int(n[2]))


l = list(map(int, input().split()))
l.sort()
print(l[0] + l[1] + 10 * l[2])


(A, B, C) = map(int, input().split())
k = max(A, B, C)
print(A + B + C - k + 10 * k)


n = list(map(int, input().split()))
n.sort()
print(n[0] + n[1] + n[2] * 10)


a = list(map(int, input().split()))
a.sort()
print(a[-1] * 10 + a[-2] + a[-3])


list01 = list(map(int, input().split()))
list02 = sorted(list01, reverse=True)
a = list02[0] * 10 + list02[1] + list02[2]
print(a)


a = list(map(int, input().split()))
sort_a = sorted(a, reverse=True)
tmp = int(str(sort_a[0]) + str(sort_a[1])) + sort_a[2]
print(tmp)


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


(x, y, z) = map(int, input().split())
print(9 * max(x, y, z) + x + y + z)


a = list(map(int, input().split()))
a.sort()
print(a[1] + 10 * a[2] + a[0])


(a, b, c) = sorted(input().split())
s = c + b + '+' + a
print(eval(s))


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

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

def main():
	data = sorted(Input(), reverse=True)
	print(int(str(data[0]) + str(data[1])) + data[2])
main()


(*_, a, b, c) = sorted(input())
print(eval(c + b + '+' + a))


(a, b, c) = sorted(input().split())
print(int(c + b) + int(a))


A = [int(i) for i in input().split()]
print(max(A) * 9 + sum(A))


(*x,) = map(int, input().split())
x.sort()
print(x[0] + x[1] + x[2] * 10)


(a, b, c) = map(int, input().split())
if a <= b and b <= c:
	print(int(str(c) + str(b)) + a)
elif c <= b and b <= a:
	print(int(str(a) + str(b)) + c)
elif a <= c and c <= b:
	print(int(str(b) + str(c)) + a)
elif b <= c and c <= a:
	print(int(str(a) + str(c)) + b)
elif b <= a and a <= c:
	print(int(str(c) + str(a)) + b)
else:
	print(int(str(b) + str(a)) + c)


(A, B, C) = sorted(map(int, input().split()))
print(10 * C + A + B)


a = list(map(int, input().split()))
a.sort()
print(a[2] * 9 + sum(a))


l = list(map(int, input().split()))
print(sum(l) + 9 * max(l))


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


s = sorted(input())[::-1]
s.insert(2, '+')
print(eval(''.join(s)))


L = list(map(str, input().split()))
L.sort()
a = int(L[2] + L[1])
b = int(L[0])
print(a + b)


L = sorted(map(int, input().split()))
print(L.pop() * 10 + sum(L))


(A, B, C) = map(int, input().split())
print(max(A, B, C) * 9 + A + B + C)


S = list(map(int, input().split()))
S.sort()
all = 0
all += S[0] + 10 * S[2] + S[1]
print(all)


l = sorted(list(map(int, input().split())))
print(10 * l[2] + l[1] + l[0])


li = list(map(int, input().split()))
print(sum(li) + 9 * max(li))


nums = list(map(int, input().split()))
nums.sort()
print(nums[2] * 10 + nums[1] + nums[0])


l = [int(x) for x in input().split()]
list.sort(l)
print(l[-1] * 10 + l[0] + l[1])


X = list(map(int, input().split()))
print(max(X) * 9 + sum(X))


(a, b, c) = input().split()
a = int(a)
b = int(b)
c = int(c)
ls = [a, b, c]
ls.sort()
print(ls[2] * 10 + ls[1] + ls[0])


abc = list(map(int, input().split()))
abc = sorted(abc, reverse=True)
ab = str(abc[0]) + str(abc[1])
c = int(abc[2])
print(int(ab) + int(c))


n = [int(_) for _ in input().split()]
print(max(n) * 9 + sum(n))


num = sorted(list(map(int, input().split())), reverse=True)
print(num[0] * 10 + sum(num[1:]))


lst = list(map(int, input().split()))
lst.sort()
lst.reverse()
maximum = int(str(lst[0]) + str(lst[1])) + lst[2]
print(maximum)


a = [int(i) for i in input().split()]
a.sort(reverse=True)
ans = a[0] * 10 + a[1] + a[2]
print(ans)


a = sorted(list(input().split()))
print(int(a[2]) * 10 + int(a[0]) + int(a[1]))


n = list(map(int, input().split()))
list_num = list(n)
list_num.sort()
list_str = []
for i in list_num:
	i = str(i)
	list_str.append(i)
max_str = list_str[-1] + list_str[1]
max_int = int(max_str)
print(max_int + int(list_str[0]))


abc = list(map(int, input().split()))
print(max(abc) * 9 + sum(abc))


(*x,) = map(int, input().split())
print(sum(x) + max(x) * 9)


(a, b, c) = (int(i) for i in input().split())
print(a + b + c + max(a, b, c) * 9)


a = sorted(list(map(int, input().split())), reverse=True)
print(sum(a) + a[0] * 9)


x = []
x = list(input().split())
x.sort(reverse=True)
print(int(x[0] + x[1]) + int(x[2]))


ABC = input().split()
m = max(ABC)
ABC.remove(m)
print(eval(m + ABC[0] + '+' + ABC[1]))


l = input().split()
ld = sorted(l, reverse=True)
a = ld[0] + ld[1]
b = ld[2]
m = int(a)
n = int(b)
print(m + n)


i = sorted(input().split())
print(int(i[0]) + int(i[2] + i[1]))


N = sorted(input().split())
print(int(N[2] + N[1]) + int(N[0]))


(A, B, C) = map(int, input().split())
ans = 0
if A >= B and A >= C:
	ans = max(A * 10 + B + C, ans)
if B >= A and B >= C:
	ans = max(B * 10 + A + C, ans)
else:
	ans = max(C * 10 + A + B, ans)
print(str(ans))


print(eval('+'.join(sorted(input())) + '*10'))


lis = []
li = input().split()
li.sort()
lis.append(li[2] + li[1])
lis.append(li[0])
print(int(lis[0]) + int(lis[1]))


x = list(map(int, input().split()))
a = max(x)
b = min(x)
x.remove(a)
x.remove(b)
c = x[0]
a = str(a)
b = str(b)
ab = int(a + b)
print(ab + c)


n = list(map(int, input().split()))
print(sum(n) + max(n) * 9)


N = list(map(int, input().split()))
print(sum(N) + max(N) * 9)


(A, B, C) = sorted([int(s) for s in input().split()])
print(10 * C + B + A)


(z, y, x) = sorted([int(i) for i in input().split()])
print(x * 10 + y + z)


a = sorted(map(int, input().split()))
print(a[0] + a[1] + a[2] * 10)


(a, b, c) = input().split()
if a == max(a, b, c):
	ans = int(a + b) + int(c)
elif b == max(a, b, c):
	ans = int(b + a) + int(c)
else:
	ans = int(c + a) + int(b)
print(ans)


n = sorted(map(int, input().split()))
print(n[2] * 9 + sum(n))


(X, Y, Z) = sorted(map(int, input().split()))
print(X + Y + 10 * Z)


l = list(map(int, input().split()))
m = max(l)
print(m * 10 + sum(l) - m)


print(eval(''.join(sorted(input() + '++') * 4)[6::5]))


abc = list(map(str, input().split()))
abc.sort()
print(int(abc[2] + abc[1]) + int(abc[0]))


(A, B, C) = list(map(int, input().split()))
if A >= B and A >= C:
	print(int(A * 10 + B + C))
elif B >= A and B >= C:
	print(int(B * 10 + A + C))
else:
	print(int(C * 10 + A + B))


z = sorted(map(int, input().split()))
z[2] *= 10
print(sum(z))


ABC = list(map(int, input().split()))
print(9 * max(ABC) + sum(ABC))


a = list(map(int, input().split()))
a = sorted(a, reverse=True)
res = a[0] * 10 + a[1] + a[2]
print(res)


a = list(input().split())
b = sorted(a)
print(int(b[2] + b[1]) + int(b[0]))


N = list(map(int, input().split()))
N.sort()
print(sum(N) + N[2] * 9)


(A, B, C) = map(int, input().split())
lst = [A, B, C]
lst2 = sorted(lst, reverse=True)
lst3 = list(map(str, lst2))
print(int(lst3[0] + lst3[1]) + int(lst3[2]))


X = sorted(list(map(int, input().split())))
print(X[2] * 10 + X[1] + X[0])


(a, b, c) = sorted(map(int, input().split()), reverse=True)
print(10 * a + b + c)


li_1 = (a, b, c) = list(map(int, input().split()))
li = sorted(li_1, reverse=True)
print(int(str(li[0]) + str(li[1])) + li[2])


a = sorted(list(map(int, input().split())))
print(a[2] * 9 + sum(a))


N = sorted(list(map(int, input().split())))
print(N[2] * 10 + N[1] + N[0])


(*h, a, b, c) = sorted(input())
print(int(c + b) + int(a))


a = list(input().split())
a.sort()
x = a[0]
y = a[2] + a[1]
print(int(x) + int(y))


s = list(map(int, input().split()))
print(sum(s) + max(s) * 9)


(a, b, c) = sorted(input()[::2])
print(int(c + b) + int(a))


Num = list(map(int, input().split()))
Num = sorted(Num, reverse=True)
X = []
for i in range(2):
	X.append(str(Num[i]))
X = int(''.join(X))
Y = int(Num[2])
print(X + Y)


a = sorted(list(map(int, input().split())))
print(a[-1] * 10 + sum(a[:-1]))


abc = sorted(list(map(int, input().split())), reverse=True)
a = [1] * 10
for i in range(10 ** 7 + 5 * 10 ** 6):
	a.append(a)
print(sum(abc) + abc[0] * 9)


A = sorted(input().split())
print(int(A[2] + A[1]) + int(A[0]))


L = list(map(int, input().split()))
print(max(L) * 9 + sum(L))


(A, B, C) = sorted(input().split())
a = C + B + '+' + A
print(eval(a))


print(eval('{}{}+{}'.format(*sorted(input().split())[::-1])))


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


a = sorted(list(map(int, input().split())))
a[2] *= 10
print(sum(a))


import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations, combinations, accumulate
from operator import itemgetter
from bisect import bisect_left, bisect
from heapq import heappop, heappush, heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
	num = list(map(int, input().split()))
	num.sort(reverse=True)
	print(num[0] * 10 + num[1] + num[2])

def __starting_point():
	main()
__starting_point()


def main():
	a = list(map(int, input().split()))
	sorted_a = sorted(a)
	print(int(str(sorted_a[2]) + str(sorted_a[1])) + sorted_a[0])

def __starting_point():
	main()
__starting_point()


L = list(map(int, input().split()))
L.sort()
print(L[2] * 10 + L[1] + L[0])


ns = list(map(int, input().split()))
print(max(ns) * 9 + sum(ns))


L = list(map(int, input().split()))
print(10 * max(L) + sum(L) - max(L))


A = list(map(int, input().split()))
A.sort()
A = A[::-1]
print(10 * A[0] + A[1] + A[2])


l = sorted(input())
print(int(l[4]) * 10 + int(l[3]) + int(l[2]))


(a, b, c) = map(int, input().split())
X = 10 * a + b + c
Y = a + 10 * b + c
Z = a + b + 10 * c
print(max(X, max(Y, Z)))


url = 'https://atcoder.jp//contests/abc110/tasks/abc110_a'

def main():
	t = list(map(int, input().split()))
	t.sort(reverse=True)
	print(t[0] * 10 + t[1] + t[2])

def __starting_point():
	main()
__starting_point()


(a, b, c) = sorted(input().split())
print(eval('{}{}+{}'.format(c, b, a)))


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


(A, B, C) = map(int, input().split())
M = max(A, B, C)
print(10 * M + A + B + C - M)


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 = list(map(int, readline().split()))
	A.sort()
	print(A[0] + A[1] + A[2] * 10)
	return

def __starting_point():
	main()
__starting_point()


S = list(map(int, input().split()))
ans = max(S) * 9 + sum(S)
print(ans)


num = list(map(int, input().split()))
num.sort()
ans = num[2] * 10 + num[1] + num[0]
print(ans)


A = list(map(int, input().split()))
print(max(A) * 10 + sum(A) - max(A))


l = list(map(int, input().split()))
i = l.index(max(l))
print(l.pop(i) * 10 + sum(l))


a = sorted(list(input().split()))
ans = int(a[0]) + int(a[2] + a[1])
print(ans)


(A, B, C) = map(int, input().split())
t = sorted([A, B, C])
print(t[0] + t[1] + t[2] * 10)


d = list(map(int, input().split()))
print(max(d) * 9 + sum(d))


n = list(map(int, input().split()))
m = sorted(n)
print(int(m[2] * 10 + m[1] + m[0]))


D = list(map(int, input().split()))
print(max(D) * 10 + sum(D) - max(D))


a = [int(i) for i in input().split()]
print(sum(a) + 9 * max(a))


l = sorted(map(int, input().split()))
print(l[2] * 10 + sum(l[:2]))


n = sorted(input().split())
print(int(n.pop() + n.pop()) + int(n.pop()))


def main():
	abc = sorted(input().split())
	print(int(abc[2]) * 10 + int(abc[1]) + int(abc[0]))

def __starting_point():
	main()
__starting_point()


(a, b, c) = map(int, input().split())
M = max(a, b, c)
r = a + b + c - M
print(10 * M + r)


(a, b, c) = sorted(map(int, input().split()))
print(a + int(str(c) + str(b)))


(*x,) = map(int, input()[::2])
print(max(x) * 9 + sum(x))


n = input().split()
n.sort()
print(int(n[0]) + int(n[2] + n[1]))