Read problem statements in [Mandarin], [Bengali], [Russian], and [Vietnamese] as well.

Chef has three spells. Their powers are A, B, and C respectively. Initially, Chef has 0 hit points, and if he uses a spell with power P, then his number of hit points increases by P.

Before going to sleep, Chef wants to use exactly two spells out of these three. Find the maximum number of hit points Chef can have after using the spells.

------ Input Format ------ 

- The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
- The first and only line of each test case contains three space-separated integers A, B, and C.

------ Output Format ------ 

For each test case, print a single line containing one integer — the maximum number of hit points.

------ Constraints ------ 

$1 ≤ T ≤ 10^{4}$
$1 ≤ A, B, C ≤ 10^{8}$

------ subtasks ------ 

Subtask #1 (100 points): original constraints

----- Sample Input 1 ------ 
2
4 2 8
10 14 18
----- Sample Output 1 ------ 
12
32
----- explanation 1 ------ 
Example case 1: Chef has three possible options:
- Use the first and second spell and have $4 + 2 = 6$ hitpoints.
- Use the second and third spell and have $2 + 8 = 10$ hitpoints.
- Use the first and third spell and have $4 + 8 = 12$ hitpoints.

Chef should choose the third option and use the spells with power $4$ and $8$ to have $12$ hitpoints.

Example case 2: Chef should use the spells with power $14$ and $18$.

Source: codechef | Difficulty: EASY
Tags: Mathematics


Solutions:
t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	print(max(a + b, b + c, a + c))


T = int(input())
for _ in range(T):
	(A, B, C) = map(int, input().split())
	print(A + B + C - min(A, B, C))


for i in range(int(input())):
	(a, b, c) = map(int, input().split(' '))
	result = a + b + c
	minimum = min(a, min(b, c))
	print(result - minimum)


for t in range(int(input())):
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	print(a[0] + a[1])


for t in range(int(input())):
	a = list(map(int, input().split()))
	MAX = a[0]
	for val in range(len(a)):
		if MAX < a[val]:
			MAX = a[val]
	res = MAX
	a.remove(MAX)
	MAX = a[0]
	for val in range(len(a)):
		if MAX < a[val]:
			MAX = a[val]
	print(res + MAX)


for t in range(int(input())):
	a = list(map(int, input().split()))
	b = min(a)
	print(sum(a) - b)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	lst = [a, b, c]
	lst.sort()
	print(lst[1] + lst[2])


T = int(input())
for i in range(T):
	(A, B, C) = map(int, input().split())
	X = A + B
	Y = B + C
	Z = C + A
	if X >= Y and X >= Z:
		print(X)
	elif Y >= X and Y >= Z:
		print(Y)
	else:
		print(Z)


T = int(input())
for i in range(T):
	(A, B, C) = map(int, input().split())
	X = A + B
	Y = B + C
	Z = C + A
	print(max(X, Y, Z))


T = int(input())
for i in range(T):
	r = []
	(a, b, c) = map(int, input().split())
	r.append(a + b)
	r.append(b + c)
	r.append(a + c)
	p = max(r)
	print(p)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	k = a + b
	l = a + c
	p = b + c
	print(max(k, l, p))


n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	d = a + b
	e = b + c
	f = c + a
	print(max(d, e, f))


for i in range(int(input(' '))):
	arr = list(map(int, input().split(' ')))
	arr.sort()
	max_p = arr[2] + arr[1]
	print(max_p)


T = int(input())
for i in range(T):
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	print(arr[0] + arr[1])


import math
n = int(input())
for i in range(n):
	(a, b, c) = list(map(int, input().split()))
	m1 = a + b
	m2 = b + c
	m3 = c + a
	print(max(m1, m2, m3))


import math
for i in range(int(input())):
	x = input().split(' ')
	a = int(x[0]) + int(x[1])
	b = int(x[1]) + int(x[2])
	c = int(x[2]) + int(x[0])
	ans = max(a, b, c)
	print(ans)


for i in range(int(input())):
	a = list(map(int, input().split()))
	a.sort()
	s = a[len(a) - 1] + a[len(a) - 2]
	print(s)


for _ in range(int(input())):
	l = list(map(int, input().split()))
	print(sum(l) - min(l))


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	print(sum(l) - min(l))


t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	a.sort()
	print(a[-1] + a[-2])


for i in range(int(input())):
	l = list(map(int, input().split()))
	l.sort()
	print(l[1] + l[2])


for i in range(int(input())):
	(m, n, a) = map(int, input().split())
	s = m + n
	n = n + a
	a = m + a
	print(max(s, n, a))


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	l = [a + b, b + c, c + a]
	print(max(l))


for _ in range(int(input())):
	a = list(map(int, input().split()))
	b = min(a)
	a.remove(b)
	c = sum(a)
	print(c)


T = int(input())
for _ in range(T):
	(A, B, C) = map(int, input().split())
	S = max(A + B, B + C, A + C)
	print(S)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	l = []
	l.append(a)
	l.append(b)
	l.append(c)
	l1 = sorted(l)
	ans = sum(l1[-1:] + l1[-2:-1])
	print(ans)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	x = a + b
	y = b + c
	z = c + a
	print(max(x, y, z))


t = int(input())
for _ in range(t):
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	print(l[0] + l[1])


t = int(input())
i = 1
while i <= t:
	(a, b, c) = map(int, input().split())
	if a >= b >= c or b >= a >= c:
		print(a + b)
	elif c >= b >= a or b >= c >= a:
		print(c + b)
	else:
		print(a + c)
	i += 1


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	k = min(a, b, c)
	print(a + b + c - k)


n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	p = a + b
	q = b + c
	r = a + c
	d = max(p, q, r)
	print(d)


for case in range(int(input())):
	l = list(map(int, input().split()))
	l.remove(min(l))
	print(sum(l))


n = int(input())
for i in range(n):
	s = list(map(int, input().split()))
	a = max(s)
	s.remove(a)
	print(a + max(s))


for a in range(int(input())):
	(a, b, c) = map(int, input().split())
	y = min(a, b, c)
	print(a + b + c - y)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	d = a + b
	e = b + c
	f = c + a
	if d >= e and d >= f:
		print(d)
	elif e >= d and e >= f:
		print(e)
	else:
		print(f)


T = int(input())
while T:
	data = (A, B, C) = list(map(int, input().split()))
	data.sort()
	print(data[-1] + data[-2])
	T -= 1


T = int(input())
while T:
	data = (A, B, C) = list(map(int, input().split()))
	data.sort()
	for i in range(len(data) - 1, -1, -1):
		for j in range(i):
			if data[j] > data[j + 1]:
				temp = data[j]
				data[j] = data[j + 1]
				data[j + 1] = temp
	print(data[-1] + data[-2])
	T -= 1


from itertools import permutations
from itertools import combinations_with_replacement
n = int(input())
for i in range(n):
	a = map(int, input().split())
	a = list(a)
	count = 0
	b = list(permutations(a, 2))
	for j in range(len(b)):
		x = sum(b[j])
		if x > count:
			count = x
	print(count)


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	print(a + b + c - min(a, b, c))


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	l = a + b
	s = a + c
	m = b + c
	print(max(l, s, m))


for _ in range(int(input())):
	ssspells = list(map(int, input().split()))
	ssspells.sort()
	print(ssspells[-1] + ssspells[-2])


T = int(input())
for i in range(T):
	A = list(map(int, input().split()))
	A.sort()
	print(A[-1] + A[-2])


T = int(input())
for i in range(T):
	L = list(map(int, input().split()))
	L.sort()
	X = sum(L)
	print(L[1] + L[2])


T = int(input())
for i in range(T):
	L = list(map(int, input().split()))
	L.sort()
	X = sum(L)
	print(X - L[0])


for i in range(int(input())):
	x = list(map(int, input().split()))
	ans = []
	for j in x:
		for k in x:
			if j is not k:
				add = j + k
				ans.append(add)
	print(max(ans))


Test = int(input())
for Cases in range(Test):
	(SpellOne, SpellTwo, SpellThree) = map(int, input().split())
	ListOne = [SpellOne, SpellTwo, SpellThree]
	ListOneSorted = sorted(ListOne, reverse=True)
	print(sum(ListOneSorted) - ListOneSorted[-1])


for test in range(int(input())):
	(a, b, c) = map(int, input().split())
	l1 = [a, b, c]
	l2 = []
	for i in l1:
		x = a + b
		y = b + c
		z = a + c
		l3 = [x, y, z]
	print(max(l3))


for _ in range(int(input())):
	l = list(map(int, input().split()))
	s = sorted(l)
	print(s[1] + s[2])


t = int(input())
for i in range(t):
	(x, y, z) = map(int, input().split())
	print(max(x + y, y + z, x + z))


for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	s = a + b
	v = b + c
	n = a + c
	print(max(s, v, n))


T = int(input())
for i in range(T):
	(A, B, C) = map(int, input().split())
	sum1 = A + B
	sum2 = A + C
	sum3 = B + C
	print(max(sum1, sum2, sum3))


for i in range(int(input())):
	(A, B, C) = map(int, input().split())
	a = A + B
	b = B + C
	c = A + C
	print(max(a, b, c))


n = int(input())
for _ in range(n):
	x = list(map(int, input().split()))
	x.sort()
	print(x[-1] + x[-2])


try:
	t = int(input())
	for r in range(t):
		(a, b, c) = map(int, input().split())
		x = a + b
		y = b + c
		z = a + c
		print(max(x, y, z))
except:
	pass


for _ in range(int(input())):
	a = list(map(int, input().split()))
	c = []
	for i in range(len(a) - 1):
		if i != len(a):
			c.append(a[i] + a[i + 1])
		c.append(a[0] + a[-1])
	d = c[:-1]
	print(max(d))


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	s = [a, b, c]
	s.sort()
	print(s[-1] + s[-2])