You have three piles of candies: red, green and blue candies:  the first pile contains only red candies and there are $r$ candies in it,  the second pile contains only green candies and there are $g$ candies in it,  the third pile contains only blue candies and there are $b$ candies in it. 

Each day Tanya eats exactly two candies of different colors. She is free to choose the colors of eaten candies: the only restriction that she can't eat two candies of the same color in a day.

Find the maximal number of days Tanya can eat candies? Each day she needs to eat exactly two candies.


-----Input-----

The first line contains integer $t$ ($1 \le t \le 1000$) — the number of test cases in the input. Then $t$ test cases follow.

Each test case is given as a separate line of the input. It contains three integers $r$, $g$ and $b$ ($1 \le r, g, b \le 10^8$) — the number of red, green and blue candies, respectively.


-----Output-----

Print $t$ integers: the $i$-th printed integer is the answer on the $i$-th test case in the input.


-----Example-----
Input
6
1 1 1
1 2 1
4 1 1
7 4 10
8 1 4
8 2 8

Output
1
2
2
10
5
9



-----Note-----

In the first example, Tanya can eat candies for one day only. She can eat any pair of candies this day because all of them have different colors.

In the second example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and green and blue candies on the second day.

In the third example, Tanya can eat candies for two days. For example, she can eat red and green candies on the first day, and red and blue candies on the second day. Note, that two red candies will remain uneaten.

Difficulty: EASY
Tags: Mathematics

Starter code:

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


import sys
ip = lambda : sys.stdin.readline().rstrip()
t = int(ip())
for _ in range(t):
	(r, g, b) = map(int, ip().split())
	(a, b, c) = sorted([r, b, g])
	if c > a + b:
		print(a + b)
	else:
		print(c + (a + b - c) // 2)


t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	a.sort()
	if a[2] <= a[0] + a[1]:
		ans = (a[0] + a[1] + a[2]) // 2
	else:
		ans = a[0] + a[1]
	print(ans)


for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	(a, c, b) = (max(a, b, c), min(a, b, c), a + b + c - max(a, b, c) - min(a, b, c))
	if b + c >= a:
		print((a + b + c) // 2)
	else:
		print(b + c)


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


t = int(input())
for querrie in range(t):
	rgb = input().split()
	rgb[0] = int(rgb[0])
	rgb[1] = int(rgb[1])
	rgb[2] = int(rgb[2])
	rgb = sorted(rgb, reverse=True)
	if rgb[0] <= rgb[1] + rgb[2]:
		total = rgb[0] + int((rgb[1] + rgb[2] - rgb[0]) / 2)
	else:
		total = rgb[1] + rgb[2]
	print(total)


t = int(input())
for i in range(t):
	days = 0
	txt = input()
	array = txt.split()
	for j in range(len(array)):
		array[j] = int(array[j])
	array.sort()
	dif = array[2] - array[1]
	if dif >= array[0]:
		days += array[0]
		array[2] -= array[0]
		days += min(array[1], array[2])
	else:
		days += dif
		array[2] -= dif
		array[0] -= dif
		days += array[0] // 2 + array[1]
	print(days)


import sys, math

def input():
	return sys.stdin.readline()[:-1]

def main():
	q = int(input())
	for _ in range(q):
		a = sorted(list(map(int, input().split())))
		(r, g, b) = (a[0], a[1], a[2])
		ans = 0
		if b - g >= r:
			ans = r + g
		else:
			ans = (r + g + b) // 2
		print(ans)
main()


def resultado():
	balas = [int(i) for i in input().split()]
	balas.sort()
	menor = balas[0]
	total = balas[0]
	dif = balas[2] - balas[1]
	balas[2] - dif
	menor = balas[0] - dif
	if menor > 0:
		p1 = int(menor // 2)
		p2 = menor - p1
		balas[1] = balas[1] - p2
		balas[2] = balas[2] - p1
	total = balas[1] + total
	return total
N = int(input())
while N:
	print(resultado())
	N = N - 1


for _ in range(int(input())):
	(a, b, c) = sorted(map(int, input().split()))
	ans = min(a + b, c)
	if a + b >= c:
		ans = (a + b + c) // 2
	print(ans)


def chooseCandies(item):
	list.sort(item)
	if item[2] > item[0] + item[1]:
		result = item[0] + item[1]
	else:
		result = (item[0] + item[1] + item[2]) // 2
	print(result)
n = int(input())
inp = []
for i in range(n):
	line = list(map(int, input().split()))
	inp.append(line)
for item in inp:
	chooseCandies(item)


t = int(input())
r = []
g = []
b = []
for i in range(t):
	s = list(map(int, input().split()))
	r.append(s[0])
	g.append(s[1])
	b.append(s[2])
for i in range(t):
	ans = 0
	mx = max(r[i], g[i], b[i])
	mn = min(r[i], g[i], b[i])
	sr = r[i] + g[i] + b[i] - mx - mn
	rz = mx - sr
	ans = mn
	if rz >= mn:
		mx -= mn
		mn = 0
	else:
		mn -= rz
		mx -= rz + (mn - mn // 2)
		sr -= mn // 2
	ans += min(mx, sr)
	print(ans)


for _ in range(int(input())):
	a = input().split(' ')
	a[0] = int(a[0])
	a[1] = int(a[1])
	a[2] = int(a[2])
	a.sort()
	if a[2] >= a[1] + a[0]:
		print(a[1] + a[0])
	else:
		print(a[2] + (a[0] + a[1] - a[2]) // 2)


for _ in range(int(input())):
	(r, g, b) = map(int, input().split())
	ls = [r, g, b]
	ls.sort()
	ans = min((r + g + b) // 2, ls[0] + ls[1])
	print(ans)


n = int(input())
for _ in range(n):
	(a, b, c) = list(map(int, input().split()))
	print(min((a + b + c) // 2, a + b, a + c, b + c))


for i in range(int(input())):
	(x, y, z) = map(int, input().split())
	q = z + y
	w = x + z
	e = x + y
	if q >= x and w >= y and (e >= z):
		print((x + y + z) // 2)
	else:
		print(min(q, w, e))


from math import *
from collections import *
import sys
sys.setrecursionlimit(10 ** 9)
t = int(input())
for y in range(t):
	(r, g, b) = list(map(int, input().split()))
	m = max(r, g, b)
	if r + g + b - m >= m:
		ans = (r + g + b) // 2
	else:
		ans = r + g + b - m
	print(ans)


t = int(input())
for _ in range(t):
	vals = list(map(int, input().split()))
	vals.sort()
	if vals[2] < vals[1] + vals[0]:
		print(sum(vals) // 2)
	else:
		print(vals[0] + vals[1])


def main():
	n = int(input())
	for i in range(n):
		data = [int(v) for v in input().split()]
		data.sort(reverse=True)
		if data[1] + data[2] > data[0]:
			print(data[0] + (data[1] + data[2] - data[0]) // 2)
		else:
			print(data[1] + data[2])
main()


from math import ceil
t = int(input())
for i in range(t):
	a = input().split()
	r = int(a[0])
	g = int(a[1])
	b = int(a[2])
	sort = sorted([r, g, b])
	r = sort[2]
	g = sort[1]
	b = sort[0]
	count = 0
	while not (r == g and r == b and (g == b)) and (not r + b + g == r):
		tcount = sort[1] - sort[0]
		if tcount == 0:
			tcount = sort[2] - sort[1]
			if ceil(tcount / 2) > sort[0]:
				tcount = sort[0] * 2
			r = sort[2] - tcount
			g = sort[1] - ceil(tcount / 2)
			b = sort[0] - tcount // 2
		else:
			r = sort[2] - tcount
			g = sort[1] - tcount
			b = sort[0]
		count += tcount
		sort = sorted([r, g, b])
		r = sort[2]
		g = sort[1]
		b = sort[0]
	if b % 2 == 1:
		r -= 1
		g -= 1
		b -= 1
		count += 1
	count += b // 2 * 3
	print(count)


t = int(input())
for i in range(t):
	s = 0
	a = list(map(int, input().split()))
	a.sort()
	if a[2] >= a[0] + a[1]:
		s = a[0] + a[1]
	else:
		s = a[2] + abs(a[2] - (a[0] + a[1])) // 2
	print(s)


import math
for tc in range(int(input())):
	ar = sorted(list(map(int, input().split())))
	if ar[2] <= ar[0] + ar[1]:
		print((ar[0] + ar[1] + ar[2]) // 2)
	else:
		print(ar[0] + ar[1])


import sys
sys.setrecursionlimit(10 ** 5)

def I():
	return sys.stdin.readline()

def SI():
	return sys.stdin.readline().split()

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

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

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]
for _ in range(II()):
	arr = LI()
	arr.sort()
	print(min(sum(arr[:2]), sum(arr) // 2))


t = int(input())
for i in range(t):
	(r, g, b) = map(int, input().split())
	maxnum = max(r, g, b)
	minnum = min(r, g, b)
	mednum = r + g + b - maxnum - minnum
	if minnum + mednum > maxnum:
		ans = (r + g + b) // 2
	else:
		ans = minnum + mednum
	print(ans)


import math
t = int(input())
for _ in range(t):
	(r, g, b) = map(int, input().split())
	if r == 1 and g == 1 and (b == 1):
		print(1)
		continue
	l = [r, g, b]
	l.sort()
	ans = 0
	if l[2] >= l[1] + l[0]:
		print(l[1] + l[0])
		continue
	else:
		ans = r + g + b
		if ans % 2 == 0:
			print(ans // 2)
		else:
			print(ans // 2)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	t = list(map(int, input().split()))
	t.sort()
	(a, b, c) = t
	d = c - b
	if d < a:
		c -= d + (a - d) // 2
		b -= a - d - (a - d) // 2
	else:
		c -= a
	print(a + min(b, c))


t = int(input())
for i in range(t):
	(r, g, b) = list(map(int, input().split()))
	maxi = max(r, g, b)
	total = r + g + b
	if 2 * maxi > total:
		print(total - maxi)
	else:
		print(total // 2)


for _ in range(int(input())):
	A = list(map(int, input().split()))
	A.sort(reverse=True)
	a = A[0]
	b = A[1]
	c = A[2]
	print(min((a + b + c) // 2, b + c))


t = int(input())
for i in range(t):
	(r, g, b) = map(int, input().split())
	(r, g, b) = sorted([r, g, b])
	if r <= b - g:
		ans = r
		b -= r
		ans += min(g, b)
	else:
		ans = b - g
		r -= b - g
		b = g
		r //= 2
		b -= r
		g -= r
		ans += 2 * r
		ans += b
	print(ans)


for tt in range(int(input())):
	l = list(map(int, input().split()))
	l.sort()
	x1 = l[0]
	x2 = l[1]
	x3 = l[2]
	if x3 >= x1 + x2:
		print(x1 + x2)
	else:
		r1 = min(x3, x1)
		x3 -= x1
		r2 = min(x3, x2)
		print(max(r1 + r2, sum(l) // 2))


t = int(input())
for i in range(t):
	val = list(map(int, input().split()))
	val.sort()
	sum_val = sum(val)
	if val[2] >= sum_val / 2:
		print(sum_val - val[2])
	else:
		c = val[2] - val[1]
		val[0] -= c
		val[2] -= c
		if val[0] % 2 == 1:
			print(val[1] + (val[0] - 1) // 2 + c)
		else:
			print(val[1] + val[0] // 2 + c)


t = int(input())
for _ in range(t):
	(r, g, b) = map(int, input().split())
	print(min((r + g + b) // 2, r + g, r + b, g + b))


import sys
input = sys.stdin.readline
t = int(input())
for zz in range(t):
	ar = [int(i) for i in input().split()]
	ar.sort()
	ar[2] = min(ar[1] + ar[0], ar[2])
	print(sum(ar) // 2)


for i in range(int(input())):
	l = list(map(int, input().split()))
	s = sorted(l)
	if s[2] >= s[1] + s[0]:
		print(s[1] + s[0])
	else:
		print(sum(l) // 2)


t = int(input())
for I in range(t):
	a = [int(i) for i in input().split(' ')]
	a.sort()
	if a[2] > a[0] + a[1]:
		a[2] = a[0] + a[1]
	print(sum(a) // 2)


for _ in range(int(input())):
	l = list(map(int, input().split()))
	l.sort()
	if l[2] >= l[0] + l[1]:
		print(l[0] + l[1])
	else:
		s = l[0] + l[1] + l[2]
		print(s // 2)


for _ in range(int(input())):
	l = list(map(int, input().split()))
	l.sort()
	(s, m, b) = l
	a = s
	c = min(s, b - m)
	s -= c
	b -= c
	b -= s // 2
	m -= s - s // 2
	a += min(m, b)
	print(a)


for _ in range(int(input())):
	(a, b, c) = sorted(map(int, input().split()))
	if a + b <= c:
		print(a + b)
	else:
		print((a + b + c) // 2)


for _ in range(int(input())):
	r = sorted(list(map(int, input().split())))
	if r[2] <= r[0] + r[1]:
		print(sum(r) // 2)
	else:
		print(r[0] + r[1])


def read():
	(r, g, b) = map(int, input().split(' '))
	return (r, g, b)

def solve(r, g, b):
	(r, g, b) = sorted([r, g, b])
	d = g - r
	c = d
	(g, b) = (g - d, b - d)
	if b >= r + g:
		return c + r + g
	else:
		c += (r + g + b) // 2
	return c
for i in range(int(input())):
	result = solve(*read())
	print(result)


T = int(input())

def solve(r, g, b):
	(r, g, b) = list(sorted([r, g, b]))
	eaten = 0
	eaten += g - r
	(r, g, b) = (r, g - eaten, b - eaten)
	k = min(b - g, g, b // 2)
	eaten += 2 * k
	(r, g, b) = (r - k, g - k, b - 2 * k)
	if r == 0:
		return eaten
	else:
		assert r == b
		return eaten + (r + g + b) // 2

def sim(r, g, b):
	(r, g, b) = list(sorted([r, g, b]))
	eaten = 0
	while g != 0:
		(g, b) = (g - 1, b - 1)
		eaten += 1
		(r, g, b) = list(sorted([r, g, b]))
	return eaten
for _ in range(T):
	(r, g, b) = [int(x) for x in input().split()]
	print(solve(r, g, b))


num_queries = int(input())
for _ in range(num_queries):
	candies = [int(num_candy) for num_candy in input().split(' ')]
	candies.sort()
	(red_candies, green_candies, blue_candies) = (candies[0], candies[1], candies[2])
	max_days = 0
	if blue_candies >= red_candies + green_candies:
		num_days = 0
		num_days += red_candies
		red_candies -= red_candies
		blue_candies -= red_candies
		num_days += green_candies
		green_candies -= green_candies
		blue_candies -= green_candies
		max_days = max(max_days, num_days)
	else:
		num_days = 0
		if green_candies < blue_candies:
			num_days += blue_candies - green_candies
			red_candies -= blue_candies - green_candies
			blue_candies = green_candies
		if red_candies < green_candies:
			num_days += green_candies - red_candies
			blue_candies -= green_candies - red_candies
			green_candies = red_candies
		if red_candies >= 1:
			if (red_candies + blue_candies + green_candies) % 2 == 0:
				num_days += (red_candies + blue_candies + green_candies) // 2
			else:
				num_days += (red_candies + blue_candies + green_candies - 1) // 2
		max_days = max(max_days, num_days)
	print(max_days)


import math
for _ in range(int(input())):
	lis = [x for x in map(int, input().split())]
	lis.sort()
	if lis[2] >= lis[0] + lis[1]:
		print(lis[0] + lis[1])
	else:
		print(math.floor((lis[0] + lis[1] + lis[2]) / 2))


def days(r, g, b):
	l = [r, g, b]
	l.sort()
	s = (l[0] + l[1] - l[2]) // 2
	if s > 0:
		return min(l[0] + l[1], l[2]) + s
	else:
		return min(l[0] + l[1], l[2])
t = int(input())
L = []
for i in range(t):
	a = input()
	(r, g, b) = a.split()
	L.append(days(int(r), int(g), int(b)))
for a in L:
	print(a)


def zeroes(z):
	c = 0
	for i in z:
		if i == 0:
			c = c + 1
	return c

def sweetp(a):
	a.sort(reverse=True)
	if a[1] + a[2] > a[0]:
		return (a[0] + a[1] + a[2]) // 2
	return a[1] + a[2]
t = int(input())
for i in range(t):
	(r, g, b) = list(map(int, input().split()))
	print(sweetp([r, g, b]))


q = int(input())
for i in range(q):
	ans = 0
	(r, g, b) = sorted(map(int, input().split()))
	w = g - r
	b -= w
	g -= w
	ans += w
	ans += min(b // 2 * 2, r + g)
	rr = max(r - b // 2, 0)
	gg = max(r - b // 2, 0)
	ans += rr
	print(ans)


for _ in range(int(input())):
	(a, b, c) = sorted(map(int, input().split()))
	ans = a + b
	g = b - a
	a += g
	c -= g
	ans1 = a + c // 2
	ans = min(ans1, ans)
	print(ans)


import math
n = int(input())
result = list()
for i in range(n):
	count = 0
	colors = map(int, input().split(' '))
	sorted_colors = sorted(colors)
	if sorted_colors[0] + sorted_colors[1] >= sorted_colors[2]:
		count = math.floor(sum(sorted_colors) / 2)
	else:
		count = sorted_colors[0] + sorted_colors[1]
	result.append(count)
for i in result:
	print(i)


t = int(input())
while t:
	t += -1
	l = list(map(int, input().split()))
	l.sort()
	if l[2] - l[0] >= l[1]:
		print(l[0] + l[1])
	else:
		s = l[2] - l[1]
		l[0] = l[0] - s
		l[2] = l[2] - s
		if l[0] % 2 == 0:
			print(s + l[0] + l[2] - l[0] // 2)
		else:
			print(s + l[0] - 1 + l[2] - l[0] // 2)


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


def main():
	n = int(input())
	for _ in range(n):
		candies = list(map(int, input().split(' ')))
		candies.sort(reverse=True)
		counter = 0
		aux = candies[0] - candies[1]
		if aux > 0:
			aux2 = aux - candies[2]
			if aux2 >= 0:
				counter += candies[2]
				candies[0] -= candies[2]
				candies[2] = 0
			else:
				counter += aux2
				candies[0] -= aux2
				candies[2] -= aux2
		if not candies[2]:
			print(counter + candies[1])
		else:
			print(counter + sum(candies) // 2)
main()


for _ in range(int(input())):
	(r, g, b) = [int(__) for __ in input().split()]
	x = min(r, g, b)
	z = max(r, g, b)
	y = r + g + b - x - z
	ans = x
	if x < z - y:
		z -= x
	else:
		x -= z - y
		z -= z - y
		if z > y:
			y -= x // 2
			z -= x - x // 2
		else:
			z -= x // 2
			y -= x - x // 2
	ans += min(y, z)
	print(ans)


def calc(candies: list):
	candies.sort()
	return min(sum(candies) // 2, candies[0] + candies[1])

def main():
	n: int = int(input())
	for _ in range(n):
		candies: list = list(map(int, input().split()))
		print(calc(candies))
main()


n = int(input())
for i in range(n):
	a = list(map(int, input().split()))
	a.sort()
	if a[0] + a[1] <= a[2]:
		print(a[0] + a[1])
	else:
		x = a[0] + a[1] - a[2]
		x = 2 * int(x / 2) + a[2] - int(x / 2)
		print(x)


import math as m

def solve():
	(r, g, b) = map(int, input().split())
	x = min(r, g, b)
	y = max(r, g, b)
	z = r + g + b - x - y
	ans = 0
	ans += min(x, y - z)
	p = x
	x -= min(p, y - z)
	y -= min(p, y - z)
	l = x // 2
	r = x - l
	y -= r
	z -= l
	ans += x
	ans += min(y, z)
	print(ans)
t = int(input())
for _ in range(t):
	solve()


q = int(input())
import math
for qq in range(q):
	res = 0
	dat = list(map(int, input().split()))
	dat.sort()
	diff = dat[2] - dat[1]
	if dat[0] <= diff:
		res += dat[0]
		dat[0] = 0
	else:
		res += diff
		dat[0] -= diff
	res += dat[0]
	dat[1] -= math.ceil(dat[0] / 2)
	res += dat[1]
	print(res)


import sys
FOR_SUBMIT = True
readline = sys.stdin.readline
old_print = print

def print(i):
	if not FOR_SUBMIT:
		old_print(i)

def solve(a, b, c):
	(a, b, c) = sorted([a, b, c], reverse=True)
	print('STEP 1 : {} {} {}'.format(a, b, c))
	D = 0
	D += b - c
	(a, b, c) = (a - (b - c), b - (b - c), c)
	print('STEP 2 : {} {} {}'.format(a, b, c))
	E = min(a // 2, b)
	D += 2 * E
	(a, b, c) = (a - 2 * E, b - E, c - E)
	print('STEP 3 : {} {} {}'.format(a, b, c))
	if b > 0:
		D += b
	return D
T = int(readline())
for _ in range(T):
	(a, b, c) = readline().split(' ')
	old_print(solve(int(a), int(b), int(c)))


def solve(r, g, b):
	(r, g, b) = sorted((r, g, b))
	if b - r > g:
		return r + g
	total = 0
	diff = b - g
	total += diff
	r -= diff
	b -= diff
	total += r
	half = r // 2
	g -= half
	b -= r - half
	return total + min(g, b)
for _ in range(int(input())):
	(r, g, b) = map(int, input().split())
	print(solve(r, g, b))


for q in range(int(input())):
	can = sorted(list(map(int, input().split())))
	res = can[1] - can[0]
	can[1] = can[0]
	can[2] -= res
	res += min(can[0] * 2, can[2])
	if can[2] % 2 == 0:
		can[2] //= 2
		can[0] = max(0, can[0] - can[2])
		can[1] = max(0, can[1] - can[2])
	else:
		can[2] //= 2
		can[0] = max(0, can[0] - (can[2] + 1))
		can[1] = max(0, can[1] - can[2])
	res += min(can[0], can[1])
	print(res)


for _ in '0' * int(input()):
	(a, b, c) = sorted(map(int, input().split()))
	d = min(a, c - b)
	print(b + d + (a - d) // 2)


n = int(input())
for i in range(0, n):
	rgb = list(map(int, input().split()))
	rgb.sort()
	p = rgb[0]
	q = rgb[1]
	r = rgb[2]
	if p + q <= r:
		print(p + q)
	elif p != q != r:
		print((p + q + r) // 2)
	elif p == q == r:
		print(int(1.5 * p))
	elif p < q == r:
		print(q - p + int(1.5 * p))
	else:
		print((p + q + r) // 2)


t = int(input())
m = [0] * t
for i in range(t):
	a = input().split()
	a[0] = int(a[0])
	a[1] = int(a[1])
	a[2] = int(a[2])
	x = max(a)
	z = min(a)
	y = sum(a) - x - z
	if y + z < x:
		m[i] = y + z
	else:
		m[i] = (x + y + z) // 2
for i in range(t):
	print(m[i])


t = int(input())
for _ in range(t):
	l = list(map(int, input().split()))
	l.sort()
	k = (l[2] + l[1] - l[0]) // 2
	n = min(k, l[1])
	print(n + l[0])


import sys
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	a = list(map(int, input().split()))
	a = sorted(a)
	ans = a[0]
	b = a[0]
	c = a[2] - a[1]
	b -= c
	if b <= 0:
		ans += a[1]
	else:
		a[-1] -= c
		ans += a[-1] - b // 2 - b % 2
	print(ans)


t = int(input())
for i in range(t):
	S = input().split(' ')
	candies = [int(s) for s in S]
	max_days = 0
	candies.sort()
	d = candies[2] - candies[1]
	if candies[0] >= d:
		candies[0] -= d
		max_days = d + candies[0] + candies[1] - int(candies[0] / 2)
		if candies[0] % 2 == 1:
			max_days -= 1
	else:
		max_days = candies[0] + candies[1]
	print(max_days)


for _ in range(int(input())):
	(r, g, b) = list(map(int, input().split()))
	x = [r, g, b]
	x.sort()
	print(min((x[1] + x[0] + x[2]) // 2, x[0] + x[1]))


for _ in range(int(input())):
	X = sorted(list(map(int, input().split())))
	(Total, Sum) = (0, sum(X))
	for i in range(2):
		Total += min(Sum // 2, X[i])
		Sum -= Total * 2
	print(Total)


for _ in range(int(input())):
	lista = sorted(list(map(int, input().split())))
	print(min(lista[0] + lista[1], sum(lista) // 2))


t = int(input())
while t:
	t = t - 1
	(a, b, c) = map(int, input().split())
	l = [a, b, c]
	l.sort()
	if l[2] >= l[0] + l[1]:
		print(l[0] + l[1])
	else:
		print((a + b + c) // 2)


import sys
input = sys.stdin.readline
from math import ceil, floor, factorial

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(10000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	(r, g, b) = sorted(int_array())
	if r <= b - g:
		ans = g + r
	else:
		ans = b - g
		r -= ans
		b = g
		ans += 2 * (r // 2)
		ans += g - r // 2
	print(ans)


for i in range(int(input())):
	a = sorted([int(x) for x in input().split()])
	print(sum(a) // 2 if a[2] <= a[0] + a[1] else a[0] + a[1])


n = int(input())
for i in range(n):
	l = [int(x) for x in input().split(' ')]
	l.sort(reverse=True)
	if l[0] >= l[1] + l[2]:
		print(l[1] + l[2])
	else:
		print((l[1] + l[2] + l[0]) // 2)


n = int(input())
for i in range(n):
	rgb = [int(x) for x in input().split()]
	rgb.sort()
	diff = rgb[2] - rgb[1]
	dias = 0
	if diff >= rgb[0]:
		dias += rgb[0]
		rgb[2] -= rgb[0]
		dias += rgb[1]
		print(dias)
	else:
		dias += diff
		rgb[2] -= diff
		rgb[0] -= diff
		dias += rgb[0] // 2 + rgb[1]
		print(dias)


t = int(input())
for _ in range(t):
	A = [int(v) for v in input().split()]
	A.sort()
	if A[0] + A[1] >= A[2]:
		print(sum(A) // 2)
	else:
		print(A[0] + A[1])


import math
a = int(input())
for i in range(0, a):
	arr = list(map(int, input().split()))
	arr.sort()
	a = arr[0]
	if a >= arr[2] - arr[1]:
		a = arr[0] - (arr[2] - arr[1])
		arr[2] = arr[1]
	else:
		arr[2] = arr[2] - a
		a = 0
	arr[2] = arr[2] - math.ceil(a / 2)
	arr[1] = arr[1] - math.floor(a / 2)
	print(arr[0] + min(arr[1], arr[2]))


t = int(input())
while t:
	(r, g, b) = map(int, input().split())
	l = []
	l.append(r)
	l.append(g)
	l.append(b)
	l.sort()
	k = 0
	if l[2] - l[1] >= l[0]:
		print(l[0] + l[1])
	else:
		r = l[0]
		r = r - (l[2] - l[1])
		k = l[2] - l[1]
		l[2] = l[1]
		if r % 2 == 0:
			k = k + r + (l[1] - r // 2)
		else:
			k = k + r + (l[1] - r // 2) - 1
		print(k)
	t -= 1


for i in range(int(input())):
	a = sorted(map(int, input().split()))
	k = a[0] + a[1]
	print(min(k, (k + a[2]) // 2))


from sys import stdin
import math

def inp():
	return stdin.readline().strip()
t = int(inp())
for _ in range(t):
	ar = [int(x) for x in inp().split()]
	ar.sort()
	print(min(sum(ar) // 2, ar[0] + ar[1]))


for _ in range(int(input())):
	A = list(map(int, input().split()))
	A.sort()
	a = A[0]
	ans = 0
	if len(set(A)) == 1:
		ans = A[0] + A[0] // 2
	elif A[1] >= a // 2:
		ans += a
		if A[2] - A[1] >= a:
			A[2] -= a
			ans += min(A[1], A[2])
		else:
			a -= A[2] - A[1]
			A[2] = A[1]
			A[2] -= a // 2
			A[1] -= a // 2
			if a % 2 != 0:
				A[2] -= 1
			ans += A[2]
	print(ans)


t = int(input())
while t > 0:
	t -= 1
	nums = list(map(int, input().split()))
	nums.sort()
	if nums[0] + nums[1] < nums[2]:
		print(nums[0] + nums[1])
	else:
		print(sum(nums) // 2)


import math
n = int(input())
for i in range(n):
	lis = [int(x) for x in input().split()]
	lis.sort()
	ans = 0
	a = lis[2] - lis[1]
	if a >= lis[0]:
		ans += lis[1] + lis[0]
	else:
		ans += lis[0]
		lis[0] -= a
		l = math.ceil(lis[0] / 2)
		ans += lis[1] - l
	print(ans)


def findZ(sweets):
	j = 0
	for i in sweets:
		if i <= 0:
			j += 1
	return not j >= 2

def cal():
	l = 0
	sweets = [int(x) for x in input().split()]
	sweets.sort()
	if sweets[2] - sweets[0] > sweets[1]:
		l += sweets[0] + sweets[1]
		print(l)
	elif sweets[2] - sweets[0] == sweets[1]:
		l = sweets[2]
		print(l)
	else:
		l += sweets[0]
		sweets[0] -= sweets[2] - sweets[1]
		sweets[2] = sweets[1]
		if sweets[0] % 2 != 0:
			sweets[0] -= 1
			sweets[2] -= 1
		l += min(sweets[2], sweets[1]) - sweets[0] // 2
		print(l)
for x in range(int(input())):
	cal()


n = int(input())
for i in range(n):
	a = list(map(int, input().strip().split()))
	a = sorted(a)
	print(min(a[0] + a[1], sum(a) // 2))


n = int(input())
for i in range(0, n):
	a = input().split(' ')
	for j in range(0, len(a)):
		a[j] = int(a[j])
	a.sort()
	a0 = a[0]
	diff = a[2] - a[1]
	if a0 <= diff:
		print(a[1] + a0)
	else:
		a[0] = a[0] - diff
		a[2] = a[1]
		small1 = int(a[0] / 2)
		small2 = int(a[0] % 2)
		a[0] = 0
		a[1] -= small1
		a[2] = a[2] - small1 - small2
		a.sort()
		print(a0 + a[1])


for _ in range(int(input())):
	(r, g, b) = sorted(list(map(int, input().split())))
	m = g - r
	g -= m
	b -= m
	if r + g <= b:
		print(m + r + g)
	else:
		n = b
		r -= n // 2
		g -= n // 2
		print(m + n // 2 * 2 + r)


for i in range(int(input())):
	(a, b, c) = sorted(map(int, input().split()))
	x = min(a, c - b)
	a -= x
	c -= x
	print(x + a // 2 + min(c, b))


def to_str(num):
	a = num // 1000 % 10
	b = num // 100 % 10
	c = num // 10 % 10
	d = num % 10
	return str(a) + str(b) + str(c) + str(d)
t = int(input())
for tt in range(t):
	a = list(map(int, input().split()))
	a.sort()
	if a[0] == 0:
		print(a[1])
		continue
	if a[1] == 0:
		print(0)
		continue
	d = a[2] - a[1]
	if d <= a[0]:
		a[0] -= d
		a[2] -= d
		a[1] -= a[0] // 2 + (a[0] % 2 != 0)
		print(d + a[0] + a[1])
	else:
		a[2] -= d
		print(a[0] + min(a[1], a[2]))


import math
t = int(input())
for _ in range(t):
	ali = list(map(int, input().split()))
	ali.sort()
	if ali[2] > ali[0] + ali[1]:
		print(ali[0] + ali[1])
	else:
		q = math.floor(sum(ali) / 2)
		print(q)


for t in range(int(input())):
	A = sorted(list(map(int, input().split())))
	a = A[0]
	b = A[1]
	c = A[2]
	if c >= a + b:
		print(a + b)
	else:
		print((a + b + c) // 2)


ent = int(input())
for i in range(ent):
	lst = [int(x) for x in input().split(' ')]
	lst.sort()
	res = (lst[0] + lst[1] + lst[2]) // 2 if lst[2] <= lst[1] + lst[0] else lst[1] + lst[0]
	print(res)


import sys
input = sys.stdin.readline
t = int(input())
for testcases in range(t):
	(r, g, b) = sorted(map(int, input().split()))
	if b > r + g:
		print(r + g)
	else:
		print((r + g + b) // 2)


sp = lambda : list(map(int, input().split()))
si = lambda : int(input())
TESTCASES = int(input())
for tc in range(TESTCASES):
	(r, g, b) = sorted(sp())
	if b > r + g:
		b = r + g
	print((r + g + b) // 2)


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
for _ in range(get_int()):
	s = sorted(get_list())
	if s[0] + s[1] <= s[2]:
		print(s[0] + s[1])
	else:
		count = 0
		f = s[2] - s[1]
		count += f
		s[2] -= f
		s[0] -= f
		g = s[1] - s[0]
		count += g
		s[1] -= g
		s[2] -= g
		if s[0] == s[1] == s[2] == 1:
			count += 1
		else:
			count += s[0] // 2 * 3
			if s[0] % 2 == 1:
				count += 1
		print(count)


import math
for _ in range(int(input())):
	l = list(map(int, input().split()))
	l.sort()
	k = l[2] - l[1]
	if k > 0:
		if l[0] >= k:
			l[0] -= k
			l[2] -= k
			s = k
			l[2] -= math.ceil(l[0] / 2)
			l[1] -= l[0] // 2
			s += l[0]
		else:
			l[2] -= l[0]
			s = l[0]
			l[0] = 0
	else:
		s = l[0]
		l[2] -= math.ceil(l[0] / 2)
		l[1] -= l[0] // 2
	s += min(l[1], l[2])
	print(s)


t = int(input())
for i in range(t):
	a = sorted(map(int, input().split()))
	if sum(a) - a[-1] < a[-1]:
		print(sum(a) - a[-1])
	else:
		print(sum(a) // 2)


t = int(input())
for _ in range(t):
	(a, b, c) = sorted([int(x) for x in input().split()])
	if a + b <= c:
		print(a + b)
	else:
		print(c + (a + b - c) // 2)


import math
import copy
t = int(input())
for _ in range(t):
	a = [int(i) for i in input().split()]
	a.sort()
	if a[2] <= a[0] + a[1]:
		print(int((a[0] + a[1] + a[2]) / 2))
	else:
		print(a[0] + a[1])


import math
for _ in range(int(input())):
	(a, b, c) = sorted(map(int, input().split()))
	if c > a + b:
		print(a + b)
	else:
		print(int(math.floor(a + b + c) / 2))


import math
q = int(input())
for i in range(q):
	l = list(map(int, input().split(' ')))
	l.sort()
	dif = l[2] - l[1]
	if dif >= l[0]:
		l[2] -= l[0]
		print(l[0] + min(l[1], l[2]))
	else:
		x = math.floor((l[0] - dif) / 2)
		l[1] -= x
		l[2] -= l[0] - x
		print(l[0] + min(l[1], l[2]))


t = int(input())
for test in range(t):
	(r, g, b) = map(int, input().split())
	if max(r, g, b) >= r + g + b - max(r, g, b):
		print(r + g + b - max(r, g, b))
	else:
		print((r + g + b) // 2)


for _ in range(int(input())):
	arr = [int(i) for i in input().split()]
	arr.sort()
	if arr[2] > arr[0] + arr[1]:
		print(arr[0] + arr[1])
	else:
		print(int((arr[0] + arr[1] + arr[2]) / 2))


def parsing(ent):
	arr = []
	ent += ' '
	u = 0
	for i in ent:
		if i != ' ':
			u = u * 10 + int(i)
		else:
			arr.append(u)
			u = 0
	return arr
a = 0
a = int(input())
for i in range(a):
	arr = {}
	ent = str(input())
	arr = parsing(ent)
	arr.sort()
	if arr[2] - arr[1] > arr[0]:
		arr[2] -= arr[0]
	else:
		x = arr[2] - arr[1]
		arr[2] = arr[1]
		arr[2] -= int((arr[0] - x) / 2)
		arr[1] -= arr[0] - x - int((arr[0] - x) / 2)
	print(arr[0] + min(arr[1], arr[2]))


for i in range(int(input())):
	a = sorted([int(s) for s in input().split()], reverse=True)
	k = 0
	if a[0] >= a[1] + a[2]:
		print(a[1] + a[2])
		continue
	else:
		print((a[0] + a[1] + a[2]) // 2)
		continue


t = int(input())
for _ in range(t):
	(r, g, b) = sorted(map(int, input().split()))
	ans = 0
	if r + g <= b:
		ans = r + g
	else:
		ans = (r + g + b) // 2
	print(ans)


x = int(input())
for i in range(x):
	y = input().split(' ')
	y = list(map(int, y))
	a = min(y[0], y[1], y[2])
	c = max(y[0], y[1], y[2])
	b = y[0] + y[1] + y[2] - a - c
	if a + b <= c:
		print(a + b)
	else:
		print(c + (a - (c - b)) // 2)


for _ in range(int(input())):
	l = [int(i) for i in input().split()]
	l.sort()
	a = l[0]
	b = l[1]
	c = l[2]
	if c >= a + b:
		print(a + b)
	else:
		print(c + (a + b - c) // 2)


t = int(input())
for _ in range(t):
	(r, g, b) = map(int, input().split())
	a = sorted([r, g, b])[::-1]
	res = 0
	m = min(a[0] - a[1], a[2])
	res += m
	a[0] -= m
	a[2] -= m
	if a[2] % 2 == 0:
		res += a[2]
		a[0] -= a[2] // 2
		a[1] -= a[2] // 2
	else:
		res += a[2]
		a[0] -= a[2] // 2 + 1
		a[1] -= a[2] // 2
	res += min(a[0], a[1])
	print(res)


t = int(input())
for i in range(t):
	(r, g, b) = list(map(int, input().split()))
	x1 = max(r, g, b)
	x3 = min(r, g, b)
	x2 = r + g + b - x1 - x3
	k = x1 - x2
	ans = min(k, x3)
	x1 -= min(k, x3)
	x3 -= min(k, x3)
	k = x3 // 2
	ans += 3 * k
	x1 -= 2 * k
	x2 -= 2 * k
	x3 -= 2 * k
	ans += x2
	x1 -= x2
	if x1 != 0:
		ans += x3 % 2
	print(ans)


import os, sys, math
if os.path.exists('in.in'):
	sys.stdin = open('in.in', 'r')
t = int(input())
for ti in range(t):
	(r, g, b) = sorted(list(map(int, input().split())))
	delta = b - g
	if r < delta:
		b -= r
		ans = r + min(b, g)
	else:
		ans = delta
		r -= delta
		b -= delta
		if r & 1:
			r -= 1
		t = min(r // 2, b)
		ans += t * 2
		r -= t * 2
		b -= t
		g -= t
		ans += g
	print(ans)


n = int(input())
for _ in range(n):
	d = [int(x) for x in input().strip().split()]
	m = max(d)
	s = sum(d)
	z = s - m
	if z > m:
		print(s // 2)
	else:
		print(z)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	x = max(a, b, c)
	y = min(a, b, c)
	z = a + b + c - x - y
	if x - y >= z:
		print(y + z)
	else:
		q = 0
		q += x - z
		f = x
		x = z
		y = y - f + z
		print(q + (x + y + z) // 2)


t = int(input())
for a in range(t):
	s = [int(i) for i in input().split()]
	ss = sum(s)
	ms = max(s)
	if ss - ms < ms:
		print(min(ss - ms, ms))
	else:
		print(ss // 2)


for _ in range(int(input())):
	l = list(map(int, input().split()))
	s = 0
	d = max(l)
	l.remove(d)
	s += d
	if sum(l) < s:
		print(sum(l))
	elif sum(l) == s or sum(l) == s + 1:
		print(s)
	else:
		f = sum(l) - s
		s += f // 2
		print(s)


t = int(input())
for _ in range(t):
	(r, g, b) = sorted(map(int, input().split()))
	ans = 0
	if b - g >= r:
		g += r
		ans = g
	elif b - g < r:
		tmp = b - g
		g += tmp
		r -= tmp
		ans = g
		if r > 1:
			ans += r // 2
	print(ans)


t = int(input())
for _ in range(t):
	(r, g, b) = sorted(list(map(int, input().split())))
	offset = b - g
	reminder = max(0, r - offset)
	added = min(r, offset)
	g += min(offset, r)
	g += reminder // 2
	b += reminder // 2
	print(min(g, b))


from sys import stdin
t = int(stdin.readline().rstrip())
while t > 0:
	l = list(map(int, stdin.readline().split()))
	l.sort()
	if l[0] + l[1] <= l[2]:
		print(l[0] + l[1])
	else:
		print((l[0] + l[1] + l[2]) // 2)
	t -= 1


for i in range(int(input())):
	(r, g, b) = sorted(list(map(int, input().split())))
	if r + g <= b:
		print(r + g)
	else:
		print((r + g + b) // 2)


for _ in range(int(input())):
	a = sorted([int(x) for x in input().split()])
	if a[2] >= a[1] + a[0]:
		print(a[1] + a[0])
	else:
		print((a[2] + a[1] + a[0]) // 2)


import sys
input = sys.stdin.readline
Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]
for A in Query:
	A.sort()
	tmp = A[0]
	d = A[2] - A[1]
	if d > tmp:
		ans = A[0] + A[1]
	else:
		ans = A[0] + A[1] - (tmp - d + 1) // 2
	print(ans)


t = int(input())
for _ in range(t):
	l = list(map(int, input().split()))
	l.sort()
	if l[1] != l[2]:
		if l[2] - l[1] >= l[0]:
			ans = l[0] + l[1]
		else:
			y = l[2] - l[1]
			x = l[0] - (l[2] - l[1])
			ans = max(y + x + l[1] - x // 2 - x % 2, l[2])
	else:
		ans = max(l[0] + l[2] - l[0] // 2 - l[0] % 2, l[2])
	print(ans)


from math import floor
n = int(input())

def number_of_ways(k):
	a = k.split(' ')
	b1 = int(a[0])
	b2 = int(a[1])
	b3 = int(a[2])
	b = [b1, b2, b3]
	c = sorted(b)
	if c[2] >= c[1] + c[0]:
		return c[1] + c[0]
	else:
		return floor((c[0] + c[1] + c[2]) / 2)
ans = []
for p in range(n):
	x = input()
	ans = ans + [number_of_ways(x)]
for anss in ans:
	print(anss)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
testcases = int(input())
for j in range(testcases):
	(r, g, b) = map(int, input().split())
	maxy = max(r, g, b)
	minny = min(r, g, b)
	mid = r + g + b - maxy - minny
	eats = minny
	diff = maxy - mid
	maxy -= min(diff, minny)
	minny -= min(diff, minny)
	maxy -= math.ceil(minny / 2)
	mid -= math.floor(minny / 2)
	eats += min(mid, maxy)
	print(eats)


def A():
	conf = list(map(int, input().split()))
	conf.sort()
	mins = conf[0] + conf[1]
	if mins <= conf[2]:
		print(mins)
	else:
		print(sum(conf) // 2)

def main():
	t = int(input())
	for _ in range(t):
		A()
main()


def solve(l):
	l.sort()
	l.reverse()
	m = l[0]
	r = l[1] + l[2]
	ans = min(m, r)
	if m < r:
		temp = r - m
		ans += temp // 2
	print(ans)
t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	solve(l)


t = int(input())
for i in range(t):
	(r, g, b) = sorted(list(map(int, input().split())))
	diff = min(r, b - g)
	print(g + diff + (r - diff) // 2)


def solve():
	for _ in range(int(input())):
		(r, g, b) = map(int, input().split())
		rgb = sorted([r, g, b])
		curr = rgb[-1]
		days = 0
		if curr > sum(rgb) - curr:
			for i in rgb[:-1]:
				if curr > 0:
					days += min(i, curr)
					curr -= min(i, curr)
			print(days)
		else:
			print(sum(rgb) // 2)
solve()


def magic(l):
	l.sort()
	(r, g, b) = l
	if r + g >= b:
		return (r + g + b) // 2
	else:
		return r + g
t = int(input())
for _ in range(t):
	l = list(map(int, input().split()))
	print(magic(l))


t = int(input())
for _ in range(t):
	rgb = [int(x) for x in input().split(' ')]
	rgb.sort()
	(x, y, z) = (rgb[0], rgb[1], rgb[2])
	diff = z - y
	z = z - min(x, diff)
	x = x - min(x, diff)
	z = z - x // 2
	y = y - (x - x // 2)
	days = rgb[0] + min(z, y)
	print(days)


from sys import stdin
import math
t = int(stdin.readline())
while t:
	l = list(map(int, stdin.readline().split()))
	l.sort()
	diff = l[2] - l[1]
	if l[0] <= diff:
		l[1] += l[0]
		ans = min(l[1], l[2])
	else:
		l[1] = l[2]
		rem = l[0] - diff
		l[1] += rem // 2
		l[2] += rem - rem // 2
		ans = min(l[1], l[2])
	print(ans)
	t -= 1


def ab():
	c = list(map(int, input().split()))
	c.sort()
	print(min(c[0] + c[1], sum(c) // 2))
for i in range(0, int(input())):
	ab()


t = int(input())
for i in range(t):
	l = [int(zax) for zax in input().split()]
	l.sort()
	(a, b, c) = l
	diff = c - b
	if diff >= a:
		count = a
		c -= a
		count += min(b, c)
	else:
		count = a
		c -= diff
		left = a - diff
		if left % 2 == 0:
			half1 = left // 2
			half2 = left // 2
		else:
			half1 = left // 2
			half2 = left // 2 + 1
		c -= half2
		b -= half1
		count += min(c, b)
	print(count)


for _ in range(int(input())):
	a = sorted(map(int, input().split()))
	ans = a[0]
	d = min(a[0], a[2] - a[1])
	a[2] -= d
	a[2] -= (a[0] - d + 1) // 2
	a[1] -= (a[0] - d) // 2
	ans += min(a[1], a[2])
	print(ans)


t = int(input())
for _ in range(t):
	rgb = [int(i) for i in input().split()]
	s = sum(rgb)
	if max(rgb) > sum(rgb) - max(rgb):
		s -= 2 * max(rgb) - sum(rgb)
	if s % 2 != 0:
		s -= 1
	print(int(s / 2))


for t in range(int(input())):
	(r, g, b) = map(int, input().split())
	mini = min(r, g, b)
	maxi = max(r, g, b)
	g = r + g + b
	r = mini
	b = maxi
	g -= r + b
	if r + g <= b:
		print(r + g)
	else:
		print((r + b + g) // 2)


t = int(input())
output = list()
for i in range(t):
	piles = list(map(int, input().split()))
	piles = sorted(piles)
	if piles[2] - piles[1] >= piles[0]:
		output.append(piles[0] + piles[1])
	else:
		piles[0] -= piles[2] - piles[1]
		b = piles[2] - piles[1]
		piles[2] = piles[1]
		if piles[0] % 2 == 0:
			piles[1] -= int(piles[0] / 2)
			piles[2] -= int(piles[0] / 2)
		else:
			piles[1] -= int((piles[0] - 1) / 2)
			piles[2] -= int((piles[0] + 1) / 2)
		b += piles[0]
		b += piles[2]
		output.append(b)
for i in output:
	print(i)


t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	t = a[2]
	d = a[0] - a[1]
	if d > t:
		a[0] -= t
	else:
		fh = a[2] // 2
		sh = a[2] - fh
		a[0] -= fh
		a[1] -= sh
		s = a[0] + a[1]
		a[0] = s // 2
		a[1] = s - s // 2
	t += min(a[0], a[1])
	print(t)


import math
inp = int(input())
for i in range(inp):
	days = 0
	candies = [int(x) for x in input().split()]
	candies.sort()
	a = candies[0]
	b = candies[1]
	c = candies[2]
	if a + b <= c:
		print(a + b)
	elif a + b > c:
		print(math.floor((a + b + c) / 2))


t = int(input(''))
value = []
for i in range(t):
	case = input('')
	value.append(case.split(' '))
	value[i] = list(map(int, value[i]))
for j in value:
	max_index = j.index(max(j))
	max_val = j.pop(max_index)
	sigma = 0
	for k in range(2):
		sigma = sigma + j[k]
	if max_val - sigma >= 0:
		print(sigma)
	else:
		print((sigma + max_val) // 2)


t = int(input())
for i in range(t):
	(r, g, b) = map(int, input().split())
	arr = [r, g, b]
	arr.sort()
	diff = arr[2] - arr[1]
	arr[2] -= arr[0]
	if arr[2] < arr[1]:
		arr[2] = int((arr[1] + arr[2]) / 2)
		arr[1] = arr[2]
	print(arr[0] + min(arr[2], arr[1]))


for _ in range(int(input())):
	candies = sorted([int(x) for x in input().split()])
	print(min(candies[0] + candies[1], sum(candies) // 2))


t = int(input())
for i in range(t):
	candies = list(map(int, input().split(' ')))
	candies.sort()
	if candies[2] > candies[1] + candies[0]:
		print(candies[0] + candies[1])
	else:
		print(int((candies[2] + candies[1] + candies[0]) / 2))


for i in range(int(input())):
	ll = list(map(int, input().split()))
	ll.sort(reverse=True)
	count = ll.pop()
	x = (ll[0] - ll[1] + count) // 2
	if ll[0] - count > ll[1]:
		ll[0] -= count
	else:
		ll[0] -= x
		ll[1] -= count - x
	count += min(ll)
	print(count)


testcases = int(input())
for i in range(testcases):
	piles = [int(j) for j in input().split()]
	piles.sort(reverse=True)
	if piles[0] >= piles[1] + piles[2]:
		print(piles[1] + piles[2])
	else:
		piles[0] += (piles[1] + piles[2] - piles[0]) // 2
		print(piles[0])


def solve(r, g, b):
	if r > g:
		(r, g) = (g, r)
	if g > b:
		(g, b) = (b, g)
	if r + g <= b:
		print(r + g)
	else:
		print(int((r + g + b) / 2))
T = int(input())
for case in range(1, T + 1):
	(r, g, b) = input().split()
	(r, g, b) = (int(r), int(g), int(b))
	solve(r, g, b)


for T in range(int(input())):
	arr = [int(x) for x in input().split()]
	arr.sort(reverse=True)
	ans = 0
	(a, b, c) = arr
	ans += min(a - b, c)
	c -= min(a - b, c)
	a -= ans
	a -= c // 2
	b -= c // 2 + c % 2
	print(ans + b + c)


import sys
import collections
from collections import Counter
import itertools
import math
import timeit
input = sys.stdin.readline

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
t = ii()
for _ in range(t):
	(r, g, b) = sorted(mi())
	print(r + min(g, (b + g - r) // 2))


t = int(input())
while t:
	l = list(map(int, input().split()))
	l.sort()
	l1 = l[0]
	l2 = l[1]
	l3 = l[2]
	if l3 - l2 > l1:
		print(l1 + l2)
	else:
		print(l3 - l2 + int((l1 - l3 + l2) / 2) + l2)
	t = t - 1


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	m1 = min(a, b, c)
	m3 = max(a, b, c)
	m2 = sum([a, b, c]) - m1 - m3
	ans = 0
	if m3 >= m1 + m2:
		ans = m1 + m2
	else:
		ans = sum([a, b, c]) // 2
	print(ans)


from math import *
for _ in range(int(input())):
	l = [*map(int, input().split())]
	l.sort()
	x = int(floor(sum(l) / 2))
	if l[0] + l[1] < x:
		print(l[0] + l[1])
	else:
		print(x)


for _ in range(int(input())):
	(b, g, r) = sorted(map(int, input().split()))
	if r >= b + g:
		print(b + g)
	else:
		print((r + g + b) // 2)


t = int(input())
for i in range(t):
	case = [int(e) for e in input().split()]
	case.sort(reverse=True)
	days = 0
	diff = case[0] - case[1]
	if diff >= case[2]:
		days += case[2]
		case[0] -= case[2]
		days += min(case[0], case[1])
	else:
		days += diff
		case[0] -= diff
		case[2] -= diff
		days += case[2] // 2 + case[1]
	print(days)


z = input
import math
for i in range(int(input())):
	(a, b, c) = sorted(list(map(int, z().split())))
	print(min(a + b, (a + b + c) // 2))


t = int(input())
ans = []
for _ in range(t):
	(r, g, b) = map(int, input().split())
	c = sorted([r, g, b])
	if c[0] + c[1] > c[2]:
		temp = (c[0] + c[1] - c[2]) // 2
		ans.append(c[2] + temp)
	else:
		ans.append(c[0] + c[1])
print('\n'.join([str(x) for x in ans]))


def solve(x):
	ans = 0
	x.sort()
	diff = x[-1] - x[1]
	fi = min(x[0], diff)
	ans += fi
	x[0] -= fi
	x[-1] -= diff
	ans += min(x[1], x[-1]) + x[0] // 2
	return ans
t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	print(solve([a, b, c]))


t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	a.sort()
	x = a[2] - a[1]
	if x >= a[0]:
		a[1] += a[0]
		print(min(a[1], a[2]))
	else:
		a[1] += x
		a[0] -= x
		x = a[0] // 2
		y = a[0] - x
		a[1] += x
		a[2] += y
		print(min(a[1], a[2]))


for i in range(int(input())):
	(a, b, c) = sorted(list(map(int, input().split())))
	diff = min(a, c - b)
	print(b + diff + (a - diff) // 2)


N = int(input())
for i in range(N):
	X = sorted([int(i) for i in input().strip().split()])
	m = X[0] + X[1]
	if m >= X[2]:
		print((m + X[2]) // 2)
	else:
		print(m)


t = int(input())
for i in range(t):
	(r, g, b) = map(int, input().split())
	p = [r, g, b]
	p = sorted(p)
	if p[2] <= p[0] + p[1]:
		print(int((p[0] + p[1] + p[2]) / 2))
	else:
		print(p[0] + p[1])


def solve():
	z = [int(x) for x in input().split(' ')]
	if max(z) >= sum(z) / 2:
		ans = 2 * (sum(z) - max(z))
	else:
		ans = sum(z) - sum(z) % 2
	return ans // 2
t = int(input())
for case in range(t):
	print(solve())


from math import *

def counter(low, mid, high):
	cnt = 0
	if mid >= low // 2:
		cnt += low // 2
		mid -= low // 2
		low -= low // 2
	else:
		cnt += mid
		mid = 0
		low -= mid
	high -= low
	cnt += low
	cnt += min(mid, high)
	return cnt
for _ in range(int(input())):
	(low, mid, high) = sorted(map(int, input().split()))
	count = 0
	if high != mid:
		if high - mid < low:
			count += high - mid + counter(low - (high - mid), mid, mid)
		else:
			count += low + min(high, mid)
	else:
		count = counter(low, mid, high)
	print(count)


def main():
	(q, w, e) = map(int, input().split())
	[q, w, e] = sorted([q, w, e])
	if e >= q + w:
		print(q + w)
	else:
		a = w - q
		e -= w - q
		w = q
		print(a + (q + w + e) // 2)
for i in range(int(input())):
	main()


n = int(input())
for i in range(n):
	(r, g, b) = map(int, input().split())
	l = [r, g, b]
	l.sort()
	if l[2] >= l[0] + l[1]:
		print(l[0] + l[1])
	elif (-l[2] + l[1] + l[0]) % 2 == 0:
		print(l[2] + (-l[2] + l[0] + l[1]) // 2)
	elif (-l[2] + l[1] + l[0]) % 2 == 1:
		print(l[2] - 1 + (-l[2] + 1 + l[0] + l[1]) // 2)


import math
t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if b > c:
		(b, c) = (c, b)
	if a > b:
		(a, b) = (b, a)
	if c - b >= a:
		r = 2 * a
	else:
		r = math.floor((c - b + 3 * a) / 2)
	print(b - a + r)


n = int(input())
while n:
	n -= 1
	l = list(map(int, input().split()))
	l = sorted(l)
	(a, b, c) = (l[0], l[1], l[2])
	s = 0
	if b == c:
		if a % 2 == 0:
			b -= a // 2
			c -= a // 2
		else:
			b -= a // 2
			c -= a // 2 + 1
		print(a + min(b, c))
	else:
		m = c - b
		if a < m:
			s += a
			c -= a
			print(s + min(b, c))
		else:
			a -= m
			c -= m
			if a % 2 == 0:
				b -= a // 2
				c -= a // 2
			else:
				b -= a // 2
				c -= a // 2 + 1
			print(m + a + min(b, c))


import math
n = int(input())
for i in range(n):
	l = list(map(int, input().split()))
	l.sort()
	print(l[0] + l[1] - max(0, math.ceil((l[0] - (l[2] - l[1])) / 2)))


t = int(input())
for _ in range(t):
	lst = list([int(x) for x in input().split()])
	(a, b, c) = sorted(lst)
	ans = 0
	if c - b <= a:
		buf = c - b
		c -= buf
		a -= buf
		ans += buf
		b -= a % 2
		b -= a // 2
		ans += a
	else:
		c -= a
		ans += a
		a = 0
	print(ans + b)


def fastio():
	import sys
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from collections import defaultdict as dd
(t,) = I()
while t:
	t -= 1
	l = I()
	l.sort()
	(r, g, b) = l
	if r + g <= b:
		print(r + g)
	else:
		print((r + g + b) // 2)


for _ in range(int(input())):
	a = list(map(int, input().split()))
	a.sort()
	p = 0
	s = a[-1] - a[-2]
	if a[-1] == a[-2]:
		s2 = a[0] // 2
		s1 = a[0] - s2
		p = p + a[0]
		a[-1] -= s2
		a[-2] -= s1
	elif s > a[0]:
		a[-1] -= a[0]
		p = p + a[0]
	else:
		a[-1] -= s
		q = a[0] - s
		p1 = q // 2
		p2 = q - p1
		a[-2] = a[-2] - p1
		a[-1] = a[-1] - p2
		p = p + a[0]
	p = p + min(a[-1], a[-2])
	print(p)


import math

def init():
	t = int(input())
	for i in range(t):
		candies = list(map(lambda x: int(x), input().split(' ')))
		candies.sort()
		if candies[0] + candies[1] <= candies[2]:
			counter = candies[0] + candies[1]
		elif candies[0] == candies[1] and candies[1] == candies[2]:
			counter = math.floor(3 * candies[0] / 2)
		else:
			counter = int(math.floor((candies[0] + candies[1] + candies[2]) / 2))
		print(counter)
init()


for u in range(int(input())):
	l = list(map(int, input().split()))
	l.sort()
	if l[0] + l[1] <= l[2]:
		print(l[0] + l[1])
	else:
		print(sum(l) // 2)


for _ in range(int(input())):
	(a, b, c) = sorted(list(map(int, input().split())))
	d = c - b
	print(b + min(d, a) + max(0, a - d) // 2)


from sys import stdin, stdout
from collections import defaultdict, deque
t = int(stdin.readline().strip())
for _ in range(t):
	arr = list(map(int, stdin.readline().split()))
	arr.sort()
	(r, g, b) = arr
	ans = r
	if b - g >= r:
		b -= r
		ans += g
	else:
		r -= b - g
		b = g
		b -= r // 2
		g -= r // 2
		if r % 2 == 1:
			g -= 1
		ans += g
	print(ans)


def main():
	t = int(input())
	for line in range(t):
		[r, g, b] = [int(x) for x in input().split()]
		print(solver(r, g, b))

def solver(r, g, b):
	colors = sorted([r, g, b])
	if colors[0] + colors[1] < colors[2]:
		return colors[0] + colors[1]
	else:
		return (colors[0] + colors[1] + colors[2]) // 2
main()


import math

def compute(arr):
	arr.sort()
	if arr[2] >= arr[0] + arr[1]:
		return arr[0] + arr[1]
	else:
		return math.floor(sum(arr) / 2)
t = int(input())
for _ in range(t):
	(r, g, b) = map(int, input().split())
	print(compute([r, g, b]))


import sys
import bisect
import heapq
from math import *
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = pow(10, 9) + 7

def inp():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase():
	for p in range(int(inp())):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def solve():
	a = lis()
	a = sorted(a)
	out(min(a[0] + a[1], sum(a) // 2))
	nextline()
testcase()


a = int(input())
for i in range(a):
	(x, y, z) = map(int, input().split())
	(x, y, z) = sorted([x, y, z])
	k = z - y
	if k == 0:
		y += x // 2
		print(y)
	elif k > x:
		y += x
		print(y)
	else:
		x -= z - y
		y = z
		z += x // 2
		print(z)


for _ in range(int(input())):
	arr = list(map(int, input().split()))
	arr.sort()
	print(min(arr[0] + arr[1], sum(arr) // 2))


t = int(input())
for i in range(t):
	rgb = list(map(int, input().split()))
	rgb.sort()
	ans = min(sum(rgb) // 2, sum(rgb[:2]))
	print(ans)


import sys
input = lambda : sys.stdin.readline().rstrip()
t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	a.sort()
	ans = a[1] - a[0]
	(a[1], a[2]) = (a[0], a[2] - a[1] + a[0])
	if a[1] * 2 < a[2]:
		ans += a[1] * 2
		print(ans)
		continue
	cnt = a[2] - a[1]
	(a[0], a[1], a[2]) = (a[0] - cnt, a[1] - cnt, a[2] - cnt * 2)
	ans += cnt * 2
	ans += a[0] // 2 * 3 + a[0] % 2
	print(ans)


from collections import deque
from math import ceil, sqrt

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
n = ii()
while n:
	n -= 1
	a = li()
	a.sort()
	r = a[0]
	g = a[1]
	b = a[2]
	x = r + g
	if b >= x:
		print(x)
	else:
		ans = b
		x -= b
		ans += x // 2
		print(ans)


import sys

def solve():
	(a, b, c) = map(int, sys.stdin.readline().split())
	(a, b, c) = sorted([a, b, c])
	(ml, mr) = (0, a + b + c)
	while mr - ml > 1:
		m = ml + mr >> 1
		z = max(0, m - a)
		y = max(0, m - b)
		if y + z <= min(m, c):
			ml = m
		else:
			mr = m
	print(ml)
(t,) = map(int, sys.stdin.readline().split())
for _ in range(t):
	solve()


t = int(input())
while t:
	(r, g, b) = map(int, input().split())
	a = [r, g, b]
	a.sort()
	if a[2] - a[1] >= a[0]:
		print(a[0] + a[1])
	else:
		temp = a[0]
		a[0] -= a[2] - a[1]
		a[2] = a[1]
		if a[0] % 2 == 0:
			print(temp + a[1] - a[0] // 2)
		else:
			print(temp + a[1] - a[0] // 2 - 1)
	t -= 1


t = int(input())
for i in range(t):
	M = [int(x) for x in input().split()]
	a = min(M)
	M.remove(a)
	b = min(M)
	c = max(M)
	if c < b + a:
		if (a - c + b) % 2 == 0:
			print((a + b + c) // 2)
		else:
			print((a + b + c - 1) // 2)
	else:
		print(a + b)


import math
for _ in range(int(input())):
	x = list(map(int, input().split()))
	x.sort()
	t1 = x[2] - x[1]
	if x[0] > t1:
		x[2] = x[1]
		x[0] -= t1
		y = math.ceil(x[0] / 2)
		z = math.floor(x[0] / 2)
		print(t1 + x[0] + min(x[2] - y, x[1] - z))
	else:
		print(x[0] + x[1])


import math
t = int(input())
for i in range(t):
	b = list(map(int, input().split()))
	b.sort()
	k = b[2] - b[1]
	if k - b[0] >= 0:
		print(b[0] + b[1])
	else:
		print(b[0] + b[1] - math.ceil((b[0] - k) / 2))


import math
t = int(input())
for i in range(t):
	(r, g, b) = [int(x) for x in input().split()]
	l = [r, g, b]
	low = min(l)
	high = max(l)
	l.remove(low)
	l.remove(high)
	mid = l[0]
	if mid <= high - low:
		print(min(mid + low, high))
	else:
		d = high - low
		mid -= d
		high += mid // 2
		print(high)


n = int(input())
for cn in range(1, n + 1):
	(a, b, c) = map(int, input().split())
	if a > b:
		tmp = a
		a = b
		b = tmp
	if b > c:
		tmp = b
		b = c
		c = tmp
	if a > b:
		tmp = a
		a = b
		b = tmp
	if a + b >= c:
		print(int((a + b + c) / 2))
	else:
		print(a + b)


for _ in range(int(input())):
	a = sorted(map(int, input().split()))
	if a[0] + a[1] <= a[2]:
		print(a[0] + a[1])
	else:
		k = a[2] - a[1]
		a[0] -= k
		z = a[0] // 2
		a[2] += z
		print(a[2])


for i in range(int(input())):
	a = list(map(int, input().split()))
	a.sort()
	if a[0] + a[1] <= a[2]:
		print(a[0] + a[1])
	elif a[0] + a[1] > a[2]:
		rem = a[0] + a[1] - a[2]
		to_take = rem // 2
		print(a[2] + rem // 2)


for i in range(int(input())):
	x = sorted(list(map(int, input().split())))
	print(min(sum(x) // 2, x[0] + x[1]))


import math
for _ in range(int(input())):
	(a, b, c) = sorted(list(map(int, input().split())))
	cnt = a
	diff = c - b
	c -= min(diff, a)
	if diff < a:
		b -= (a - diff) // 2
		c -= math.ceil((a - diff) / 2)
	cnt += min(b, c)
	print(cnt)


for __ in range(int(input())):
	a = list(map(int, input().split()))
	a.sort()
	count = 0
	if a[2] - a[1] <= a[0]:
		count = a[2] - a[1] + 1
	else:
		count = a[0]
	a[0] -= count
	a[2] -= count
	if a[0] == 0:
		print(count + min(a[1], a[2]))
	elif a[0] % 2 == 0:
		a[1] -= a[0] // 2
		a[2] -= a[0] // 2
		count += a[0] + min(a[1], a[2])
		print(count)
	else:
		a[1] -= a[0] // 2 + 1
		a[2] -= a[0] // 2
		count += a[0] + min(a[1], a[2])
		print(count)


import math
T = int(input())
write = ''
for t in range(T):
	text = list(map(int, input().split(' ')))
	text.sort()
	a = text[2]
	b = text[0]
	c = text[1]
	if a <= b + c:
		sum = a + b + c
		write += str(sum // 2) + '\n'
	else:
		write += str(b + c) + '\n'
print(write)


n = int(input())
a = []
x = 0
for i in range(n):
	y = list(map(int, input().split()))
	y.sort()
	a.append(y)
for el in a:
	x = 0
	if el == [1, 1, 1]:
		x = 1
	elif el == [2, 2, 2]:
		x = 3
	elif el[0] == el[1] == el[2]:
		if el[0] % 2 == 0:
			x = el[0] // 2 * 3
		else:
			x = el[0] // 2 * 3 + 1
	elif el[2] == el[1]:
		if el[0] % 2 == 0:
			x = el[0] // 2 * 3
			x += el[1] - el[0]
		else:
			x = el[0] // 2 * 3 + 1
			x += el[1] - el[0]
	elif el[2] >= el[0] + el[1]:
		x = el[0] + el[1]
	else:
		x = el[2] + (el[0] + el[1] - el[2]) // 2
	print(x)


t = int(input())
for zz in range(t):
	a = [int(i) for i in input().split()]
	a.sort()
	if a[0] == 1 and a[1] == 1:
		print(min(2, a[2]))
	elif a[0] == 1:
		print(1 + min(a[1], a[2] - 1))
	else:
		print(min(sum(a) // 2, a[0] + a[1]))


t = int(input())
for i in range(t):
	(r, g, b) = map(int, input().split())
	m = max((r, g, b))
	if r + g + b - m >= m:
		d = int((r + g + b) / 2)
	else:
		d = r + g + b - m
	print(int(d))


t = int(input())
for i in range(t):
	arr = list(map(int, input().split()))
	arr.sort()
	days = 0
	j = 0
	if arr[2] - arr[1] >= arr[0]:
		arr[1] += arr[0]
		arr[0] = 0
		days = min(arr[0] + arr[1], arr[2])
	else:
		arr[0] -= arr[2] - arr[1]
		arr[1] = arr[2]
		arr[1] += arr[0] // 2
		arr[2] += arr[0] // 2 + arr[0] % 2
		days = min(arr[1], arr[2])
	print(days)


def cal_days(li):
	days = 0
	if li[0] == li[1]:
		val = li[2] // 2
		li[2] = li[2] % 2
		li[0] -= val
		li[1] -= val
		days = 2 * val + li[1]
	elif li[0] - li[1] <= li[2]:
		days = li[0] - li[1]
		li[2] -= days
		li[0] -= days
		days += cal_days(li)
	else:
		days = li[1] + li[2]
	return days
t = int(input())
for _ in range(0, t):
	li = [int(x) for x in input().split(' ')]
	li.sort(reverse=True)
	print(cal_days(li))


t = int(input())
for _ in range(t):
	l = list(map(int, input().split()))
	l.sort()
	a = sum(l)
	l[2] -= a % 2
	a = a - a % 2
	l.sort()
	a -= l[2]
	if l[2] > a:
		print(a)
	else:
		print((a + l[2]) // 2)


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


n = int(input())
while n != 0:
	n -= 1
	a = list(map(int, input().split()))
	a.sort()
	if a[0] + a[1] >= a[2]:
		print(sum(a) // 2)
	else:
		print(a[0] + a[1])


for i in range(int(input())):
	(a, b, c) = sorted([int(j) for j in input().split()])
	s = min(c - b, a)
	(c, a) = (c - s, a - s)
	if a == 0:
		s += min(c, b)
	else:
		s += a // 2 * 2
		s += min(b, c) - a // 2
	print(s)


from sys import stdin

def input():
	return stdin.readline()[:-1]

def intput():
	return int(input())

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

def intsput():
	return map(int, sinput())
t = intput()
for _ in range(t):
	a = list(intsput())
	a.sort()
	diff = a[2] - a[1]
	if diff <= a[0]:
		stack = 0
		stack += diff
		a[2] -= diff
		a[0] -= diff
		stack += a[1] + a[0] // 2
		print(stack)
	else:
		print(a[0] + a[1])


for q in range(int(input())):
	(a, c) = (0, 0)
	l = list(map(int, input().split()))
	l.sort()
	if l[2] <= l[0] + l[1]:
		print(int((l[0] + l[1] + l[2]) / 2))
	else:
		print(int(l[0] + l[1]))


def solve():
	(r, g, b) = map(int, input().split())
	(a, b, c) = sorted([r, g, b])
	if a + b <= c:
		ans = a + b
	else:
		ans = a + b + c
		ans //= 2
	print(ans)
t = int(input())
for i in range(t):
	solve()


def main():
	(r, p, q) = list(map(int, input().split()))
	c = [r, p, q]
	c.sort()
	if c[0] + c[1] <= c[2]:
		print(c[0] + c[1])
	else:
		k = 0
		if (c[0] + c[1] - c[2]) % 2 == 1:
			k = (c[0] + c[1] - c[2]) // 2 + 1
		else:
			k = (c[0] + c[1] - c[2]) // 2
		c[0] -= k
		c[1] -= k
		print(k + c[0] + c[1])
a = int(input())
for i in range(a):
	main()


import math
n = int(input())
for i in range(n):
	colors = sorted([int(x) for x in input().split(' ')])
	if colors[2] <= colors[1] + colors[0]:
		print(int(sum(colors) / 2))
	else:
		print(colors[0] + colors[1])


t = int(input())
for i in range(t):
	arr = list(map(int, input().split()))
	r = arr[0]
	g = arr[1]
	b = arr[2]
	z = min(r, g, b)
	x = sorted(arr)
	if x[0] + x[1] < x[2]:
		print(x[0] + x[1])
	else:
		print(sum(arr) // 2)


from math import floor

def calc_days(cn, cd, cx):
	if cd + cn <= cx:
		return cd + cn
	else:
		diff = cx - cd
		cn = cn - diff
		return diff + floor(cn / 2) + cd
n = int(input())
while n > 0:
	days = 0
	(r, g, b) = map(int, input().split())
	cmin = min(r, g, b)
	if cmin == r:
		cmid = min(g, b)
	if cmin == g:
		cmid = min(r, b)
	if cmin == b:
		cmid = min(g, r)
	cmax = max(r, g, b)
	print(calc_days(cmin, cmid, cmax))
	n = n - 1


t = int(input())
for _ in range(t):
	(a, b, c) = list(map(int, input().split()))
	(a, b, c) = sorted([a, b, c])
	aa = a
	bb = b
	cc = c
	d = c - b
	c -= min(d, a)
	a -= min(a, d)
	b -= min(a // 2, 0)
	a -= min(a // 2, 0)
	c -= min(a, 0)
	a -= min(a, 0)
	(b, c) = sorted([b, c])
	c -= b
	b = 0
	print((aa + bb + cc - c) // 2)


from collections import deque as de
import math
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping
from itertools import groupby as gb

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))
t = int(input())
while t:
	t -= 1
	l = sorted(list(map(int, input().split())), reverse=True)
	if l[0] >= l[1] + l[2]:
		print(l[1] + l[2])
	else:
		print(sum(l) // 2)


number_of_tests = int(input())
for _ in range(number_of_tests):
	a = [int(x) for x in input().split()]
	s = sum(a)
	answer = s - max(a) if max(a) >= s / 2 else int(s / 2)
	print(answer)


for _ in range(int(input())):
	v = sorted(list(map(int, input().split())))
	a = min(v[0], v[2] - v[1])
	print(a + v[1] + (v[0] - a) // 2)


for _ in range(int(input())):
	l = [int(i) for i in input().split()]
	ds = 0
	while sum(l) > 1 and l.count(0) < 2:
		mx = max(l)
		if l.count(mx) == 1:
			mx2 = sum(l) - mx - min(l)
			dx = mx2 - min(l)
			if dx == 0:
				mx2 = min(l)
				dx = min(mx - mx2, mx2)
			l[l.index(mx)] -= dx
			l[l.index(mx2)] -= dx
			ds += dx
		elif l.count(mx) == 2:
			dx = mx - min(l)
			l[l.index(mx)] -= dx
			l[l.index(mx)] -= dx
			ds += dx
		else:
			if l[0] == 1:
				ds += 1
				break
			dx = l[0] // 2
			l[0] -= 2 * dx
			l[1] -= 1 * dx
			l[2] -= 1 * dx
			ds += dx * 2
	print(ds)


T = int(input())
for t in range(T):
	a = list(map(int, input().split()))
	a.sort()
	if a[2] >= a[0] + a[1]:
		print(a[0] + a[1])
	else:
		res1 = a[1] - a[0]
		a[1] -= res1
		a[2] -= res1
		res2 = a[2] - a[1]
		a[0] -= res2
		a[1] -= res2
		a[2] -= res2 * 2
		res2 *= 2
		res3 = sum(a) // 2
		print(res1 + res2 + res3)


def main():

	def solve():
		rgb = [int(a) for a in input().split()]
		rgb.sort()
		if rgb[0] + rgb[1] <= rgb[2]:
			print(rgb[0] + rgb[1])
		else:
			print(rgb[2] + (rgb[0] + rgb[1] - rgb[2]) // 2)
	q = int(input())
	for _ in range(q):
		solve()
main()


import math
t = int(input())
while t > 0:
	t -= 1
	a = input().split()
	a = list(map(int, a))
	a = sorted(a)
	(c, b, a) = list(map(int, a))
	sel = a - b
	a -= min(sel, c)
	ans = min(sel, c)
	c -= min(sel, c)
	c -= c % 2
	a += int(c / 2)
	b += int(c / 2)
	ans += min(a, b)
	print(ans)


for _ in range(int(input())):
	l = []
	(a, b, c) = map(int, input().split())
	l.append(a)
	l.append(b)
	l.append(c)
	l.sort()
	if l[2] >= l[0] + l[1]:
		print(l[0] + l[1])
	else:
		ans = min(l[2], l[0] + l[1])
		print(sum(l) // 2)


t = int(input())
while t > 0:
	arr = [int(i) for i in input().split()]
	arr = sorted(arr)
	m = arr[-1]
	if m > arr[0] + arr[1]:
		print(arr[0] + arr[1])
	elif m < arr[0] + arr[1]:
		print(m + (arr[0] + arr[1] - m) // 2)
	else:
		print(m)
	t -= 1


for _ in range(int(input())):
	s = list(map(int, input().split()))
	s.sort()
	days = s[0]
	diff = s[2] - s[1]
	if diff >= s[0]:
		s[2] -= s[0]
	elif diff > 1:
		s[2] = s[2] - diff
		rem = days - diff
		s[1] = s[1] - int(rem / 2)
		s[2] = s[2] - int(rem / 2) - rem % 2
	else:
		s[1] -= int(s[0] / 2)
		s[2] = s[2] - int(s[0] / 2) - s[0] % 2
	days += min(s[1], s[2])
	print(days)


for _ in range(int(input())):
	l = list(map(int, input().split()))
	l.sort()
	ans = 0
	t = 0
	k = l[2] - l[1]
	if k > l[0]:
		print(l[0] + l[1])
	else:
		p = l[0] - k
		r = p // 2
		if p % 2 == 0:
			ans = ans + l[0] + min(l[1] - r, l[2] - (r + k))
		if p % 2 != 0:
			ans = ans + l[0] + min(l[1] - r, l[2] - (r + k + 1))
		print(ans)


for _ in range(int(input())):
	(r, g, b) = tuple(sorted(map(int, input().split()), reverse=True))
	if r >= g + b:
		res = g + b
	else:
		res = r - g
		b -= r - g
		res += g - b
		res += b // 2 * 3
		res += b % 2
	print(res)


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	candy = [int(item) for item in input().split()]
	candy.sort(reverse=True)
	total = sum(candy)
	if candy[0] <= candy[1] + candy[2]:
		print((total - total % 2) // 2)
	else:
		print((total - (candy[0] - candy[1] - candy[2])) // 2)


t = int(input())
for _ in range(t):
	(r, g, b) = sorted(map(int, input().split()))
	s = sum([r, g, b])
	print(min([r + g, s // 2]))


t = int(input())
for i in range(t):
	aux = []
	contagem = 0
	balas = input().split(' ')
	balas[0] = int(balas[0])
	balas[1] = int(balas[1])
	balas[2] = int(balas[2])
	balas = sorted(balas, reverse=True)
	if balas[0] > balas[1] + balas[2]:
		print(balas[1] + balas[2])
	else:
		print(sum(balas) // 2)


n = int(input())
ans = []
for i in range(n):
	x = input()
	x = [int(i) for i in x.split()]
	temp = max(x)
	y = x.index(temp)
	x.pop(y)
	s = sum(x)
	if s <= temp:
		ans.append(s)
	else:
		ans.append(temp + (s - temp) // 2)
for x in range(len(ans)):
	print(ans[x])


query = int(input())
for _ in range(query):
	arr = [int(i) for i in input().split()]
	arr.sort()
	x = arr[0] + arr[1]
	z = arr[2]
	if x >= z:
		print((x + z) // 2)
	else:
		print(x)


n = int(input())
for i in range(n):
	a = input().split()
	mi = min(int(a[0]), min(int(a[1]), int(a[2])))
	ma = max(int(a[0]), max(int(a[1]), int(a[2])))
	m = int(a[0]) + int(a[1]) + int(a[2]) - mi - ma
	if ma >= mi + m:
		print(mi + m)
	else:
		print(ma + (m + mi - ma) // 2)


from sys import stdin, stdout
LI = lambda : list(map(int, input().split()))
MAP = lambda : map(int, input().split())
IN = lambda : int(input())
S = lambda : input()
import math
from collections import Counter

def solve():
	a = sorted(LI())
	print(min(a[0] + a[1], sum(a) // 2))
for i in range(IN()):
	solve()


n = int(input())
for x in range(n):
	wyn = 0
	a = list(map(int, input().split()))
	a = sorted(a, reverse=True)
	wyn += a[1] - a[2]
	a[0] -= wyn
	a[1] = a[2]
	if a[1] + a[2] <= a[0]:
		wyn += a[1] + a[2]
	else:
		wyn += a[0]
		if a[0] % 2 == 1:
			a[1] -= a[0] // 2 + 1
			a[2] -= a[0] // 2
		else:
			a[1] -= a[0] // 2
			a[2] -= a[0] // 2
		wyn += min(a[1], a[2])
	print(wyn)


from os import path
import sys
from math import ceil, floor, gcd, log
from collections import defaultdict, Counter
maxx = float('inf')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
	I = lambda : int(sys.stdin.buffer.readline())
	tup = lambda : map(int, sys.stdin.buffer.readline().split())
	lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
	S = lambda : sys.stdin.readline().replace('\n', '').strip()
	stpr = lambda x: sys.stdout.write(f'{x}' + '\n')
	star = lambda x: print(' '.join(map(str, x)))
else:
	I = lambda : int(sys.stdin.buffer.readline())
	tup = lambda : map(int, sys.stdin.buffer.readline().split())
	lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
	S = lambda : sys.stdin.readline().replace('\n', '').strip()
	stpr = lambda x: sys.stdout.write(f'{x}' + '\n')
	star = lambda x: print(' '.join(map(str, x)))
for _ in range(I()):
	(a, b, c) = sorted(lint())
	print(min(a + b, (a + b + c) // 2))


from math import ceil
from math import factorial
t = int(input())
while t:
	a = list(map(int, input().split()))
	x = min(a)
	y = sum(a) - min(a) - max(a)
	z = max(a)
	s = sum(a)
	print(min(s // 2, x + y))
	t -= 1


q = int(input())
for _ in range(q):
	a = [int(i) for i in input().split()]
	a = sorted(a)
	res = min(a[2] - a[1], a[0])
	a[0] -= res
	a[2] -= res
	if a[0]:
		res += sum(a) // 2
	else:
		res += min(a[1], a[2])
	print(res)


T = int(input())
for t in range(T):
	(r, g, b) = list(map(int, input().split()))
	(s, m, l) = sorted([r, g, b])
	res = 0
	diff = min(s, l - m)
	s -= diff
	l -= diff
	res += diff
	if s != 0:
		q = s // 2
		res += 2 * q
		m -= q
		l -= q
		s -= 2 * q
	if l == m + 1:
		if s == 1:
			s -= 1
			l -= 1
			res += 1
	res += m
	print(res)


t = int(input())
pall = []
for i in range(t):
	l = []
	(a, b, c) = map(int, input().split())
	l.append(a)
	l.append(b)
	l.append(c)
	l.sort()
	(a, b, c) = (l[0], l[1], l[2])
	if c <= b + a:
		pall.append(c + (b + a - c) // 2)
	else:
		pall.append(b + a)
for k in range(len(pall)):
	print(pall[k])


a = int(input())
m = []
for i in range(a):
	b = list(map(int, input().split()))
	b.sort()
	if b[0] + b[1] <= b[2]:
		m.append(b[0] + b[1])
	else:
		c = b[0] - (b[2] - b[1])
		c = int(c / 2)
		m.append(b[2] + c)
for i in m:
	print(i)


def main():
	t = int(input())
	for _ in range(t):
		(r, g, b) = map(int, input().split())
		l = [r, g, b]
		l = sorted(l)
		if l[2] - l[1] >= l[0]:
			l[2] -= l[0]
			print(l[0] + min(l[1], l[2]))
		else:
			ans = 0
			k = l[2] - l[1]
			l[2] -= k
			l[0] -= k
			ans += k
			if l[0] % 2 == 0:
				l[1] -= l[0] // 2
				l[2] -= l[0] // 2
				ans += l[0] + l[1]
			else:
				l[2] -= l[0] // 2 + 1
				l[1] -= l[0] // 2
				ans += l[0] + min(l[1], l[2])
			print(ans)
main()


t = int(input())
arr = []
for _ in range(t):
	arr.append(list(map(int, input().strip().split())))
for n in range(t):
	arr[n].sort()
	if arr[n][0] + arr[n][1] <= arr[n][2]:
		print(arr[n][0] + arr[n][1])
	else:
		print((arr[n][1] + arr[n][2] + arr[n][0]) // 2)


from collections import deque, Counter
import array
from itertools import combinations, permutations
from math import sqrt, ceil, floor
import unittest

def read_int():
	return int(input().strip())

def read_int_array():
	return [int(i) for i in input().strip().split(' ')]
for test in range(read_int()):
	(a, b, c) = list(sorted(read_int_array()))
	days = a
	d = min(a, ceil((c - b + a) / 2))
	c -= d
	b -= a - d
	days += min(c, b)
	print(days)


from math import ceil

def mod_expo(n, p, m):
	result = 1
	while p != 0:
		if p % 2 == 1:
			result = result * n % m
		p //= 2
		n = n * n % m
	return result

def find_product(n, m, arr):
	product = 1
	if n <= m:
		for i in range(n):
			for j in range(i + 1, n):
				product = product * abs(arr[i] - arr[j]) % m
		return product
	return 0

def count_days(l):
	l.sort()
	if l[2] > l[0] + l[1]:
		return l[0] + l[1]
	return sum(l) // 2
t = 1
t = int(input())
while t:
	t = t - 1
	l = list(map(int, input().strip().split()))[:3]
	print(count_days(l))


def get():
	return map(int, input().split())
t = int(input())
for _ in range(t):
	a = list(get())
	a.sort()
	b = a[0] + a[1]
	c = a[2]
	if c > b:
		print(b)
	else:
		d = c + abs(c - b) // 2
		print(d)


t = int(input())
out = []
for i in range(t):
	rgb = [int(c) for c in input().split()]
	rgb.sort()
	a = rgb.index(max(rgb))
	if a == 0:
		if max(rgb) % 2 == 0:
			out.append(3 * (rgb[0] // 2))
		else:
			out.append(3 * (rgb[0] // 2) + 1)
	elif a == 1:
		out.append(rgb[0] // 2 + rgb[1])
	elif rgb[0] == rgb[1]:
		if rgb[0] <= max(rgb) // 2:
			out.append(2 * rgb[0])
		else:
			out.append(max(rgb) // 2 + rgb[0])
	else:
		b = rgb[0] + rgb[1] - max(rgb)
		if b <= 0:
			out.append(rgb[0] + rgb[1])
		else:
			b = b // 2
			out.append(max(rgb) + b)
for i in range(t):
	print(out[i])


for _ in range(int(input())):
	q = [int(x) for x in input().split()]
	q.sort()
	if q[2] - q[1] >= q[0]:
		print(q[0] + q[1])
	else:
		print(q[0] + (q[1] + q[2] - q[0]) // 2)


t = int(input())
for i in range(t):
	vals = list(map(int, input().strip().split()))
	vals.sort()
	mx = vals[0] + vals[1]
	print(min(mx, (vals[0] + vals[1] + vals[2]) // 2))


import sys
input = sys.stdin.buffer.readline
t = int(input())
while t:
	a = list(map(int, input().split()))
	a.sort()
	r = a[0]
	g = a[1]
	b = a[2]
	day = 0
	dif = b - g
	if dif >= r:
		g -= r
		b -= r
		day += 2 * r
		r = 0
	else:
		g -= dif
		r -= dif
		b -= dif
		day += 2 * dif
	day += g + r // 2
	print(day)
	t -= 1


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	l.sort()
	foo = 0
	while 1 not in l:
		k = l[0] // 2 + l[1] // 2
		l[0] -= l[0] // 2
		l[1] -= l[1] // 2
		l[2] -= k
		foo += k
		l.sort()
	foo += min(l[0] + l[1], l[2])
	print(foo)


q = int(input())
for _ in range(q):
	(r, g, b) = map(int, input().split())
	if g < b:
		(g, b) = (b, g)
	if r < g:
		(r, g) = (g, r)
	if g < b:
		(g, b) = (b, g)
	if (r + g + b) % 2 == 1:
		r -= 1
	if r <= g + b:
		print((r + g + b) // 2)
	else:
		print(g + b)


import math
n = int(input())
for i in range(n):
	candy_list = list(map(int, input().split()))
	days = 0
	candy_list.sort()
	max_candy = max(candy_list)
	min_candy = min(candy_list)
	median_candy = candy_list[1]
	days += min_candy
	diff = max_candy - median_candy
	if diff >= min_candy:
		max_candy -= min_candy
	else:
		if diff != 0:
			max_candy = median_candy
			min_candy -= diff
		max_candy -= math.ceil(min_candy / 2)
		median_candy -= math.floor(min_candy / 2)
	days += min(max_candy, median_candy)
	print(days)


for _ in range(int(input())):
	(r, g, b) = map(int, input().split())
	ll = [r, g, b]
	ll.sort()
	a = ll[0] + ll[1]
	b = ll[-1]
	if b > a:
		print(a)
	else:
		print(b + (a - b) // 2)


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	l.sort()
	if l[2] - l[0] >= l[1]:
		print(l[0] + l[1])
	elif l[2] - l[0] < l[1]:
		x = l[0] - l[2] + l[1]
		y = l[2] - l[1] + x + (l[1] - x // 2) if x % 2 == 0 else l[2] - l[1] + x + (l[1] - (x + 1) // 2)
		print(y)


def f(l):
	c = max(l)
	ab = sum(l) - c
	return ab if ab <= c else sum(l) // 2
q = int(input())
for _ in range(q):
	l = list(map(int, input().split()))
	print(f(l))


from math import ceil
for i in range(int(input())):
	a = sorted(list(map(int, input().split())))
	res = a[0]
	yy = a[2] - a[1]
	if res >= yy:
		res -= yy
		print(a[0] + (a[1] - ceil(res / 2)))
	else:
		print(res + a[1])


t = int(input())
for _ in range(t):
	(x, y, z) = sorted(map(int, input().split()))
	r1 = min(x + y, z)
	r2 = min(x + z, y)
	rr = min(x, z - y)
	x -= min(x, z - y)
	r3 = min(y, z) + rr + x // 2
	print(max(r1, r2, r3))


t = int(input())
while t:
	l = list(map(int, input().split()))
	l.sort()
	if l[2] - l[1] >= l[0]:
		print(l[0] + l[1])
	else:
		d = (l[2] - l[1] + l[0]) // 2
		l[0] = l[0] - d
		if l[2] - d == l[1]:
			print(l[1] + d)
		else:
			print(d + l[0] + min(l[1] - l[0], l[2] - d))
	t -= 1


t = int(input())
for i in range(t):
	l = [int(x) for x in input().split()]
	l.sort()
	ans = min(l[0] + l[1], int(l[0] + l[1] + l[2]) / 2)
	print(int(ans))


n = int(input())
for i in range(n):
	rgb = [int(i) for i in input().split()]
	rgb.sort()
	(p, m, g) = rgb
	if g >= p + m:
		dias = p + m
	else:
		dias = (p + m + g) // 2
	print(dias)


t = int(input())
for tt in range(t):
	(r, g, b) = map(int, input().split())
	arr = [r, g, b]
	arr.sort()
	ss = sum(arr)
	ans = 0
	if arr[2] > arr[0] + arr[1]:
		ans = arr[0] + arr[1]
	else:
		ans = ss // 2
	print(ans)


for tc in range(int(input())):
	a = list(map(int, input().split()))
	a.sort()
	if a[0] + a[1] <= a[2]:
		print(a[0] + a[1])
	else:
		print(sum(a) // 2)


t = int(input())
for i in range(t):
	(r, g, b) = map(int, input().split())
	listCandy = [r, g, b]
	Sum = int(sum(listCandy) / 2)
	Sum = min(Sum, r + g)
	Sum = min(Sum, g + b)
	Sum = min(Sum, r + b)
	print(Sum)


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
t = int(input())
for tt in range(t):
	(r, g, b) = map(int, sys.stdin.readline().split(' '))
	a = [r, g, b]
	a.sort()
	x = a[0]
	y = a[1]
	z = a[2]
	ans = 0
	ans += y - x
	z -= y - x
	y = x
	ans += 2 * min(x, z // 2)
	x -= min(x, z // 2)
	ans += x
	print(ans)
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


for z in range(int(input())):
	(r, g, b) = map(int, input().split())
	ma = max(r, g, b)
	mi = min(r, g, b)
	ans = 0
	if r == ma:
		if r >= g + b:
			ans = g + b
		else:
			ans = r + (g + b - r) // 2
	elif g == ma:
		if g >= r + b:
			ans = r + b
		else:
			ans = g + (r + b - g) // 2
	elif b >= r + g:
		ans = g + r
	else:
		ans = b + (r + g - b) // 2
	print(ans)


T = int(input())
for t in range(T):
	(a, b, c) = sorted(map(int, input().strip().split()))
	d = c - b
	v = a
	if d > a:
		v += min(c - a, b)
	else:
		a -= d
		c -= d + a // 2
		b -= a - a // 2
		v += min(c, b)
	print(v)


t = int(input())
for q in range(0, t):
	a = [int(i) for i in input().split()]
	a.sort()
	print(min(a[0] + a[1], sum(a) // 2))


from sys import stdin
n = int(stdin.readline().strip())
for i in range(n):
	s = list(map(int, stdin.readline().strip().split()))
	s.sort()
	x = s[-1] - s[-2]
	a = min(s[0], x)
	s[-1] -= a
	s[0] -= a
	x = s[1] - s[0]
	s[-1] -= x
	s[-2] -= x
	ans = a + x + s[0] * 3 // 2
	print(ans)


n = int(input())
ls = [list(map(int, input().split())) for i in range(n)]
for i in ls:
	if max(i) > sum(i) - max(i):
		print(sum(i) - max(i))
	else:
		print(sum(i) // 2)


for i in range(int(input())):
	a = sorted([int(i) for i in input().split()])
	print(min(a[0] + a[1], sum(a) // 2))


import sys
import math
from collections import defaultdict, Counter, deque
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	l.sort()
	mi = min(l[0], l[2] - l[1])
	l[0] -= mi
	l[2] -= mi
	ans = mi + l[0]
	l[1] -= l[0] // 2
	l[2] -= (l[0] + 1) // 2
	ans += min(l[1], l[2])
	print(ans)


for _ in range(int(input())):
	(r, g, b) = list(map(int, input().split()))
	soma = r + g + b
	if r >= g and r >= b:
		if soma // 2 > g + b:
			print(g + b)
		else:
			print(soma // 2)
	elif b >= g and b >= r:
		if soma // 2 > g + r:
			print(r + g)
		else:
			print(soma // 2)
	elif g >= r and g >= b:
		if soma // 2 > r + b:
			print(r + b)
		else:
			print(soma // 2)


t = int(input().strip())
for i in range(t):
	(r, g, b) = map(int, input().strip().split())
	cmax = max(r, g, b)
	cmin = min(r, g, b)
	c = [r, g, b]
	c.remove(cmax)
	c.remove(cmin)
	cmed = c[0]
	if cmed + cmin <= cmax:
		print(cmed + cmin)
	else:
		d = cmed - cmin
		result = d
		cmax -= d
		cmed = cmin
		result += (cmax + cmin + cmed) // 2
		print(result)


t = int(input())
for _ in range(t):
	cpt = 0
	a = list(map(int, input().strip().split()))[:3]
	m = max(a)
	s = sum(a)
	if s - 2 * m > 0:
		cpt = m + (s - 2 * m) // 2
	else:
		cpt = s - m
	print(cpt)


for i in range(int(input())):
	a = list(map(int, input().split()))
	a.sort()
	if a[0] == 1:
		a[2] = a[2] - 1
		ans = 1
	elif a[2] - a[0] >= a[1] - 1:
		ans = a[0]
		a[2] = a[2] - a[0]
	else:
		ans = a[0]
		t = a[2] - a[1]
		a[0] = a[0] - t
		a[2] = a[1]
		a[2] = a[2] - a[0] // 2
		a[1] = a[1] - a[0] // 2
		if a[0] % 2 != 0:
			a[2] = a[2] - 1
	x = min(a[1], a[2])
	ans = ans + max(0, x)
	print(ans)


t = int(input())
while t:
	arr = [int(x) for x in input().split()]
	arr.sort()
	if arr[2] <= arr[1] + arr[0]:
		print(sum(arr) // 2)
	else:
		print(arr[0] + arr[1])
	t -= 1


for _ in [0] * int(input()):
	s = list(map(int, input().split()))
	s.sort()
	if s[0] + s[1] <= s[2]:
		print(s[0] + s[1])
	elif s[0] + s[1] - s[2] >= 2:
		print(s[2] + (s[0] + s[1] - s[2]) // 2)
	else:
		print(s[2])


import sys
input = sys.stdin.readline
import math
t = int(input())

def f(a, b, c, ans):
	if c < a:
		if c % 2 != 0:
			c -= 1
		ans += c
		a -= c // 2
		b -= c // 2
		ans += a
	else:
		z = min(a, c // 2)
		ans += 2 * z
		a -= z
		b -= z
		ans += a
	return ans
for i1 in range(t):
	(r, g, b) = list(map(int, input().split(' ')))
	x1 = max(r, g, b)
	ans = 0
	l = [r, g, b]
	l.remove(x1)
	l.sort()
	if sum(l) > x1:
		extra = l[1] - l[0]
		x1 -= extra
		l[1] -= extra
		ans += extra
		z = x1 // 2
		z = min(z, l[0])
		l[0] -= z
		l[1] -= z
		ans += 2 * z
		ans += min(l)
	else:
		ans = min(x1, sum(l))
	print(ans)


def solve(r, g, b):
	(r, g, b) = sorted([r, g, b])
	if r + g <= b:
		return r + g
	return int((r + g + b) / 2)
n = int(input())
for i in range(n):
	(r, g, b) = list(map(lambda x: int(x), input().split(' ')))
	print(solve(r, g, b))


n = int(input())
test = []
for i in range(n):
	test.append(list(map(int, input().split())))
re = []
for cand in test:
	cand.sort()
	if cand[0] + cand[1] <= cand[2]:
		re.append(cand[0] + cand[1])
	else:
		re.append(cand[2] + (cand[0] + cand[1] - cand[2]) // 2)
for i in re:
	print(i)


n = int(input())
for i in range(n):
	a = [int(x) for x in input().split()]
	a.sort(reverse=True)
	(r, g, b) = a
	if r >= g + b:
		print(b + g)
	elif r == g:
		print(r + b // 2)
	elif g == b:
		print(r // 2 + b)
	else:
		print(r + (g + b - r) // 2)


for _ in range(int(input())):
	(a, b, c) = sorted(map(int, input().split()))
	t = 0
	o = min(a, c - b)
	c -= o
	t += o
	a -= o
	if a > b + c:
		print(t + b + c)
	else:
		b -= a // 2
		c -= -(-a // 2)
		t += a
		print(t + min(b, c))


for _ in range(int(input())):
	(a, b, c) = sorted(map(int, input().split()))
	e = min(a, c - b)
	a -= e
	c -= e
	c -= a // 2 + (a & 1)
	b -= a // 2
	print(e + a + min(b, c))


t = int(input())
for T in range(t):
	l = [int(x) for x in input().split()]
	ans = 0
	l.sort()
	mini = l[0]
	l[0] -= min(l[0], l[2] - l[1])
	l[1] += min(mini, l[2] - l[1])
	ans = min(l[1], l[2])
	ans += l[0] // 2
	print(ans)


t = int(input())
while t > 0:
	t -= 1
	(a, b, c) = map(int, input().split())
	cnt = 0
	maxx = max(a, b, c)
	minn = min(a, b, c)
	med = a + b + c - maxx - minn
	a = maxx
	b = med
	c = minn
	if maxx >= minn + med:
		cnt = minn + med
	else:
		cnt = int((a + b + c) / 2)
	print(cnt)


q = int(input())
for i in range(q):
	mas = list(map(int, input().split()))
	mas.sort()
	answer = 0
	if mas[2] > mas[1] + mas[0]:
		answer = mas[0] + mas[1]
	else:
		answer = sum(mas) // 2
	print(answer)


n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	print(min(min(a + b, a + c, b + c), (a + b + c) // 2))


def answer():
	(a, b, c) = sorted(map(int, input().split(' ')))
	ret = a
	cb = c - b
	if cb >= ret:
		c -= a
		ret += min(b, c)
	else:
		a -= cb
		c -= cb
		half_a = a // 2
		if a % 2 == 0:
			a = 0
			b -= half_a
			c -= half_a
			ret += min(b, c)
		else:
			a = 0
			b -= half_a + 1
			c -= half_a
			ret += min(b, c)
	return ret
n = int(input())
for i in range(n):
	ret = answer()
	print(ret)


for _ in range(int(input())):
	a = list(map(int, input().split()))
	a.sort()
	mina = a[0]
	maxa = a[2]
	mid = a[1]
	ans = 0
	num = min(maxa - mid, mina)
	maxa -= num
	mina -= num
	ans += num
	if mina:
		if mina & 1:
			mina -= 1
		ans += mina
		mid -= mina // 2
		maxa -= mina // 2
	ans += min(mid, maxa)
	print(ans)


t = int(input())
for i in range(0, t):
	l = [int(l) for l in input().split()]
	if l[0] == l[1] and l[1] == l[2]:
		print(l[0] + l[0] // 2)
	elif l[0] == l[1]:
		p = l[0] + l[1]
		if p > l[2]:
			print(l[2] + (p - l[2]) // 2)
		else:
			print(p)
	elif l[2] == l[1]:
		p = l[2] + l[1]
		if p > l[0]:
			print(l[0] + (p - l[0]) // 2)
		else:
			print(p)
	elif l[2] == l[0]:
		p = l[2] + l[0]
		if p > l[1]:
			print(l[1] + (p - l[1]) // 2)
		else:
			print(p)
	else:
		l.sort()
		if l[0] + l[1] <= l[2]:
			print(l[0] + l[1])
		else:
			print(l[2] + (l[0] + l[1] - l[2]) // 2)


t = int(input())
for _ in range(t):
	r = [int(i) for i in input().split()]
	r.sort()
	if r[2] > r[0] + r[1]:
		print(r[0] + r[1])
	else:
		print(r[2] + (r[0] + r[1] - r[2]) // 2)


t = int(input())
for test in range(t):
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	if arr[0] > arr[1] + arr[2]:
		print(arr[1] + arr[2])
	else:
		print((arr[0] + arr[1] + arr[2]) // 2)


for _ in range(int(input())):
	(r, g, b) = map(int, input().split())
	a = [r, g, b]
	a.sort(reverse=True)
	ans = 0
	if a[0] >= a[1] + a[2]:
		ans = a[1] + a[2]
	else:
		ans = a[0] + (a[1] + a[2] - a[0]) // 2
	print(ans)


for _ in range(int(input())):
	(r, g, b) = map(int, input().split())
	arr = sorted([r, g, b])
	if arr[2] - arr[0] < arr[1]:
		diff = arr[2] - arr[1]
		arr[0] -= diff
		arr[2] -= arr[0] // 2 + arr[0] % 2 + diff
		arr[1] -= arr[0] // 2
		out = diff + arr[0] + min(arr[1], arr[2])
	else:
		out = arr[0] + min(arr[2] - arr[0], arr[1])
	print(out)


import math
t = int(input())
for i in range(0, t):
	s = 0
	l = []
	l = map(int, input().split())
	l = sorted(l)
	s = s + l[0]
	d = l[2] - l[1]
	if d >= l[0]:
		l[2] = l[2] - l[0]
	else:
		l[2] = l[2] - d
		l[0] = l[0] - d
		l[2] = l[2] - int(math.ceil(l[0] / 2))
		l[1] = l[1] - int(math.floor(l[0] / 2))
	l = l[1:]
	l = sorted(l)
	s = s + l[0]
	print(s)


from functools import reduce
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(n)]
mo = 1000000007
for _ in range(inn()):
	(x, y, z) = sorted(value(), reverse=True)
	if x > y + z:
		print(y + z)
	else:
		print((x + y + z) // 2)


t = int(input())
allCount = []
for i in range(t):
	box = [int(x) for x in input().split()]
	total = sum(box)
	c = max(box)
	box.remove(c)
	if sum(box) >= c:
		count = total // 2
	else:
		count = sum(box)
	allCount.append(count)
for i in allCount:
	print(i)


t = int(input())
while t:
	l = list(map(int, input().split()))
	l.sort()
	(ans1, ans) = (0, 0)
	if l[2] - l[0] >= l[1]:
		ans = l[0] + l[1]
	elif l[2] == l[1]:
		ans += l[0] // 2
		l[1] -= ans
		ans += l[0] - l[0] // 2
		l[2] -= l[0] - l[0] // 2
		ans += min(l[1], l[2])
	else:
		ans += l[2] - l[1]
		l[2] = l[1]
		l[0] -= ans
		l[1] -= l[0] // 2
		ans += l[0] // 2
		l[2] -= l[0] - l[0] // 2
		ans += l[0] - l[0] // 2
		ans += min(l[1], l[2])
	print(ans)
	t -= 1


import sys

def maximal(r, g, b):
	sun = int((r + g + b) / 2)
	sun = min(sun, r + g)
	sun = min(sun, g + b)
	sun = min(sun, b + r)
	return sun
t = int(input())
for _ in range(t):
	rgb = input().split()
	r = int(rgb.pop(0))
	g = int(rgb.pop(0))
	b = int(rgb.pop(0))
	print(maximal(r, g, b))


k = int(input())
for mn in range(0, k):
	(a, b, c) = map(int, input().split())
	d = []
	d.append(a)
	d.append(b)
	d.append(c)
	d.sort()
	j = min(d[0] + d[1], (d[0] + d[1] + d[2]) // 2)
	print(j)


t = int(input())
for _ in range(t):
	a = [int(x) for x in input().split()]
	a.sort()
	r = a[0]
	g = a[1]
	b = a[2]
	if b >= r + g:
		print(r + g)
	else:
		ans = g - r
		g = r
		b -= ans
		ans += int(b / 2)
		r -= int(b / 2)
		b -= int(b / 2)
		ans += b
		g -= b
		ans += min(r, g)
		print(ans)


for i in range(int(input())):
	a = sorted(map(int, input().split()))
	if a[0] + a[1] <= a[2]:
		print(a[0] + a[1])
	else:
		m = a[2] - a[1]
		if m % 2 != a[0] % 2:
			a[0] -= 1
		print(a[1] + m + (a[0] - m) // 2)


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math

def bin1(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = k ** mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin1(mid + 1, r, k, t, b, val, ans)
		else:
			return bin1(l, mid - 1, k, t, b, val, ans)

def bin2(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = t * k ** mid + b * mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin2(l, mid - 1, k, t, b, val, ans)
		else:
			return bin2(mid + 1, r, k, t, b, val, ans)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	l = []
	for i in range(2, n + 1):
		if prime[i]:
			l.append(i)
	return l

def bin(l, r, ll, val):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if val >= ll[mid][0] and val <= ll[mid][1]:
			return mid
		elif val < ll[mid][0]:
			return bin(l, mid - 1, ll, val)
		else:
			return bin(mid + 1, r, ll, val)

def deci(n):
	s = ''
	while n != 0:
		if n % 2 == 0:
			n = n // 2
			s = '0' + s
		else:
			n = n // 2
			s = '1' + s
	return s

def diff(s1, s2):
	if len(s1) < len(s2):
		v = len(s1)
		while v != len(s2):
			s1 = '0' + s1
			v = v + 1
	else:
		v = len(s2)
		while v != len(s1):
			s2 = '0' + s2
			v = v + 1
	c = 0
	for i in range(len(s1)):
		if s1[i:i + 1] != s2[i:i + 1]:
			c = c + 1
	return c
from sys import stdin, stdout

def fac(a, b):
	v = a
	while a != b:
		v *= a - 1
		a = a - 1
	return v

def bino(l, r, n):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		val1 = math.log(n / mid + 1, 2)
		val2 = int(val1)
		if val1 == val2:
			return val1
		elif val1 < 1.0:
			return bino(l, mid - 1, n)
		else:
			return bino(mid + 1, r, n)

def binary(l, r, ll, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		if val % ll[mid] == 0:
			ans = ll[mid]
			return binary(l, mid - 1, ll, val, ans)
		else:
			return binary(l, mid - 1, ll, val, ans)

def odd(n, ans, s):
	if n % 2 != 0 or n in s:
		return ans
	else:
		s.add(n)
		return odd(n // 2, ans + 1, s)
t = int(input())
for i in range(t):
	l = list(map(int, input().split(' ')))
	l.sort()
	a1 = l[0]
	a2 = l[1]
	a3 = l[2]
	if a3 >= a2 + a1:
		print(a2 + a1)
	else:
		val = a3 - a2
		a1 -= val
		a3 += a1 // 2
		print(a3)


for step in range(int(input())):
	A = [int(i) for i in input().split()]
	r = max(A)
	A.remove(r)
	g = max(A)
	A.remove(g)
	b = A[0]
	if r >= g + b:
		print(g + b)
	else:
		num = g - b
		r -= num
		g -= num
		g -= r >> 1
		b -= r >> 1
		num += r - r % 2
		r %= 2
		num += min(g, b)
		if abs(g - b) > 0 and r == 1:
			num += 1
		print(num)


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = int(z())
for _ in range(num):
	(a, b, c) = zz()
	print(min((a + b + c) // 2, a + b, b + c, a + c))


for _ in range(int(input())):
	l = list(map(int, input().split()))
	ans = sum(l) // 2
	l = sorted(l)
	summ = l[0] + l[1]
	print(min(ans, summ))


for _ in range(int(input())):
	(r, g, b) = map(int, input().split())
	c = [r, g, b]
	c.sort(reverse=True)
	ans = c[2]
	c[0] = c[0] - c[2]
	if c[1] > c[0]:
		med = (c[1] - c[0]) // 2
		c[1] = c[1] - med
		c[0] += med
		ans = ans + min(c[1], c[0])
	else:
		ans = ans + c[1]
	print(ans)


t = int(input())
for i in range(t):
	(a, b, c) = list(map(int, input().split()))
	p = [a, b, c]
	p.sort()
	if p[0] + p[1] <= p[2]:
		print(min(p[2], p[1] + p[0]))
	else:
		print(sum(p) // 2)


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	l = [a, b, c]
	l.sort()
	a = l[0]
	b = l[1]
	c = l[2]
	x = c - b
	ans = min(a, x)
	c -= ans
	a -= ans
	if a == 0:
		ans += min(b, c)
	else:
		ans += a
		if a % 2:
			ans += b - 1 - a // 2
		else:
			ans += b - a // 2
	print(ans)


n = int(input())
for _ in range(n):
	l = [int(i) for i in input().split()][:3]
	l.sort()
	mc = 0
	x = l[2] - l[1]
	if x <= l[0]:
		l[0] -= x
		l[2] = l[1]
		mc += x
	else:
		l[2] -= l[0]
		mc += l[0]
		l[0] = 0
	if l[0] % 2 == 1:
		l[1] = l[1] - l[0] // 2
		l[2] = l[2] - l[0] // 2
		l[1] -= 1
		mc += l[0]
	else:
		l[1] = l[1] - l[0] // 2
		l[2] = l[2] - l[0] // 2
		if l[1] < 0:
			l[1] = 0
		if l[2] < 0:
			l[2] = 0
		mc += l[0]
	mc += min(l[1], l[2])
	print(mc)


from math import ceil
for T in range(int(input())):
	(r, g, b) = sorted(list(map(int, input().split())))
	t = b - g
	if t >= r:
		print(r + g)
	else:
		print(r + g - ceil((r - t) / 2))


t = int(input())
answers = []
for ti in range(t):
	s = input()
	candies = list(map(int, s.split()))
	candies.sort()
	r = candies[0]
	g = candies[1]
	b = candies[2]
	if g == b:
		half = r // 2
		half2 = r - half
		g += half2
		b += half
	else:
		d = b - g
		g += min(d, r)
		r -= min(d, r)
		half = r // 2
		half2 = r - half
		g += half2
		b += half
	answers.append(min(b, g))
for a in answers:
	print(a)


tn = int(input())
sa = []
for i in range(tn):
	sa.append([int(i) for i in input().split(' ')])
for i in range(tn):
	t = 0
	sa[i].sort(reverse=True)
	a = sa[i][0]
	b = sa[i][1]
	c = sa[i][2]
	if a - b >= c:
		t = b + c
	else:
		i = c - (a - b)
		if i % 2 == 0:
			t = c + (b - i / 2)
		else:
			t = c + (b - (i + 1) / 2)
	print(int(t))


n = int(input())
for i in range(n):
	arr = sorted(list(map(int, input().split())))
	min_bpc = arr[1] - arr[0]
	max_bpc = arr[0] + arr[1]
	if arr[2] % 2 != max_bpc % 2:
		arr[2] -= 1
	bpc = min(max_bpc, arr[2])
	a = (arr[0] + arr[1] - bpc) // 2
	print(a + bpc)


x = int(input())
for i in range(x):
	r = []
	c = input().split()
	r.append(int(c[0]))
	r.append(int(c[1]))
	r.append(int(c[2]))
	r.sort()
	if r[0] + r[1] <= r[2]:
		print(r[0] + r[1])
	else:
		print(r[2] + int((r[0] + r[1] - r[2]) / 2))


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	(n1, n2, n3) = sorted([a, b, c])
	diff = n3 - n2
	n2 += min(n1, diff)
	n1 -= min(n1, diff)
	n2 += n1 // 2
	n3 += n1 // 2
	print(min(n2, n3))


from sys import stdin, setrecursionlimit
setrecursionlimit(10 ** 6)

def iin():
	return int(stdin.readline())

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

def main():
	t = iin()
	for _ in range(t):
		(a, b, c) = sorted(lin())
		ans = 0
		x = abs(b - c)
		x1 = min(x, a)
		a -= x1
		c -= x1
		ans += x1
		x1 = a // 2
		x2 = a - x1
		b -= x1
		c -= x2
		ans += a
		ans += min(b, c)
		print(ans)
main()


import math
import collections
t = int(input())
for w in range(t):
	(r, g, b) = sorted((int(i) for i in input().split()))
	if r + g <= b:
		print(r + g)
	else:
		k = min(b - g, r)
		r -= k
		b -= k
		if r % 2 == 0:
			print(k + r + (b - r // 2))
		else:
			print(k + r + (b - r // 2 - 1))


t = int(input())
for t in range(t):
	(r, g, b) = [int(x) for x in input().split()]
	if g == max(r, g, b):
		temp = r
		r = g
		g = temp
	elif b == max(r, g, b):
		temp = r
		r = b
		b = temp
	if r >= g + b:
		x = g + b
	else:
		x = (r + g + b) // 2
	print(x)


def solve(a):
	a = sorted(a)
	if a[0] + a[1] < a[2]:
		ans = a[0] + a[1]
	else:
		ans = sum(a) // 2
	return ans
t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	print(solve(a))


t = int(input())
for _ in range(t):
	candies = [int(i) for i in input().split()]
	ans = 0
	candies.sort()
	if candies[2] <= candies[0] + candies[1]:
		ans = sum(candies) // 2
	else:
		ans = candies[0] + candies[1]
	print(ans)


nb_tests = int(input())
for _ in range(nb_tests):
	L = list(map(int, input().split()))
	L.sort()
	(xmin, xmedium, xmax) = L
	if xmax > xmin + xmedium:
		print(xmin + xmedium)
		continue
	else:
		diff = xmax - xmedium
		xmax = xmedium
		xmin -= diff
		tot_day = diff
		if xmin % 2 == 0:
			tot_day += xmin
			xmax -= xmin / 2
			xmedium -= xmin / 2
			tot_day += xmax
			print(int(tot_day))
		else:
			xmin = xmin - 1
			tot_day += xmin
			xmax -= xmin / 2
			xmedium -= xmin / 2
			tot_day += xmax
			print(int(tot_day))


for i in range(int(input())):
	arr = [int(i) for i in input().split()]
	arr.sort()
	mn = arr[0]
	diff = min(arr[2] - arr[1], arr[0])
	x = (arr[0] - diff) // 2
	arr[1] -= x
	arr[2] -= arr[0] - x
	ans = min(arr[1], arr[2]) + mn
	print(ans)


for _ in range(int(input())):
	(c, b, a) = sorted(list(map(int, input().split())))
	ans = 0
	if a >= b + c:
		ans = b + c
	else:
		ans += a - b
		c -= a - b
		a -= a - b
		ans += b - c
		a -= b - c
		b -= b - c
		if a >= 2 and b >= 2 and (c >= 2):
			ans += (a + b + c) // 2
		elif a == b == c == 0:
			ans += 0
		elif a + b + c == 3:
			ans += 1
		else:
			ans += 2
	print(ans)


t = int(input())
for i in range(t):
	line = input().split()
	r = int(line[0])
	g = int(line[1])
	b = int(line[2])
	candies = [r, g, b]
	candies.sort()
	ans = 0
	delta = candies[1] - candies[0]
	ans += delta
	candies[1] -= delta
	candies[2] -= delta
	delta = candies[2] - candies[1]
	ans += 2 * min(candies[0], delta)
	candies[2] -= 2 * delta
	candies[1] -= delta
	candies[0] -= delta
	if candies[0] > 0:
		ans += 3 * candies[0] // 2
	print(ans)


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		a = [int(x) for x in input().split()]
		a.sort()
		if a[2] == a[1]:
			print(a[0] // 2 + a[2])
		elif a[2] > a[1] + a[0]:
			print(a[1] + a[0])
		else:
			print(a[2] + (a[0] - (a[2] - a[1])) // 2)
main()


import sys
from math import log
from math import ceil
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer('\n')
for _ in range(int(input())):
	l = list(map(int, input().split()))
	l.sort()
	diff = l[2] - l[1]
	if diff >= l[0]:
		print(l[0] + l[1])
	else:
		l[2] -= diff
		l[0] -= diff
		l[2] = l[2] - l[0] // 2
		l[1] = l[2]
		print(l[1] + diff + 2 * (l[0] // 2))


t = int(input())
while t != 0:
	a = list(map(int, input().split(' ')))
	a.sort()
	b = a.pop()
	c = a[0] + a[1]
	if b >= c:
		print(c)
	else:
		d = c - b
		e = d // 2
		print(b + e)
	t = t - 1


n = int(input())
ar = []
for i in range(n):
	s = input()
	ar.append(s.split(' '))
arr = []
for i in range(n):
	r = int(ar[i][0])
	g = int(ar[i][1])
	b = int(ar[i][2])
	m1 = max(r, g, b)
	m3 = min(r, g, b)
	m2 = r + g + b - (m1 + m3)
	if m1 == m2 and m2 == m3 and (m3 == m1):
		if m3 % 2 == 0:
			var = int(m3 / 2) * 3
		else:
			var = int((m3 - 1) / 2) * 3 + 1
		print(var)
	elif m1 != m2 and m2 != m3 and (m3 != m1):
		c = 0
		d = m2 - m3
		c = c + d
		m1 = m1 - d
		m2 = m3
		if m1 >= 2 * m3:
			print(d + 2 * m3)
		else:
			c = c + (m1 - m2)
			m3 = m3 - (m1 - m2)
			m1 = m2
			c = c + (m2 - m3)
			m1 = m3
			m2 = m3
			if m3 % 2 == 0:
				var = int(m3 / 2) * 3
			else:
				var = int((m3 - 1) / 2) * 3 + 1
			print(c + var)
	else:
		t = 0
		if m1 == m2:
			if m3 % 2 == 0:
				var = int(m3 / 2) * 3
			else:
				var = int((m3 - 1) / 2) * 3 + 1
			print(m1 - m3 + var)
		elif m1 >= 2 * m3:
			print(2 * m3)
		else:
			t = t + (m1 - m2)
			m3 = m3 - (m1 - m2)
			m1 = m2
			t = t + (m2 - m3)
			m1 = m3
			m2 = m3
			if m3 % 2 == 0:
				var = int(m3 / 2) * 3
			else:
				var = int((m3 - 1) / 2) * 3 + 1
			print(t + var)


n = int(input())
for i in range(n):
	(a, b, c) = sorted(map(int, input().split()))
	if c > a + b:
		print(a + b)
	else:
		print((a + b + c) // 2)


testCount = int(input())
for testNumber in range(0, testCount):
	inp = [int(j) for j in input().split()]
	inp.sort()
	if inp[2] >= inp[0] + inp[1]:
		print(inp[0] + inp[1])
	else:
		print((inp[0] + inp[1] + inp[2]) // 2)


t = int(input())
candies = []
for i in range(t):
	candies = []
	res = 0
	(r, g, b) = map(int, input().split())
	candies.append(r)
	candies.append(g)
	candies.append(b)
	candies.sort()
	if candies[1] == candies[2]:
		res += candies[0] // 2
		res += candies[1]
		print(res)
	else:
		b = min(candies[0], candies[2] - candies[1])
		candies[2] = candies[2] - b
		candies[0] = candies[0] - b
		res += b
		res += candies[0] // 2
		res += candies[1]
		print(res)


a = int(input())
for i in range(a):
	(x, y, z) = map(int, input().split())
	ans = [x, y, z]
	ans.sort()
	total = 0
	total += ans[0]
	if ans[2] - ans[1] >= ans[0]:
		ans[2] -= ans[0]
		print(ans[0] + min(ans[1], ans[2]))
	else:
		k = ans[0]
		ans[0] = ans[0] - (ans[2] - ans[1])
		ans[2] = ans[1]
		m = ans[0] // 2
		ans[1] -= m
		ans[2] -= ans[0] - m
		print(k + min(ans[1], ans[2]))


import math
t = int(input())
for cnt in range(t):
	(r, g, b) = map(int, input().split())
	s = r + g + b
	m = max(r, g, b)
	if 2 * m > s:
		print(s - m)
	else:
		print(s // 2)


t = int(input())
for i in range(t):
	lst = list(map(int, input().strip().split(' ')))
	lst.sort(reverse=True)
	a = lst[0]
	b = lst[1]
	c = lst[2]
	count = 0
	if b > c:
		k = b - c
		a = a - k
		b = b - k
		count += k
	if b == c:
		if a >= b + c:
			count += b + c
		elif a % 2 == 0:
			count += a
			b -= a // 2
			c -= a // 2
			count += b
		elif a % 2 != 0:
			count += a
			b -= a // 2
			c -= a // 2 + 1
			count += min(b, c)
	print(count)


t = int(input())
for i in range(t):
	(a, b, c) = sorted((int(x) for x in input().split()))
	r = min(c - b, a)
	a -= min(c - b, a)
	c -= r
	if a > 0:
		a2 = a // 2
		c -= a2
		b -= a2
		a -= 2 * a2
		r += 2 * a2
	if a:
		b -= a
		r += 1
	r += min(b, c)
	print(r)


import math, sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
lili = lambda : list(map(int, sys.stdin.readlines()))
li = lambda : list(map(int, input().split()))
I = lambda : int(input())
S = lambda : input()
t = I()
for i in range(0, t):
	a = li()
	a.sort()
	(r, g, b) = a
	if r <= b - g:
		print(r + min(g, b - r))
	else:
		ans = b - g
		r -= b - g
		b = g
		r //= 2
		b -= r
		g -= r
		ans += 2 * r + b
		print(ans)


q = int(input())
for i in range(q):
	[r, g, b] = list(map(int, input().rstrip().split()))
	ma = max(r, g, b)
	if r + g + b - ma <= ma:
		print(r + g + b - ma)
	else:
		print((r + g + b) // 2)


import math

def main():
	candies = sorted(list(map(int, input().split())), reverse=True)
	if candies[0] >= candies[1] + candies[2]:
		print(candies[1] + candies[2])
	else:
		ans = 0
		ans += candies[0] - candies[1]
		diff = candies[0] - candies[1]
		candies[0] -= diff
		candies[2] -= diff
		ans += candies[1] - candies[2]
		diff = candies[1] - candies[2]
		candies[0] -= diff
		candies[1] -= diff
		if candies[0] >= 2:
			print(ans + sum(candies) // 2)
		elif candies[0] == 1:
			print(ans + 1)
		else:
			print(ans + 0)
t = int(input())
for _ in range(t):
	main()


t = int(input())
for i in range(t):
	data = list(map(int, input().split()))
	data = sorted(data)
	if data[0] + data[1] <= data[2]:
		print(data[0] + data[1])
	else:
		n = (data[2] - data[1] + data[0]) // 2
		print(data[1] + n)


for j in range(int(input())):
	l = [int(x) for x in input().split()]
	l.sort()
	b = l[2] - l[1]
	if l[0] > b:
		l[0] -= b
		k = l[0] // 2
		f = l[0] - k
		l[2] -= b
		l[2] -= f
		l[1] -= k
		print(min(l[1], l[2]) + l[0] + b)
	else:
		l[2] -= l[0]
		print(l[1] + l[0])


n = int(input())
for i in range(n):
	kt = [int(i) for i in input().split()]
	a = max(kt[0], kt[1], kt[2])
	A = kt[0] + kt[1] + kt[2]
	if 2 * a >= A:
		print(A - a)
	else:
		print(a + (A - 2 * a) // 2)


t = int(input())
for _ in range(t):
	(r, g, b) = map(int, input().split())
	sorted_candies = sorted([r, g, b])
	if sorted_candies[2] >= sorted_candies[0] + sorted_candies[1]:
		days = sorted_candies[0] + sorted_candies[1]
	else:
		days = sum(sorted_candies) // 2
	print(days)


t = int(input())
a = []
for i in range(t):
	a = list(map(int, input().split()))
	a.sort()
	if a[0] == a[1] and a[0] == a[2]:
		ans = int(a[0] * 1.5)
		print(ans)
	else:
		n = a[1] + a[0]
		k = a[2] - n
		if k >= 0:
			ans = n
		else:
			ans = a[2] + abs(k) // 2
		print(ans)


t = int(input())
for _ in range(t):
	(r, g, b) = map(int, input().split())
	count = 0
	l = [r, g, b]
	l.sort(reverse=True)
	diff = l[0] - l[1]
	if diff <= l[2]:
		l[0] -= diff
		l[2] -= diff
		count += diff + l[1] + l[2] // 2
	else:
		l[0] -= l[2]
		count += l[2] + min(l[0], l[1])
	print(count)


import math
T = int(input())
result = ''
for t in range(T):
	text = list(map(int, input().split(' ')))
	text.sort()
	maxim = text[2]
	cent = text[1]
	minim = text[0]
	r = 0
	if maxim > cent + minim:
		result += str(cent + minim) + '\n'
	else:
		d = maxim - cent
		r += d
		minim -= d
		maxim = cent
		if minim < 2:
			result += str(r + maxim) + '\n'
		else:
			d = maxim - minim
			r += d
			maxim = cent = minim
			n = minim // 2
			r += n * 3
			if minim % 2 == 1:
				r += 1
			result += str(r) + '\n'
print(result)


import math
tc = int(input())
for _ in range(tc):
	(r, g, b) = [int(x) for x in input().split()]
	ma = max(r, g, b)
	mn = min(r, g, b)
	md = r + g + b - ma - mn
	t = 0
	if md > mn:
		e = md - mn
		t = t + e
		ma = ma - e
		md = md - e
	if md == mn:
		e = ma - md
		if e > mn:
			t = t + 2 * mn
		else:
			ma = ma - 2 * e
			md = md - e
			mn = mn - e
			t = t + 2 * e
			t = t + 3 * ma // 2
	print(t)


T = int(input())
for t in range(T):
	A = [int(x) for x in input().split()]
	A.sort()
	a = A[0]
	b = A[1]
	c = A[2]
	if c - b >= a:
		b = b
	else:
		b = b - (a + b - c + 1) // 2
	print(a + b)


t = int(input())
while t:
	t -= 1
	r = list(map(int, input().split()))
	r.sort()
	d = 0
	re = r[2] - r[1]
	if re >= r[0]:
		d += r[0]
		r[2] -= r[0]
		d += min(r[1], r[2])
		print(d)
		continue
	d += re
	r[2] -= re
	r[0] -= re
	r[2] -= r[0] - r[0] // 2
	r[1] -= r[0] // 2
	d += r[0] - r[0] // 2 + r[0] // 2
	d += min(r[1], r[2])
	print(d)


import math

def solve(A):
	A.sort()
	ans = 0
	while A[0] > 0:
		if A[0] + A[1] <= A[2]:
			d = A[0]
			A[0] -= d
			A[2] -= d
			ans += d
			A.sort()
		elif A[1] < A[2]:
			d = min(A[0], A[2] - A[1])
			A[2] -= d
			A[0] -= d
			ans += d
			A.sort()
		else:
			d = (A[0] + 1) // 2
			A[2] -= d
			A[0] -= d
			ans += d
			A.sort()
	if A[1] > 0:
		ans += A[1]
		A[2] -= A[1]
		A[1] = 0
	return ans

def main():
	cas = int(input())
	while cas > 0:
		cas -= 1
		A = list(map(int, input().split()))
		ans = solve(A)
		print(ans)
main()


n = int(input())
for i in range(n):
	count = 0
	(r, g, b) = map(int, input().split())
	l = [r, g, b]
	l.sort()
	count += l[0]
	m = min(l[0], l[2] - l[1])
	l[2] -= m
	if (l[0] - m) % 2 == 0:
		l[1] -= (l[0] - m) // 2
		l[2] -= (l[0] - m) // 2
	else:
		l[1] -= (l[0] - m) // 2
		l[2] -= (l[0] - m) // 2 + 1
	count += min(l[1], l[2])
	print(count)


t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	a.sort()
	b = sum(a) // 2
	print(min(b, a[0] + a[1]))


t = int(input())
i = 0
m = [0] * t
for i in range(t):
	a = [0] * 3
	a = list(map(int, input().split()))
	a = sorted(a)
	if a[0] + a[1] <= a[2]:
		m[i] = a[0] + a[1]
	else:
		m[i] = (sum(a) - sum(a) % 2) / 2
i = 0
for i in range(t):
	print(int(m[i]))


for _ in range(int(input())):
	(r, g, b) = map(int, input().split())
	total = r + g + b
	mx = max(r, g, b)
	if mx - (total - mx) > 1:
		print(' ', total - mx)
		continue
	print(' ', total // 2)


class Solution(object):

	def sweet_problem(self, r: int, g: int, b: int) -> int:
		(b, g, r) = sorted((r, g, b))
		if r < g + b:
			return (r + g + b) // 2
		else:
			return g + b
tc = int(input())
for i in range(tc):
	print(Solution().sweet_problem(*[int(x) for x in input().split()]))


t = int(input())
for _ in range(t):
	candies = [int(s) for s in input().split()]
	candies.sort()
	ans = candies[0]
	first = min(candies[2] - candies[1], candies[0])
	candies[2] -= first
	candies[0] -= first
	candies[1] -= candies[0] // 2
	candies[2] -= candies[0] // 2
	candies[2] -= 1 if candies[0] % 2 == 1 else 0
	ans += min(candies[1], candies[2])
	print(ans)


tcs = int(input())
import math
for tc in range(tcs):
	rgb_ = [int(x) for x in input().split()]
	rgb = {'r': rgb_[0], 'g': rgb_[1], 'b': rgb_[2]}
	num = 0
	while True:
		mx = -1
		mx_k = None
		mx_w = -1
		mx_k = None
		for (k, v) in rgb.items():
			if v > mx:
				mx = v
				mx_k = k
		mx = -1
		second_k = None
		for (k, v) in rgb.items():
			if v >= mx and k != mx_k:
				mx = v
				second_k = k
		third_k = None
		for k in rgb:
			if k != mx_k and k != second_k:
				third_k = k
		diff = rgb[second_k] - rgb[third_k]
		if diff > 0:
			rgb[mx_k] = rgb[mx_k] - diff
			rgb[second_k] = rgb[second_k] - diff
			num += diff
		else:
			mi = min(rgb[mx_k], rgb[second_k] * 2)
			rgb[mx_k] = rgb[mx_k] - mi
			rgb[second_k] = rgb[second_k] - math.ceil(mi / 2)
			rgb[third_k] = rgb[third_k] - math.ceil(mi / 2)
			num += mi
		if rgb['r'] == 0 and rgb['g'] == 0 or (rgb['r'] == 0 and rgb['b'] == 0) or (rgb['g'] == 0 and rgb['b'] == 0):
			break
	print(num)


t = int(input())
while t:
	t -= 1
	l = list(map(int, input().rstrip().split(' ')))
	l.sort()
	if l[1] + l[0] <= l[2]:
		print(l[1] + l[0])
	elif l[1] == l[2]:
		print(l[1] + l[0] // 2)
	else:
		print(l[2] + (l[1] + l[0] - l[2]) // 2)


for _ in range(int(input())):
	l = list(map(int, input().strip().split()))
	l.sort()
	diff = l[2] - l[1]
	sum = 0
	if diff >= l[0]:
		sum = sum + l[0]
		l[2] = l[2] - l[0]
		sum = sum + min(l[1], l[2])
	else:
		l[2] = l[2] - diff
		l[0] = l[0] - diff
		sum = sum + diff
		if l[0] % 2 == 0:
			l[1] = l[1] - l[0] // 2
			l[2] = l[2] - l[0] // 2
			sum = sum + l[0]
			sum = sum + min(l[1], l[2])
		else:
			l[2] = l[2] - l[0] // 2 - 1
			l[1] = l[1] - l[0] // 2
			sum = sum + l[0]
			sum = sum + min(l[1], l[2])
	print(sum)


mod = 10 ** 9 + 7
INF = float('inf')

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

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

def I():
	return int(input())
q = I()
from itertools import combinations
for _ in range(q):
	A = sorted(readInts(), reverse=True)
	ma = -1
	a = A[0]
	b = A[1]
	c = A[2]
	MAX = max(a, b)
	MIN = min(a, b)
	need = MAX - MIN
	nya = min(c, need)
	MIN += nya
	c -= nya
	divc = c // 2
	MIN += divc
	MAX += c - divc
	ma = max(ma, min(MAX, MIN))
	print(ma)


for i in range(int(input())):
	l = [int(x) for x in input().split()]
	l.sort()
	print(min(l[0] + l[1], sum(l) // 2))


n = int(input())
for i in range(n):
	s = list(map(int, input().split()))
	s.sort()
	if s[0] + s[1] <= s[2]:
		print(s[0] + s[1])
	else:
		res = (s[2] + s[1] - s[0]) // 2
		print(res + s[0])


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	ma = max(l)
	l.remove(ma)
	ma2 = max(l)
	l.remove(ma2)
	b = ma - ma2
	ans = 0
	if b > l[0]:
		ma = ma - l[0]
		ans += l[0]
		l[0] = 0
	else:
		l[0] = l[0] - b
		ma = ma - b
		ans += b
	b = ma - ma2
	if b == 0:
		if l[0] % 2 == 1:
			if b == 0:
				ans += l[0] // 2
				ma = ma - l[0] // 2
				ans = ans + l[0] // 2 + 1
				ma2 = ma2 - l[0] // 2 - 1
				ans += min(ma2, ma)
		elif b == 0:
			ans += l[0] // 2
			ma = ma - l[0] // 2
			ans = ans + l[0] // 2
			ma2 = ma2 - l[0] // 2
			ans += min(ma2, ma)
		print(ans)
	else:
		ans += min(ma, ma2)
		print(ans)


q = int(input())
for i in range(q):
	r = [int(x) for x in input().split()]
	print(min(int(sum(r) / 2), sum(r) - max(r)))


for _ in range(int(input())):
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	(a, b, c) = l
	if a > b + c:
		print(b + c)
	else:
		print((b + c - a) // 2 + a)


t = int(input())
for case in range(t):
	arr = list(map(int, input().split()))
	arr.sort()
	d = arr[2] - arr[1]
	if d >= arr[0]:
		print(arr[0] + arr[1])
	else:
		arr[0] -= d
		if arr[0] & 1:
			print(d + arr[1] + arr[0] - (arr[0] >> 1) - 1)
		else:
			print(d + arr[1] + arr[0] - (arr[0] >> 1))


t = int(input())
d = []
for i in range(0, t):
	b = input().split(' ')
	c = [int(x) for x in b]
	c.sort()
	if c[0] + c[1] >= c[2]:
		d.append(int((c[0] + c[1] + c[2]) / 2))
	else:
		d.append(c[0] + c[1])
for i in d:
	print(i)


import sys, math, itertools
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))
for _ in range(inp()):
	a = inpl()
	a.sort()
	if a[0] + a[1] <= a[2]:
		print(a[0] + a[1])
	else:
		res = a[0]
		a[0] -= a[2] - a[1]
		res += a[1] - (a[0] + 1) // 2
		print(res)


arr = []
test_cases = int(input(''))
for x in range(test_cases):
	a = []
	a = list(map(int, input().split()))
	arr.append(a)
for y in range(test_cases):
	r = arr[y][0]
	g = arr[y][1]
	b = arr[y][2]
	q = min(r, g, b)
	p = max(r, g, b)
	m = r + g + b - p - q
	if p + q - m > 0 and m + q >= p:
		x = int((p + q - m) / 2 + 0.5)
		print(q + p - x)
	else:
		print(min(max(r, g, b), r + g + b - max(r, g, b)))


n = int(input())
for i in range(n):
	c = [int(x) for x in input().split()]
	c.sort(reverse=True)
	days = 0
	difference = c[0] - c[1]
	if difference > c[2]:
		days += c[2] + c[1]
		print(days)
		days = 0
	else:
		days += difference
		c[0] -= difference
		c[2] -= difference
		di = c[2] // 2
		days += di * 2
		c[0] -= di
		c[1] -= di
		days += c[0]
		print(days)
		days = 0


def f():
	(r, g, b) = [int(s) for s in input().split()]
	r1 = g + b - r
	r2 = r + b - g
	r3 = r + g - b
	if r1 <= 0:
		return g + b
	if r2 <= 0:
		return r + b
	if r3 <= 0:
		return r + g
	check = r % 2 + b % 2 + g % 2
	if check == 0 or check == 2:
		return (r + g + b) // 2
	else:
		return (r + g + b - 1) // 2
t = int(input())
for i in range(t):
	print(f())


from sys import stdin

def rl():
	return [int(w) for w in stdin.readline().split()]
(t,) = rl()
for _ in range(t):
	a = []
	a = rl()
	a.sort()
	if a[0] + a[1] <= a[2]:
		ans = a[0] + a[1]
	else:
		ans = (a[0] + a[1] + a[2]) // 2
	print(ans)


n = int(input())
for y in range(n):
	cont = 0
	doce = list(map(int, input().split()))
	menor = min(doce)
	menorPos = doce.index(menor)
	del doce[menorPos]
	difMenor = max(doce) - min(doce)
	if difMenor <= menor:
		menor -= difMenor
		cont += difMenor
		doce[doce.index(max(doce))] -= difMenor
		if menor % 2 != 0:
			menor -= 1
			cont += 1
			doce[doce.index(max(doce))] -= 1
		if menor != 0:
			doce[doce.index(min(doce))] -= menor / 2
			doce[doce.index(max(doce))] -= menor / 2
			cont += menor
		cont += min(doce)
	else:
		cont += menor
		doce[doce.index(max(doce))] -= menor
		cont += min(doce)
	print(int(cont))


n = int(input())
for i in ' ' * n:
	(*l,) = sorted(map(int, input().split()))
	t = max(l[1], l[2] - l[0])
	c = l[2] - t
	l[0] -= l[2] - t
	l[2] -= l[2] - t
	if l[0] > 0:
		k = l[0] // 2
		l[1] -= k
		l[2] -= k
		c += k * 2
		if l[0] % 2 != 0:
			l[0] = 0
			l[2] -= 1
			c += 1
	c += min(l[1], l[2])
	print(c)


def arr_inp():
	return [int(x) for x in input().split()]
from math import *
for i in range(int(input())):
	arr = arr_inp()
	arr.sort()
	ans = 0
	if sum(arr[:2]) <= arr[2]:
		print(sum(arr[:2]))
	else:
		ans = arr[2] + (arr[0] - (arr[2] - arr[1])) // 2
		print(ans)


for i in range(int(input())):
	candy = sorted([int(j) for j in input().split()])
	a = candy[0]
	b = candy[0]
	c = candy[2] - (candy[1] - candy[0])
	print(candy[1] - candy[0] + int(b - (c - 1) / 2) + c - c % 2 if a + b > c else candy[1] - candy[0] + a + b)


from sys import stdin, stdout
import math
input = stdin.readline

def print(x='', end='\n'):
	stdout.write(str(x) + end)

def solve():
	l = list(map(int, input().split()))
	l.sort()
	(r, g, b) = l
	if b >= r + g:
		print(r + g)
	else:
		print((r + g + b) // 2)
test = 1
test = int(input())
for __ in range(test):
	solve()


t = int(input())
for i in range(0, t):
	r = list(map(int, input().split()))
	r.sort()
	k = r[2]
	r[2] = 0
	g = sum(r)
	if g > k:
		print((g + k) // 2)
	elif g == k:
		print(g)
	else:
		print(g)


n = int(input())
for i in range(n):
	a = list(map(int, input().split()))
	a = sorted(a)
	rmin = min(a[0], a[2] - a[1])
	s = rmin
	a[2] -= rmin
	a[0] -= rmin
	a[1] -= a[0] // 2
	a[2] -= a[0] // 2
	s += a[0] - a[0] % 2
	a[0] = a[0] % 2
	rmin = min(a[1], a[2])
	s += rmin
	a[1] -= rmin
	a[2] -= rmin
	s += min(a[0], a[2])
	print(s)


from collections import Counter
from collections import defaultdict
import math
t = int(input())
for _ in range(0, t):
	l = list(map(int, input().split()))
	l.sort()
	a = l[2]
	b = l[1]
	c = l[0]
	if a >= b + c:
		print(b + c)
		continue
	else:
		q = a - b
		if q <= c:
			c = c - q
			ans = math.ceil(c / 2)
			b = b - ans
			print(b + c + q)
		else:
			print(b)


for _ in range(int(input())):
	arr = [int(i) for i in input().split()]
	arr.sort()
	(x, y, z) = arr
	if z <= x + y:
		print((x + y + z) // 2)
	else:
		print(x + y)


for _ in range(int(input())):
	(r, g, b) = map(int, input().split())
	a = list(sorted([r, g, b]))
	if a[2] - (a[0] + a[1]) == 0:
		print((r + g + b) // 2)
	elif a[2] - (a[0] + a[1]) > 0:
		print(a[0] + a[1])
	elif a[0] == 1:
		print((sum(a) - abs(a[2] - (a[0] + a[1]))) // 2)
	else:
		print((r + g + b) // 2)


t = int(input())
for _ in range(t):
	(r, g, b) = map(int, input().split())
	a = [r, g, b]
	a.sort()
	max1 = a[2]
	max2 = a[0] + a[1]
	if max1 >= max2:
		print(max2)
	else:
		print(max1 + (max2 - max1) // 2)


read = lambda : [int(i) for i in input().split()]
n = int(input())
for _ in range(n):
	(r, g, b) = sorted(read())
	diff = b - g
	if r > diff:
		g += diff
		r -= diff
		g += r // 2
		b += r - r // 2
		print(min(g, b))
	else:
		print(min(r + g, b))


for i in range(int(input())):
	c = sorted(list(map(int, input().split())))
	if c[2] >= c[0] + c[1]:
		x = c[0] + c[1]
	else:
		x = int(sum(c) / 2)
	print(str(x))


s = int(input())
for i in range(s):
	(a, b, c) = list(map(int, input().split()))
	m = min(a, b, c)
	x = max(a, b, c)
	av = a + b + c - m - x
	final = 0
	if m <= x - av:
		x -= m
		print(m + min(av, x))
	else:
		final = m
		ag = x - av
		x -= ag
		m -= ag
		if m % 2 == 0:
			x -= m // 2
			av -= m // 2
			final += min(x, av)
		else:
			x -= m // 2 + 1
			av -= m // 2
			final += min(x, av)
		print(final)


import math
t = int(input())
for i in range(t):
	rgb = list(map(int, input().split()))
	rgb.sort()
	if rgb[1] == rgb[2]:
		print((rgb[0] + rgb[1] + rgb[2]) // 2)
	elif rgb[0] + rgb[1] <= rgb[2]:
		print(rgb[0] + rgb[1])
	else:
		print((rgb[2] + rgb[0] + rgb[1]) // 2)


test_cases = int(input())
for i in range(test_cases):
	(r, g, b) = map(int, input().split(' '))
	total = r + g + b
	if total // 2 <= total - max(r, g, b):
		print(total // 2)
	else:
		print(total - max(r, g, b))


t = int(input())
ans = []
for _ in range(t):
	arr = sorted(map(int, input().split()))
	if arr[-1] > arr[0] + arr[1]:
		ans.append(arr[0] + arr[1])
	else:
		ans.append(sum(arr) // 2)
for a in ans:
	print(a)


import math
t = int(input())
for i in range(1, t + 1):
	a = [None] * 3
	(a[0], a[1], a[2]) = [int(s) for s in input().split(' ')]
	a.sort()
	if a[0] + a[1] <= a[2]:
		print(a[0] + a[1])
	else:
		print(math.floor((a[0] + a[1] - a[2]) / 2) + a[2])


n = int(input())
for i in range(n):
	days = 0
	(r, g, b) = map(int, input().split())
	v = [r, g, b]
	m = max(v)
	v.remove(m)
	if sum(v) <= m:
		print(sum(v))
	else:
		print(m + (sum(v) - m) // 2)


import math
t = int(input())
while t:
	t -= 1
	l = list(map(int, input().split()))
	l.sort()
	if l[2] <= l[0] + l[1]:
		print((l[2] + l[0] + l[1]) // 2)
	else:
		print(l[0] + l[1])


from math import floor, ceil
for _ in range(int(input())):
	(a, b, c) = sorted(map(int, input().split()))
	r = 0
	if a - 1 <= c - b:
		r += a
		c -= a
	else:
		r += a
		a -= c - b
		c -= c - b
		c -= ceil(a / 2)
		b -= a // 2
	r += min(b, c)
	print(int(r))


import math
t = int(input())
for i in range(t):
	(r, g, b) = map(int, input().split())
	l1 = []
	l1.append(r)
	l1.append(g)
	l1.append(b)
	l1.sort(reverse=True)
	ans = l1[1] - l1[2]
	l1[1] = l1[2]
	l1[0] -= ans
	x = l1[0] // 2
	if x > l1[1]:
		ans += l1[1] * 2
	else:
		ans += x * 2 + l1[1] - x
	print(ans)


n = int(input())
for _ in range(n):
	(a, b, c) = list(map(int, input().split()))
	if a > b + c:
		ans = b + c
	elif b > a + c:
		ans = a + c
	elif c > a + b:
		ans = a + b
	else:
		ans = (a + b + c) // 2
	print(ans)


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from math import sqrt, pi, ceil, log, inf, gcd, floor
from itertools import combinations, permutations
from bisect import *
from fractions import Fraction
from heapq import *
from random import randint

def main():
	for t in range(int(input())):
		a = sorted(map(int, input().split()))
		if a[0] + a[1] <= a[2]:
			print(a[0] + a[1])
		else:
			print(sum(a) // 2)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for z in range(t):
	arr = sorted(list(map(int, input().split())))
	ans = sum(arr) // 2
	if arr[0] + arr[1] < ans:
		ans = arr[0] + arr[1]
	print(ans)


import math
for _ in range(int(input())):
	l = list(map(int, input().split()))
	l.sort()
	if l[0] + l[1] <= l[2]:
		print(l[0] + l[1])
	else:
		t = abs(l[1] + l[0] - l[2])
		print(min(l[1] + l[0], l[2]) + t // 2)


tcs = int(input())
for _ in range(tcs):
	can = list(map(int, input().split()))
	can.sort()
	res = 0
	div2 = can[0] // 2
	diff = can[2] - can[1]
	if diff > can[0]:
		can[2] -= can[0]
		res += can[0]
		can[0] = 0
		res += can[1]
	else:
		div2 = (can[2] + can[1] - can[0]) // 2
		can[2] = can[2] + can[1] - can[0] - div2
		can[1] = div2
		res += can[0]
		res += can[1]
	print(res)


t = int(input())
for _ in range(t):
	a = sorted(list(map(int, input().split())))
	res = max(min(a[0] + a[1], a[2]), min(a[0], a[2] - a[1]) + a[1] + (a[0] - min(a[0], a[2] - a[1])) // 2, a[1] + a[0] // 2)
	print(res)


from collections import *
from functools import reduce
import sys
input = sys.stdin.readline

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def li():
	return [int(i) for i in input().rstrip('\n').split(' ')]

def st():
	return input().rstrip('\n')

def val():
	return int(input())
for i in range(val()):
	(a, b, c) = sorted(li())
	a1 = a // 2 + (a - a // 2) + min(b - a // 2, c - (a - a // 2))
	a2 = min(a + b, c)
	a3 = (c if c <= a + b else 0) + (a + b - c) // 2
	print(max(a1, a2, a3))


for z in range(int(input())):
	l = list(map(int, input().split()))
	l.sort()
	a = l[0]
	b = l[1]
	c = l[2]
	if a + b <= c:
		print(a + b)
		continue
	print((a + b + c) // 2)


import math
n = int(input())
for i in range(n):
	a = [int(i) for i in input().split()]
	a.sort()
	if sum(a) - a[2] > a[2]:
		print(math.floor(sum(a) / 2))
	else:
		print(sum(a) - a[2])


for _ in range(int(input())):
	l = sorted(map(int, input().split()))
	print(min(sum(l) // 2, l[0] + l[1]))


t = int(input())
for _ in range(t):
	pls = list(map(int, input().split(' ')))
	pls = sorted(pls)
	df = pls[2] - pls[1]
	if df > pls[0]:
		print(pls[0] + pls[1])
		continue
	cnt = df
	pls[0] -= df
	pls[2] -= df
	ls = pls[0] // 2
	orm = pls[0] % 2
	cnt += pls[0]
	pls[1] -= ls
	pls[2] -= ls + orm
	pls[0] = 0
	print(cnt + min(pls[1], pls[2]))


t = int(input())
for i in range(t):
	ar = [int(x) for x in input().split()]
	ar.sort()
	count = 0
	if ar[2] - ar[1] >= ar[0]:
		count = ar[0] + ar[1]
	elif ar[0] == 1 and ar[1] == 1 and (ar[2] == 1):
		count = 1
	else:
		count = ar[2] - ar[1]
		ar[2] = ar[1]
		ar[0] = ar[0] - count
		div = ar[0] // 2
		dif = ar[0] - div
		ar[1] = ar[1] - dif
		count += ar[0] + ar[1]
	print(count)


import sys
import math
t = int(sys.stdin.readline())
while t:
	(r, g, b) = map(int, sys.stdin.readline().split())
	minn = min(r, g, b)
	a = sorted([r, g, b])
	if a[2] >= a[0] + a[1]:
		print(a[0] + a[1])
	else:
		print((a[0] + a[1] + a[2]) // 2)
	t -= 1


def main():
	for _ in range(int(input())):
		c = list(map(int, input().split()))
		c.sort()
		d = 0
		x = c[0]
		c[2] -= c[0]
		c[0] = 0
		if c[2] < c[1]:
			c[0] = c[1] - c[2]
			c[2] = c[1]
		d += x - c[0]
		if c[2] != c[1]:
			print(d + c[1])
		else:
			print(d + c[2] + c[0] // 2)
main()


n = int(input())
for i in range(0, n):
	ln = [int(j) for j in input().split(' ')]
	ln = sorted(ln)
	ans = min(sum(ln) // 2, ln[0] + ln[1])
	print(ans)


for _ in range(int(input())):
	r = list(map(int, input().split()))
	print(min(int(sum(r) / 2), sum(r) - max(r)))


number_of_tests = int(input())
for _ in range(number_of_tests):
	a = [int(x) for x in input().split()]
	a.sort(reverse=True)
	if a[0] >= a[1] + a[2]:
		print(min(a[0], a[2]) + min(a[0] - a[2], a[1]))
	else:
		print(int(sum(a) / 2))


for _ in range(int(input())):
	(r, g, b) = list(map(int, input().split()))
	x = [r, g, b]
	x.sort()
	d = x[2] - x[1]
	if x[1] + x[0] <= x[2]:
		print(x[1] + x[0])
	else:
		y = x[0] - (x[2] - x[1])
		x[1] += x[2] - x[1]
		x[1] += y // 2
		x[2] += y // 2
		if y % 2 == 1:
			x[1] += 1
		print(min(x[1], x[2]))


for _ in range(int(input().strip())):
	arr = [int(x) for x in input().strip().split()]
	arr.sort()
	(a, b, c) = arr
	diff = c - b
	if diff == a:
		print((a + b + c) // 2)
	elif diff > a:
		print(a + b)
	else:
		diff = abs(a + b - c)
		ans = min(a + b, c)
		if diff > 1:
			ans += diff // 2
		print(ans)


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	l.sort()
	if l[2] > l[1] + l[0]:
		print(l[0] + l[1])
		continue
	a = l[2] - l[1]
	if l[0] >= a:
		print(a + l[1] + (l[0] - a) // 2)
	else:
		print(l[2])


import math
for i in range(int(input())):
	x = list(map(int, input().split()))
	x = sorted(x)
	if x[0] + x[1] >= x[2]:
		print(math.floor(sum(x) / 2))
	else:
		print(x[0] + x[1])


t = int(input())
while t > 0:
	t -= 1
	(r, g, b) = map(int, input().strip().split())
	l = r + g + b
	count = max(r, g, b)
	b = min(r, g, b)
	r = count
	g = l - r - b
	count = 0
	if r >= g + b:
		count += g + b
	else:
		count += (r + g + b) // 2
	print(count)


for _ in range(int(input())):
	a = list(map(int, input().split()))
	a = sorted(a)
	count = 0
	diff = a[2] - a[1]
	if a[0] >= diff:
		count += diff
		a[2] -= diff
		a[0] -= diff
		aa = a[0] // 2
		count += a[2] + aa
	else:
		count += a[0]
		a[2] -= diff
		count += min(a[1], a[2])
	print(count)


import math
t = int(input())
while t > 0:
	rgb = [int(s) for s in input().split()]
	rgb.sort(reverse=True)
	aux = rgb[0] - rgb[2]
	if aux >= rgb[1]:
		rgb[0] -= rgb[2]
		total = rgb[2]
		rgb[2] = 0
	else:
		aux = rgb[0] - rgb[1]
		total = aux
		rgb[2] -= aux
		rgb[0] -= aux
	total += rgb[2]
	rgb[1] -= math.floor(rgb[2] / 2)
	rgb[0] -= math.ceil(rgb[2] / 2)
	rgb[2] = 0
	rgb.sort(reverse=True)
	total += rgb[1]
	print(total)
	t -= 1


import sys
for _ in range(int(input())):
	(a, b, c) = sorted(list(map(int, input().split())))
	print((a + b + c - max(0, c - (a + b))) // 2)


test_cases = int(input())
for each_test_case in range(test_cases):
	(r, g, b) = map(int, input().split())
	min_b = min(b, r + g)
	min_g = min(g, b + r)
	min_r = min(r, g + b)
	print((min_b + min_g + min_r) // 2)


for i in range(int(input())):
	(r, g, b) = [int(x) for x in input().split()]
	l = [r, g, b]
	l.sort()
	if l[0] < l[2] - l[1]:
		print(l[1] + l[0])
	else:
		t = l[0] - l[2] + l[1]
		if t % 2 == 0:
			print(l[0] + l[1] - t // 2)
		else:
			print(l[0] + l[1] - t // 2 - 1)


t = int(input())
for _ in range(t):
	(a, b, c) = list(map(int, input().split()))
	(a, b, c) = sorted([a, b, c])
	if c >= a + b:
		print(a + b)
	else:
		e = (a + b - c) // 2
		print(c + e)


def main():
	t = int(input())
	for _ in range(t):
		(r, g, b) = list(map(int, input().split()))
		c_max = max([r, g, b])
		if c_max >= sum([r, g, b]) - c_max:
			print(sum([r, g, b]) - c_max)
			continue
		rv = c_max
		overflow = (sum([r, g, b]) - 2 * c_max) // 2
		if overflow > min([r, g, b]):
			overflow = min([r, g, b])
		rv += overflow
		print(rv)
main()


for _ in range(int(input())):
	l = list(map(int, input().split()))
	l = sorted(l)
	(a, b, c) = (l[0], l[1], l[2])
	diff = c - b
	if diff <= a:
		a = a - diff
		print(b + diff + a // 2)
	else:
		print(b + a)


q = int(input())
for re in range(q):
	l = list(map(int, input().split()))
	l.sort()
	print(min(sum(l) // 2, l[0] + l[1]))


from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import sys
t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	(a, b, c) = sorted([a, b, c])
	if a + b <= c:
		print(a + b)
	else:
		ans = a
		cnt = min(a, c - b)
		a -= cnt
		c -= cnt
		(a, b, c) = sorted([a, b, c])
		if a == 0:
			print(cnt + min(b, c))
		else:
			c -= (a + 1) // 2
			b -= a // 2
			print(cnt + a + min(b, c))


import math
t = int(input())
answer = []
for i in range(t):
	f = list(map(int, input().split()))
	f.sort()
	a = f[0]
	b = f[1]
	c = f[2]
	if c - a >= b:
		answer.append(a + b)
	else:
		k = max(c - a, b)
		p = a - c + k
		b -= math.ceil(p / 2)
		answer.append(a + b)
for i in range(t):
	print(answer[i])


t = int(input())
for i in range(t):
	(r, g, d) = map(int, input().split())
	mm = max(r, g, d)
	nemax = r + g + d - mm
	if nemax <= mm:
		print(nemax)
		continue
	print((r + g + d) // 2)


for _ in range(int(input())):
	l = list(map(int, input().split()))
	l.sort()
	if l[2] < l[0] + l[1]:
		print(int((l[0] + l[1] + l[2]) / 2))
	elif l[2] >= l[0] + l[1]:
		print(l[0] + l[1])


def main():
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	if a[0] >= a[1] + a[2]:
		print(a[1] + a[2])
	else:
		print(sum(a) // 2)
t = int(input())
while t:
	main()
	t -= 1


t = int(input())
while t:
	(a, b, c) = map(int, input().split())
	mx = -1
	l = [a, b, c]
	l.sort()
	(a, b, c) = l
	d = c - b
	d = min(d, a)
	a -= d
	c -= d
	res = d
	if a % 2:
		res += a
		res += min(b - a // 2, c - a // 2 - 1)
	else:
		res += a
		res += min(b - a // 2, c - a // 2)
	print(res)
	t -= 1


t = int(input())
for _ in range(t):
	(r, g, b) = map(int, input().split())
	max_candy = max(r, g, b)
	min_candy = min(r, g, b)
	mid_candy = r + g + b - max_candy - min_candy
	res = 0
	if max_candy - min_candy < mid_candy:
		res = max_candy - mid_candy
		max_candy -= res
		min_candy -= res
		res += min_candy // 2 * 2
		mid_candy -= min_candy // 2
		max_candy -= min_candy // 2
		res += mid_candy
	else:
		res = min_candy
		max_candy -= min_candy
		res += min(mid_candy, max_candy)
	print(res)


k = int(input())
for i in range(k):
	mas = list(map(int, input().split()))
	mas.sort()
	a = mas[0]
	b = mas[1]
	c = mas[2]
	if c >= a + b:
		print(a + b)
	else:
		print((a + b + c) // 2)


def program():
	l = list(map(int, input().split()))
	l.sort()
	sum = l[1] - l[0]
	l[1] = l[1] - sum
	l[2] = l[2] - sum
	if l[0] == l[1] and l[1] == l[2] and (l[0] % 2 == 0):
		sum = sum + l[0] // 2 * 3
	elif l[0] == l[1] and l[1] == l[2] and (l[0] % 2 != 0):
		sum = sum + l[0] + (l[0] - 1) // 2
	elif l[2] >= 2 * l[0]:
		sum = sum + 2 * l[0]
	elif l[2] % 2 == 0:
		temp = l[2] - l[0]
		sum = sum + 2 * temp
		l[0] = l[0] - temp
		l[1] = l[1] - temp
		l[2] = l[2] - 2 * temp
		if l[0] == l[1] and l[1] == l[2] and (l[0] % 2 == 0):
			sum = sum + l[0] // 2 * 3
		elif l[0] == l[1] and l[1] == l[2] and (l[0] % 2 != 0):
			sum = sum + l[0] + (l[0] - 1) // 2
	else:
		l[2] = l[2] - 1
		temp = l[2] - l[0]
		sum = sum + 2 * temp
		l[0] = l[0] - temp
		l[1] = l[1] - temp
		l[2] = l[2] - 2 * temp
		if l[0] == l[1] and l[1] == l[2] and (l[0] % 2 == 0):
			sum = sum + l[0] // 2 * 3
		elif l[0] == l[1] and l[1] == l[2] and (l[0] % 2 != 0):
			sum = sum + l[0] + (l[0] - 1) // 2
	print(sum)
t = int(input())
for i in range(t):
	program()


for _ in range(int(input())):
	(r, g, b) = map(int, input().split(' '))
	c = sorted([r, g, b])
	sum_c = sum(c)
	s = c[0]
	m = c[1]
	l = c[2]
	if l >= s + m:
		print(s + m)
	elif sum_c % 2 == 0:
		print(sum_c // 2)
	else:
		print((sum_c - 1) // 2)


t = int(input())
for i in range(t):
	x = list(map(int, input().split()))
	x.sort()
	a = x[1] + x[0] - x[2]
	if a < 0:
		print(x[1] + x[0])
	else:
		ans = a % 2
		a //= 2
		ans += 3 * a
		ans += 2 * x[2] - x[1] - x[0]
		print(ans)


t = int(input())
L = []
for _ in range(t):
	temp = list(map(int, input().split()))
	L.append(temp)
for i in range(t):
	ans = 0
	L_ = sorted(L[i], reverse=True)
	(r, g, b) = L_
	temp = g - b
	ans += temp
	r -= temp
	g -= temp
	if r >= g + b:
		print(ans + g + b)
	elif r % 2 == 0:
		print(ans + r + (g - r // 2))
	else:
		print(ans + r + (g - r // 2) - 1)


def compute():
	l = [int(i) for i in input().split()]
	l.sort()
	return min(sum(l) // 2, l[0] + l[1])

def main():
	t = int(input())
	for i in range(t):
		print(compute())
main()


def f(r, g, b):
	if r >= g + b:
		return g + b
	if g >= r + b:
		return r + b
	if b >= r + g:
		return r + g
	if r == max(r, g, b):
		if (g + b - r) % 2 == 0:
			n = (g + b - r) // 2
			return n + f(r, g - n, b - n)
		elif g == max(g, b):
			return f(r, g - 1, b)
		else:
			return f(r, g, b - 1)
	else:
		if g == max(r, g, b):
			return f(g, r, b)
		if b == max(r, g, b):
			return f(b, r, g)
for i in range(int(input())):
	(r, g, b) = list(map(int, input().split()))
	print(f(r, g, b))


t = int(input())
for i in range(t):
	a = sorted(list(map(int, input().split())))
	ans = (a[0] + a[1] + a[2]) // 2
	if a[0] + a[1] < a[2]:
		ans = a[0] + a[1]
	print(ans)


for _ in range(int(input())):
	lst = list(map(int, input().split()))
	lst.sort()
	if lst[0] == 1:
		print(min(lst[0] + lst[1], lst[2]))
	else:
		while lst[0] > 0:
			if lst[1] == lst[2] and lst[0] > 1:
				if lst[0] % 2 == 1:
					lst[0] -= 1
				lst[0] = lst[0] // 2
				lst[2] += lst[0]
				lst[1] += lst[0]
				lst[0] = 0
			elif lst[0] + lst[1] <= lst[2]:
				lst[1] = lst[0] + lst[1]
				lst[0] = 0
			else:
				lst[0] = lst[0] - lst[2] + lst[1]
				lst[1] = lst[2]
				if lst[0] <= 1:
					lst[0] = 0
		print(min(lst[1], lst[2]))


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	ans = 0
	p = [a, b, c]
	p.sort()
	if p[2] >= p[0] + p[1]:
		print(p[0] + p[1])
	else:
		a = p[2] - p[1]
		p[2] -= a
		p[0] -= a
		b = p[1] - p[0]
		p[2] -= b
		p[1] -= b
		ans += a + b + (p[0] + p[1] + p[2]) // 2
		print(ans)


n = int(input())
for _ in range(n):
	(r, g, b) = map(int, input().split())
	days = 0
	arr = [r, g, b]
	maxval = arr.pop(arr.index(max(arr)))
	if sum(arr) >= maxval:
		days = maxval + (sum(arr) - maxval) // 2
	elif sum(arr) < maxval:
		days = sum(arr)
	print(days)


n = int(input())

def sweet(a, b, c):
	candies = [a, b, c]
	candies.sort()
	(x, y, z) = (candies[0], candies[1], candies[2])
	if z >= x + y:
		return x + y
	else:
		return int((x + y + z) / 2)
for i in range(n):
	(a, b, c) = [int(x) for x in input().split()]
	print(sweet(a, b, c))


for q in range(int(input())):
	(a, b, c) = map(int, input().split())
	arr = [a, b, c]
	arr.sort()
	if arr[-1] >= arr[0] + arr[1]:
		print(sum(arr[0:2]))
	else:
		print(int(sum(arr) / 2))


t = int(input())
for i in range(t):
	l = []
	(r, g, b) = map(int, input().split())
	l.append(r)
	l.append(g)
	l.append(b)
	l.sort()
	if l[0] + l[1] > l[2]:
		print((l[0] + l[1] + l[2]) // 2)
	elif l[0] + l[1] == l[2]:
		print(l[2])
	else:
		print(l[0] + l[1])


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

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

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		a = LI()
		a.sort()
		if a[2] >= sum(a[:2]):
			r = sum(a[:2])
		else:
			r = sum(a) // 2
		rr.append(r)
	return JA(rr, '\n')
print(main())


for _ in range(int(input())):
	lst = [int(i) for i in input().split()]
	max1 = max(lst)
	lst.remove(max1)
	sum1 = sum(lst)
	if sum1 <= max1:
		print(sum1)
	else:
		a = sum1 - max1
		print(max1 + a // 2)


import math
import sys
t = int(input())
for i in range(t):
	line = list(map(int, input().split()))
	line.sort(reverse=True)
	(a, b, c) = line
	day = 0
	while c != 0:
		diff = a - b
		if diff >= c:
			day += c
			a -= c
			c = 0
		if diff < c and diff != 0:
			day += diff
			c -= diff
			a -= diff
		if diff == 0:
			day += 2 * math.floor(c / 2) + (a - math.floor(c / 2))
			print(day)
			break
	if c == 0:
		day += min(a, b)
		print(day)


import bisect
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	num = []
	for p in range(2, n + 1):
		if prime[p]:
			num.append(p)
	return num

def lcm(a, b):
	return a * b // math.gcd(a, b)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]))

def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binaryToDecimal(n):
	return int(n, 2)

def solve():
	(r, g, b) = sorted(num_input())
	ans = 0
	if g != b:
		if r < b - g:
			ans = g
			b -= g
			ans += min(r, b)
			print(ans)
			return
		else:
			ans = b - g
			r -= b - g
			b -= b - g
	temp = r // 2 * 2
	ans += temp
	r -= temp
	g -= temp // 2
	b -= temp // 2
	if r == 0:
		ans += min(g, b)
	else:
		ans += 1
		if g < b:
			b -= 1
			ans += min(g, b)
		else:
			g -= 1
			ans += min(g, b)
	print(ans)
t = int(input())
for _ in range(t):
	solve()


def solver(r, g, b):
	res = 0
	(x, y, z) = sorted([r, g, b])
	d = z - y
	z -= min(d, x)
	res += min(d, x)
	x -= min(d, x)
	(half_x, rem_x) = (x // 2, x % 2)
	x = 0
	y -= half_x + rem_x
	z -= half_x
	res += half_x * 2 + rem_x
	z -= y
	res += y
	y = 0
	return res
for i in range(int(input())):
	(r, g, b) = [int(x) for x in input().split()]
	print(solver(r, g, b))


import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
N = int(input())
for _ in range(N):
	l = list(map(int, input().split()))
	l = sorted(l, reverse=True)
	(r, g, b) = l
	add = min(b, r - g)
	g += add
	b -= add
	r += b // 2
	g += b // 2
	print(min(r, g))


t = int(input())
while t > 0:
	t = t - 1
	x = list(map(int, input().split()))
	x.sort()
	print(min(x[0] + x[1], sum(x) // 2))


t = int(input())
for i in range(t):
	lista = [int(c) for c in input().split()]
	lista.sort()
	dias = 0
	(r, g, b) = lista
	diff = b - g
	if diff >= r:
		dias = g + r
	else:
		r -= diff
		dias = b + r // 2
	print(dias)


for _ in range(int(input())):
	c = [int(i) for i in input().split()]
	c.sort()
	if c[0] + c[1] >= c[2]:
		print(sum(c) // 2)
	else:
		print(c[0] + c[1])


tc = int(input())
for _ in range(tc):
	l = list(map(int, input().split()))
	l.sort()
	ans = min(l[0] + l[1], sum(l) // 2)
	print(ans)


import math
n = int(input())
for i in range(n):
	l = sorted(list(map(int, input().split())))
	if l[0] > l[2] - l[1]:
		ans = l[2] - l[1]
		l[0] -= ans
		l[2] -= ans
		ans += l[2] - math.ceil(l[0] / 2) + l[0]
	else:
		ans = l[0]
		ans += min(l[1], l[2] - l[0])
	print(ans)


import math

def ans(a, b, c):
	x = a + b + c
	sum = 0
	count = 0
	print(min(x // 2, x - max(a, b, c)))
t = int(input())
for i in range(1, t + 1, 1):
	(a, b, c) = map(int, input().split())
	ans(a, b, c)


t = int(input())
for w in range(t):
	a = [int(i) for i in input().split()]
	ans = 0
	a.sort()
	Min = a[0]
	Mid = a[1]
	Max = a[2]
	if Max >= Min + Mid:
		print(Min + Mid)
		continue
	print((Min + Mid + Max) // 2)


import math
t = int(input())
for _ in range(t):
	arr = list(map(int, input().split()))
	arr.sort()
	rep = 0
	ans = 0
	if arr[0] == 1 and arr[1] == 1 and (arr[2] == 1):
		print('1')
	else:
		for i in range(1, 3):
			if arr[i] == arr[i - 1]:
				rep = 1
		if arr[2] >= arr[1] + arr[0]:
			print(arr[0] + arr[1])
		else:
			ans = arr[2] + (arr[1] + arr[0] - arr[2]) // 2
			print(ans)


import math
t = int(input())
for _ in range(t):
	a = [int(x) for x in input().split()]
	a.sort()
	print(a[0] + a[1] - max(0, math.ceil((a[0] + a[1] - a[2]) / 2)))


t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	m = max(a)
	x = a[0] + a[1] + a[2]
	y = x - m
	if y < m:
		print(y)
	else:
		z = int((y - m) / 2)
		print(m + z)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	l = [a, b, c]
	l.sort()
	max1 = l[-1]
	max2 = l[-2]
	max3 = l[-3]
	d = max1 - max2
	if d >= max3:
		cnt = max3 + max2
		print(cnt)
		continue
	else:
		cnt = d
		max1 = max1 - d
		max3 = max3 - d
		x = max3 // 2
		if max3 % 2 == 0:
			cnt = cnt + max3 + max1 - x
			print(cnt)
			continue
		else:
			cnt = cnt + max3 + max1 - (x + 1)
			print(cnt)


for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	a1 = [0, 0, 0]
	(a1[0], a1[1], a1[2]) = (a, b, c)
	a1.sort()
	s = a1[0] + a1[1]
	if s > a1[2]:
		print(a1[2] + (s - a1[2]) // 2)
	else:
		print(s)


t = int(input())
rgb = [list(map(int, input().split())) for _ in range(t)]
for i in range(t):
	L = sorted(rgb[i])
	if L[2] - L[1] >= L[0]:
		print(L[1] + L[0])
	else:
		x = L[2] - L[1]
		L[2] -= x
		L[0] -= x
		if L[0] % 2 == 0:
			L[1] -= L[0] // 2
			L[2] -= L[0] // 2
		else:
			L[1] -= L[0] // 2
			L[2] -= L[0] // 2 + 1
		print(x + L[0] + min(L[1], L[2]))


n = int(input())
for i in range(n):
	l = list(map(int, input().split()))
	l.sort()
	(a, b, c) = (l[0], l[1], l[2])
	d = a + b - c
	if d < 0:
		print(a + b)
	else:
		print(c + d // 2)


t = int(input())
for i in range(t):
	inp = list(map(int, input().split()))
	inp.sort()
	(a, b, c) = inp
	if a + b < c:
		print(a + b)
	else:
		s = a + b + c
		print(s // 2)


for _ in range(int(input())):
	L = list(map(int, input().split()))
	L.sort()
	r = L[0]
	g = L[1]
	b = L[2]
	ans = 0
	diff = g - r
	b = b - diff
	g = r
	ans += diff
	print(diff + min(b // 2, r) + r)


for nt in range(int(input())):
	l = list(map(int, input().split()))
	l.sort()
	if l[-1] >= l[-2] + l[-3]:
		print(l[-2] + l[-3])
	else:
		print((l[0] + l[1] + l[2]) // 2)


t = int(input().strip())
for case in range(t):
	(a, b, c) = map(int, input().strip().split())
	ls = sorted([a, b, c])
	if ls[2] > ls[1] + ls[0]:
		print(ls[1] + ls[0])
	else:
		print(sum(ls) // 2)


import math
n = int(input())
for _ in range(n):
	l = list(map(int, input().split()))
	l.sort()
	x = l[-1] - l[-2]
	if x > l[0]:
		ans = l[0]
		l[-1] -= l[0]
		ans += min(l[-1], l[-2])
	else:
		ans = x
		l[0] -= x
		l[-1] = l[-2]
		ans += l[0]
		l[-1] -= math.ceil(l[0] / 2)
		ans += l[-1]
	print(ans)


for i in range(int(input())):
	(a, b, c) = sorted(list(map(int, input().split())))
	x = (a + c - b) // 2
	if x > a:
		print(b + a)
	else:
		print(b + x)


t = int(input())
i = 0
anse = list()
while i < t:
	a = list(map(int, input().split()))
	r = a[0]
	g = a[1]
	b = a[2]
	ans = 0
	tempr = r
	tempg = g
	tempb = b
	r = max(tempr, max(tempb, tempg))
	b = min(tempr, min(tempb, tempg))
	g = tempr + tempb + tempg - r - b
	if r >= g + b:
		print(g + b)
	else:
		ans += r - g
		b -= r - g
		ans += g - b
		ans += b // 2 * 3 + b % 2
		print(ans)
	i = i + 1


n = int(input())
while n:
	n -= 1
	(a, b, c) = map(int, input().split())
	if a < c:
		(a, c) = (c, a)
	if a < b:
		(a, b) = (b, a)
	if b < c:
		(b, c) = (c, b)
	t = a - b
	t2 = c
	t3 = a
	c -= t
	if c >= 0:
		a -= t
		ost = c % (2 * a)
		if c % 2:
			ost += 1
		print((t2 + t3 + b) // 2)
	else:
		print(b + t2)


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	s = sum([a, b, c])
	print(min(s // 2, s - max(a, b, c)))


T = int(input())
for t in range(0, T):
	(r, g, b) = map(int, input().split())
	A = [r, g, b]
	mx = max(A)
	p = A.count(mx)
	s = r + g + b
	if p == 1:
		if s - mx < mx:
			print(s - mx)
		else:
			print(int(s // 2))
	elif p == 2:
		mn = min(A)
		if mn % 2 == 0:
			print(int(mx - mn / 2) + mn)
		else:
			print(int(mx - (mn - 1) / 2 + mn - 1))
	else:
		print(int(s // 2))


import os
import sys

def main():
	T = read_int()
	for _ in range(T):
		print(solve(*read_ints()))

def solve(R, G, B):
	(a, b, c) = (R, G, B)
	count = 0
	while True:
		(a, b, c) = sorted([a, b, c])
		if b == 0:
			break
		if a == b and b == c:
			count += a // 2 * 3
			if a % 2 == 1:
				count += 1
			break
		if a == b:
			n = min(c - b, b)
			count += 2 * n
			a -= n
			b -= n
			c -= 2 * n
			continue
		n = b - a
		count += n
		b -= n
		c -= n
	return count
DEBUG = 'DEBUG' in os.environ

def inp():
	return sys.stdin.readline().rstrip()

def read_int():
	return int(inp())

def read_ints():
	return [int(e) for e in inp().split()]

def dprint(*value, sep=' ', end='\n'):
	if DEBUG:
		print(*value, sep=sep, end=end)
main()


for _ in range(int(input())):
	(l, m, r) = sorted(map(int, input().split()))
	print((l + m + r) // 2 if l + m > r else l + m)


from collections import defaultdict
from collections import Counter
import math
import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def listt():
	return [int(i) for i in input().split()]

def gcd(a, b):
	return math.gcd(a, b)

def lcm(a, b):
	return a * b // gcd(a, b)

def factors(n):
	step = 2 if n % 2 else 1
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(math.sqrt(n)) + 1, step) if n % i == 0)))

def comb(n, k):
	factn = math.factorial(n)
	factk = math.factorial(k)
	fact = math.factorial(n - k)
	ans = factn // (factk * fact)
	return ans

def is_prime(n):
	if n <= 1:
		return False
	if n == 2:
		return True
	if n > 2 and n % 2 == 0:
		return False
	max_div = math.floor(math.sqrt(n))
	for i in range(3, 1 + max_div, 2):
		if n % i == 0:
			return False
	return True

def maxpower(n, x):
	B_max = int(math.log(n, x))
	return B_max

def binaryToDecimal(n):
	return int(n, 2)
t = int(input())
for _ in range(t):
	l = listt()
	l.sort()
	if l[0] + l[1] >= l[2]:
		print(math.floor((l[0] + l[1] + l[2]) / 2))
	else:
		print(l[0] + l[1])


import sys
reader = (list(map(int, s.split())) for s in sys.stdin)

def sweets(r, g, b):
	total = g - r
	g -= total
	b -= total
	if b > r + g:
		total += r + g
	else:
		total += (r + b + g) // 2
	return total
(t,) = next(reader)
for _ in range(t):
	(r, g, b) = sorted(list(next(reader)))
	ans = sweets(r, g, b)
	print(ans)


def sugar(lst):
	if lst[2] <= lst[0] + lst[1]:
		return sum(lst) // 2
	return lst[0] + lst[1]
for _ in range(int(input())):
	a = [int(i) for i in input().split()]
	print(sugar(sorted(a)))


for i in range(int(input())):
	(a, b, c) = (int(x) for x in input().split())
	mx = max(a, b, c)
	mn = min(a, b, c)
	md = a + b + c - mn - mx
	if mx >= md + mn:
		print(mn + md)
	else:
		print(mx + (mn + md - mx) // 2)


n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	lst = [a, b, c]
	lst.sort()
	x = lst[0]
	y = lst[1]
	z = lst[2]
	if x + y <= z:
		print(x + y)
	else:
		d = x + y - z
		print(z + d // 2)


for _ in ' ' * int(input()):
	(a, b, c) = sorted(map(int, input().split()))
	print([a + b, (a + b + c) // 2][a + b >= c])


t = int(input())
for i in range(t):
	al = list(map(int, input().split()))
	al.sort()
	count = 0
	(r, g, b) = (al[2], al[1], al[0])
	rd = min(r - g, b)
	r -= rd
	b -= rd
	count += rd
	if b == 0:
		print(count + min(r, g))
		continue
	else:
		bs = b // 2
		r -= bs
		g -= bs
		b -= bs * 2
		count += bs * 2
		if b == 1:
			if r > 0:
				r -= 1
				b -= 1
				count += 1
			elif g > 0:
				g -= 1
				b -= 1
				count += 1
		print(min(r, g) + count)


from math import *
for i in range(int(input())):
	List = list(map(int, input().split()))
	List.sort()
	if List[0] + List[1] >= List[2]:
		print(sum(List) // 2)
	else:
		print(sum(List[:2]))


t = int(input())
for ij in range(0, t):
	l = list(map(int, input().split()))
	l = sorted(l)
	if l[2] > l[1] + l[0]:
		print(l[1] + l[0])
	else:
		print(sum(l) // 2)


for __ in range(int(input())):
	aa = list(map(int, input().split()))
	aa.sort()
	if aa[2] > aa[0] + aa[1]:
		print(aa[0] + aa[1])
	else:
		print(sum(aa) // 2)


n = int(input())
for i in range(n):
	ans = 0
	l = list(map(int, input().split()))
	l.sort()
	(a, b, c) = l
	x = min(c - a, b)
	c -= a
	ans += a + x
	b = b - x
	c = c - x
	if c == 0 and b > 0:
		if b % 2 != 0:
			b -= 1
		ans += min(b, a * 2) // 2
		print(ans)
	else:
		print(ans)


def process(a, b, c):
	if a <= b + c:
		return (a + b + c) // 2
	else:
		return b + c

def inkq():
	s = input()
	b = s.split(' ')
	c = []
	for i in b:
		x = int(i)
		c.append(x)
	c.sort(reverse=True)
	print(process(c[0], c[1], c[2]))
q = int(input())
for i in range(0, q):
	inkq()


n = int(input())
for i in range(n):
	arr = [0] * 3
	(arr[0], arr[1], arr[2]) = map(int, input().split())
	arr.sort()
	print(sum(arr) // 2) if arr[2] <= arr[1] + arr[0] else print(arr[0] + arr[1])


T = int(input())
while T:
	Rgb = list(map(int, input().split()))
	Total = Rgb[0] + Rgb[1] + Rgb[2]
	Max = max(Rgb)
	if Total - Max <= Max:
		Ans = Total - Max
	else:
		Ans = Total // 2
	print(Ans)
	T -= 1


for _ in range(int(input())):
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	if a[0] > a[1] + a[2]:
		print(a[1] + a[2])
	else:
		print(sum(a) // 2)


import array
number = int(input())
arr = array.array('i', [1, 2, 3])
for i in range(0, number):
	sum = 0
	arr = [int(x) for x in input().split()]
	arr.sort()
	if arr[0] == 0:
		sum = arr[1]
	elif arr[0] > arr[2] - arr[1]:
		sum = arr[2] - arr[1]
		arr[0] -= arr[2] - arr[1]
		arr[2] = arr[1]
		sum += arr[1] + int(arr[0] / 2)
	else:
		sum = arr[0] + arr[1]
	print(sum)


t = input()
for _ in range(int(t)):
	nums = [0, 0, 0]
	(nums[0], nums[1], nums[2]) = map(int, input().split())
	ans = (nums[0] + nums[1] + nums[2]) // 2
	if len(set(nums)) != 1:
		nums.sort()
		if nums[2] >= nums[1] + nums[0]:
			ans = 0
			if nums[1] == nums[2]:
				ans += 1
			ans += min(nums[0], nums[2])
			nums[2] = nums[2] - nums[0]
			ans += min(nums[2], nums[1])
	print(ans)


import os
import sys
from io import BytesIO, IOBase

def solution(r, g, b):
	if r + g <= b:
		write(r + g)
	else:
		write((r + g + b) // 2)

def main():
	for _ in range(r_int()):
		(r, g, b) = sorted(r_array())
		solution(r, g, b)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(end)

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

def r_int():
	return int(input())
main()


from sys import stdin, stdout
t = int(stdin.readline().strip())
for _ in range(t):
	c = list(map(int, stdin.readline().split()))
	c.sort(reverse=True)
	total = c[1] - c[2]
	(c[0], c[1]) = (c[0] - total, c[1] - total)
	k = min(c[0] - c[1], c[1])
	total += k * 2
	c[1] = c[1] - k
	total += 3 * (c[1] // 2) + c[1] % 2
	stdout.write('{}\n'.format(total))


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		a = list(map(int, input().split()))
		a.sort()
		op = a[1] - a[0]
		a[1] -= op
		a[2] -= op
		ans = op
		op = min(a[2] // 2, a[0])
		a[0] -= op
		a[1] -= op
		a[2] -= 2 * op
		ans += 2 * op
		assert a[0] == a[1]
		if a[0] > 0:
			ans += a[0]
		print(ans)
main()


def resolve():
	l = [i for i in map(int, input().split())]
	l.sort()
	if l[2] - l[0] >= l[1]:
		print(l[0] + l[1])
	else:
		dif = l[2] - l[1]
		print((l[0] - dif) // 2 + l[1] + dif)
n = int(input())
for i in range(n):
	resolve()


for i in range(int(input())):
	l = list(map(int, input().split()))
	l = sorted(l)
	diff = l[2] - l[1]
	if diff >= l[0]:
		l[1] += l[0]
		l[0] = 0
	else:
		l[1] += diff
		l[0] -= diff
	ans = min(l[1], l[2]) + l[0] // 2
	print(ans)


import sys

def main():
	t = int(sys.stdin.readline())
	solns = []
	for _ in range(t):
		candy = [int(x) for x in sys.stdin.readline().split(' ')]
		candy.sort()
		if candy[2] >= candy[1] + candy[0]:
			solns.append(candy[1] + candy[0])
		else:
			solns.append(sum(candy) // 2)
	print('\n'.join((str(x) for x in solns)))
main()


import os, sys

def solve(*digits):
	(c, b, a) = sorted(digits)
	if a >= b + c:
		return min(a, b + c)
	return (a + b + c) // 2
num = int(input().strip())
for x in range(num):
	digits = list(map(int, input().strip().split()))
	v = solve(*digits)
	print(v)


def solve(A):
	A.sort()
	if A[2] >= A[0] + A[1]:
		return A[0] + A[1]
	return sum(A) // 2

def main():
	for _ in range(int(input())):
		A = list(map(int, input().split()))
		print(solve(A))
main()


import math

def fact(n):
	ans = 1
	for i in range(2, n + 1):
		ans *= i
	return ans

def comb(n, c):
	return fact(n) // (fact(n - c) * c)
for _ in range(int(input())):
	(a, b, c) = sorted(list(map(int, input().split())))
	ans = 0
	if c >= a + b:
		ans = a + b
		print(ans)
	else:
		ans = (a + b + c) // 2
		print(ans)


test = int(input())
while test > 0:
	test -= 1
	(x, y, z) = map(int, input().split())
	summ = min(x, y, z)
	maxx = max(x, y, z)
	minn = summ
	t = sum([x, y, z]) - maxx - minn
	maxx = maxx - minn
	if maxx >= t:
		summ += t
	else:
		summ = summ + int((t + maxx) / 2)
	print(summ)


t = int(input())
for _ in range(t):
	vals = list(map(int, input().split()))
	vals.sort()
	if vals[2] - vals[1] <= vals[0]:
		day = 0
		day = vals[2] - vals[1]
		vals[0] -= day
		day += vals[0] // 2 * 2
		vals[1] -= vals[0] // 2
		print(day + vals[1])
	else:
		assert vals[0] + vals[1] == vals[0] + min(vals[2] - vals[0], vals[1]), 'Mistake'
		print(vals[0] + vals[1])


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	A = LIST()
	A.sort()
	if A[0] + A[1] >= A[2]:
		print(sum(A) // 2)
	else:
		x = A[2] - (A[0] + A[1])
		print((sum(A) - x) // 2)


T = int(input())
for I in range(T):
	L = list(map(int, input().split()))
	L.sort()
	D = 0
	if L[2] >= L[0] + L[1]:
		D = L[0] + L[1]
	else:
		D += L[1] - L[0]
		L[2] -= L[1] - L[0]
		L[1] = L[0]
		D += (L[0] + L[1] + L[2]) // 2
	print(D)


import sys, math
input = sys.stdin.readline

def inp():
	n = int(input())
	return n

def inlt():
	a = list(map(int, input().split()))
	return a

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	(a, b, c) = map(int, input().split())
	return (a, b, c)
t = 1
t = inp()
for tt in range(t):
	(r, g, b) = sorted(invr())
	if b > r + g:
		print(r + g)
	else:
		print((r + g + b) // 2)


import math
t = int(input())
for _ in range(t):
	(r, g, b) = list(map(int, input().split()))
	if max(r, g, b) == 1:
		print(1)
		continue
	Sum = r + g + b
	arr = [r, g, b]
	arr.sort()
	print(min(arr[0] + arr[1], (r + g + b) // 2))


t = int(input())
for i in range(t):
	inp = list(map(int, input().split()))
	inp.sort()
	k = inp[2] - inp[1]
	ans = 0
	if k >= inp[0]:
		print(inp[0] + inp[1])
	elif (inp[0] - k) % 2 == 0:
		print(max(inp[2], k + inp[0] - k + inp[1] - (inp[0] - k) // 2))
	else:
		print(max(inp[2], k + inp[0] - k + inp[1] - (inp[0] - k) // 2 - 1))


qtd = int(input())
for i in range(qtd):
	doces = list(map(int, input().split()))
	maior = max(doces)
	doces.remove(maior)
	menor = min(doces)
	doces.remove(menor)
	meio = doces[0]
	total1 = menor + meio
	total2 = int((maior + meio + menor) / 2)
	print(min(total1, total2))


t = int(input())
for i in range(t):
	(a, b, c) = [int(x) for x in input().split()]
	if a > b:
		(a, b) = (b, a)
	if b > c:
		(b, c) = (c, b)
	if a > b:
		(a, b) = (b, a)
	if c >= a + b:
		print(a + b)
	else:
		res = c
		c -= b - a
		c = c // 2 + c % 2
		res += a - c
		print(res)


import math
N = int(input())
while N > 0:
	a = input().split()
	a[0] = int(a[0])
	a[1] = int(a[1])
	a[2] = int(a[2])
	if a[0] > a[1]:
		(a[0], a[1]) = (a[1], a[0])
	if a[0] > a[2]:
		(a[0], a[2]) = (a[2], a[0])
	if a[1] > a[2]:
		(a[1], a[2]) = (a[2], a[1])
	N -= 1
	if a[0] + a[1] >= a[2]:
		print(math.floor((a[0] + a[1] + a[2]) / 2))
	elif a[2] > a[0] + a[1]:
		print(a[0] + a[1])


tc = int(input())
for _ in range(tc):
	(x, y, z) = list(sorted(list(map(int, input().split()))))
	if x + y <= z:
		print(x + y)
	else:
		ans = 0
		diffy = z - y
		tmp = min(diffy, x)
		ans += tmp
		z -= tmp
		x = max(0, x - diffy)
		tmp = x // 2
		z -= x - tmp
		y -= tmp
		ans += x
		ans += max(min(y, z), 0)
		print(ans)


from math import sqrt
t = int(input())
for _ in range(t):
	(r, g, b) = map(int, input().split())
	if g < b:
		x = g
		g = b
		b = x
	if r < g:
		x = r
		r = g
		g = x
	if r >= b + g:
		print(b + g)
	else:
		print((r + g + b) // 2)


n = int(input())
for i in range(n):
	ls = [int(i) for i in input().split()]
	ls.sort()
	x = ls[0] + ls[1]
	z = ls[2]
	if ls[0] + ls[1] >= ls[2]:
		print((x + z) // 2)
	else:
		print(x)


t = int(input())
out = []
for i in range(t):
	(a, b, c) = map(int, input().split(' '))
	k = sorted([a, b, c])
	(a, b, c) = (k[-1], k[1], k[0])
	result = b - c
	a -= b - c
	if a > c * 2:
		result += c * 2
	else:
		result += (a + c * 2) // 2
	out.append(result)
for i in out:
	print(i)


def SweetProb(candies):
	candy = candies[:]
	days = 0
	candy.sort()
	if candy[2] >= candy[1] + candy[0]:
		return candy[1] + candy[0]
	days += candy[1] - candy[0]
	candy[1] = candy[0]
	candy[2] += -1 * days
	days += candy[2]
	candy[0] += -1 * candy[2] // 2
	days += candy[0]
	return days

def main():
	l = []
	for i in range(int(input())):
		inl = input().split()
		l.append(SweetProb([int(inl[0]), int(inl[1]), int(inl[2])]))
	for i in l:
		print(i)
if '__main__' == __name__:
	main()


t = int(input())
for _ in range(t):
	(r, g, b) = [int(x) for x in input().split()]
	ans1 = (r + g + b) // 2
	x = min(r, g, b)
	z = max(r, g, b)
	y = sum([r, g, b]) - x - z
	ans2 = x + y
	ans = min(ans1, ans2)
	print(ans)


cases = int(input())
for case in range(cases):
	(red, green, blue) = [int(x) for x in input().split(' ')]
	total = (red + green + blue) // 2
	print(min(total, red + green, green + blue, red + blue))


for _ in range(int(input())):
	r = list(map(int, input().split()))
	r.sort()
	if r[2] > r[1] + r[0]:
		print(r[1] + r[0])
	else:
		print(r[2] - r[1] + (r[0] - r[2] + r[1]) // 2 + r[1])


for i in range(int(input())):
	li = sorted(list(map(int, input().split())))
	ans = 0
	if li[2] > li[0] + li[1]:
		ans = li[0] + li[1]
	else:
		ans = (li[0] + li[1] + li[2]) // 2
	print(ans)


t = int(input())
for i in range(t):
	a = list(map(int, input().strip().split()))
	a.sort(reverse=True)
	if a[0] > sum(a[1:]):
		print(sum(a[1:]))
	else:
		print(sum(a) // 2)


n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	(a, b, c) = sorted([a, b, c])
	res = 0
	if c >= b - a:
		res += b - a
		c -= b - a
		b = a
	mx = min(a, c // 2)
	res += mx * 2
	c -= mx * 2
	a -= mx
	b -= mx
	res += a
	print(res)


for _ in range(int(input())):
	l = list(map(int, input().split()))
	MAX = max(l)
	l.remove(MAX)
	counter = 0
	v = l[0] + l[1]
	if v > MAX:
		v = (v - MAX) // 2
		counter = v
		l[0] -= v
		l[1] -= v
		print(MAX + counter)
	else:
		print(l[0] + l[1])


import math

def solve(a, b, c):
	p = [a, b, c]
	p.sort()
	if p[0] + p[1] < p[2]:
		return p[0] + p[1]
	else:
		return (a + b + c) // 2

def main():
	t = int(input())
	for i in range(t):
		(a, b, c) = tuple([int(x) for x in input().split()])
		print(solve(a, b, c))
main()


T = int(input())
for kase in range(T):
	(a, b, c) = [int(x) for x in input().split()]
	(a, b, c) = sorted([a, b, c])
	ans = 0
	d = b - a
	ans += d
	c -= d
	b -= d
	d = min(c - a, a)
	ans += 2 * d
	c -= 2 * d
	b -= d
	a -= d
	if a == b == c:
		ans += (a + b + c) // 2
	print(ans)


import math
n = int(input())
for _ in range(n):
	candies = list(map(int, input().split()))
	candies.sort(reverse=True)
	count = 0
	if candies[0] == candies[1] and candies[0] != candies[2]:
		if candies[2] % 2 == 0:
			candies[0] -= candies[2] // 2
			candies[1] -= candies[2] // 2
			count += candies[2]
			candies[2] = 0
		else:
			candies[0] -= math.ceil(candies[2] / 2)
			candies[1] -= candies[2] - math.ceil(candies[2] / 2)
			count += candies[2]
			candies[2] = 0
		if candies[0] < candies[1]:
			count += candies[0]
		else:
			count += candies[1]
	elif candies[0] - candies[2] < candies[1]:
		n = candies[0] - candies[1]
		count += n
		candies[2] -= n
		candies[0] -= n
		if candies[2] % 2 == 0:
			candies[0] -= candies[2] // 2
			candies[1] -= candies[2] // 2
			count += candies[2]
			candies[2] = 0
		else:
			candies[0] -= math.ceil(candies[2] / 2)
			candies[1] -= candies[2] - math.ceil(candies[2] / 2)
			count += candies[2]
			candies[2] = 0
		if candies[0] < candies[1]:
			count += candies[0]
		else:
			count += candies[1]
	else:
		candies[0] = candies[0] - candies[1]
		count += candies[1]
		candies[1] = 0
		if candies[0] != 0 and candies[2] != 0:
			if candies[0] < candies[2]:
				count += candies[0]
			else:
				count += candies[2]
	print(count)


n = int(input())
for i in range(0, n):
	p = input().rstrip().split(' ')
	p.sort(key=int, reverse=True)
	A = int(p[0]) - int(p[1])
	if A >= int(p[2]):
		print(int(p[2]) + int(p[1]))
	else:
		p[2] = int(p[2]) - A
		ans = A
		p[0] = int(p[0]) - A
		D = (int(p[0]) + int(p[1]) + int(p[2])) // 2
		ans += D
		print(ans)


cases = int(input())
while cases != 0:
	rgb = input()
	rgb_list = rgb.split(' ')
	rgb_list = [int(i) for i in rgb_list]
	rgb_list.sort()
	if rgb_list[0] + rgb_list[1] > rgb_list[2]:
		days = sum(rgb_list) // 2
	else:
		days = rgb_list[0] + rgb_list[1]
	print(days)
	cases = cases - 1


for _ in range(int(input())):
	(r, g, b) = sorted(map(int, input().split()))
	take = min(r, b - g)
	r -= take
	b -= take
	b -= r // 2
	g -= r // 2
	if r % 2:
		g -= 1
	print(take + r + min(g, b))


t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	a.sort()
	c = 0
	d = a[2] - a[1]
	if d >= a[0]:
		a[2] -= a[0]
		c += a[0]
	else:
		a[2] -= d
		a[0] -= d
		c += d + a[0]
		if a[0] & 1:
			a[2] -= a[0] // 2
			a[1] -= a[0] // 2 + 1
		else:
			a[2] -= a[0] // 2
			a[1] -= a[0] // 2
	print(min(a[2], a[1]) + c)


n = int(input())

def getAns(li):
	li.sort()
	total = li[0]
	r = li[0]
	s = li[1]
	t = li[2]
	a = t - s
	if a >= r:
		total += s
		print(total)
		return
	else:
		t -= a
		r -= a
		total += s - (r + 1) // 2
		print(total)
		return
for i in range(n):
	getAns([int(x) for x in input().split(' ')])


test = int(input())
for i in range(test):
	a = [int(j) for j in input().split()]
	a.sort()
	print(min(sum(a) // 2, a[0] + a[1]))


import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations

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

def num():
	return map(int, sys.stdin.readline().split())

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	gg = find_gcd(x, y)
	return x * y // gg
mm = 1000000007

def solve():
	t = nu()
	for tt in range(t):
		(r, g, b) = num()
		a = [r, g, b]
		a.sort()
		x = a[0]
		y = a[1]
		z = a[2]
		zz = z - y
		op = min(zz, x)
		x -= op
		z -= op
		ff = x // 2
		op += ff * 2
		y -= ff
		z -= ff
		x -= op
		if x > 0:
			op += 1
			z -= 1
		op += min(z, y)
		print(op)
solve()


t = int(input())
while t > 0:
	t -= 1
	(r, g, b) = map(int, input().split())
	m = max(r, g, b)
	s = r + g + b
	print(min(s // 2, s - m))


for _ in range(int(input())):
	l = []
	(a, b, c) = map(int, input().split())
	l.append(a)
	l.append(b)
	l.append(c)
	l.sort()
	l1 = list(set(l))
	if len(l1) == 1:
		print(l[0] + l[0] // 2)
	elif len(l1) == 2:
		if l[0] == l[1]:
			if l[2] < l[0]:
				print(l[2] // 2 + l[0])
			elif l[2] > l[0] and l[2] < 2 * l[0]:
				print(l[2] - int(l[2] % 2) + l[0] - l[2] // 2)
			else:
				print(2 * l[0])
		elif l[1] == l[2]:
			if l[0] < l[1]:
				print(l[0] // 2 + l[1])
			elif l[0] > l[1] and l[0] < 2 * l[1]:
				print(l[0] - int(l[0] % 2) + l[1] - l[0] // 2)
			else:
				print(2 * l[1])
	elif l[2] <= l[1] + l[0]:
		print(sum(l) // 2)
	else:
		print(l[1] + l[0])


t = int(input())
for i in range(t):
	array = [int(x) for x in input().split()]
	array.sort()
	if array[0] + array[1] < array[2]:
		print(array[0] + array[1])
	else:
		print(sum(array) // 2)


import sys
input = sys.stdin.readline
n = int(input())
while n:
	n -= 1
	(r, g, b) = map(int, input().split())
	col = [r, g, b]
	col.sort()
	(l, r) = (0, col[1] + 1)
	while l < r:
		mid = (l + r) // 2
		if mid <= col[1] and col[2] + col[1] - 2 * mid >= col[0]:
			l = mid + 1
		else:
			r = mid
	print(max(r - 1 + col[0], min(col[0] + col[1], col[2])))


t = int(input())
for _ in range(t):
	a = [int(x) for x in input().split()]
	a.sort()
	if a[0] + a[1] > a[2]:
		print(sum(a) // 2)
	else:
		print(a[0] + a[1])


t = int(input())
for i in range(t):
	(r, g, b) = map(int, input().split())
	if r == g == b:
		print((r + g + b) // 2)
		continue
	ls = []
	ls.append(r)
	ls.append(g)
	ls.append(b)
	ls.sort()
	if ls[1] == ls[2]:
		print((ls[0] + ls[1] + ls[2]) // 2)
		continue
	if ls[0] + ls[1] < ls[2]:
		print(ls[0] + ls[1])
	else:
		print((ls[0] + ls[1] + ls[2]) // 2)


def check2(lis, count):
	if lis[0] % 2 == 0:
		lis[2] -= lis[0] / 2
		lis[1] -= lis[0] / 2
		lis[0] = 0
	else:
		lis[0] += 1
		lis[2] -= lis[0] / 2
		lis[1] -= lis[0] / 2
		lis[2] += 1
		lis[0] = 0
	lis = sorted(lis)
	count += lis[1]
	print(int(count))

def check(lis):
	if lis[1] == lis[2]:
		check2(lis, lis[0])
		return
	tmp = 0
	if lis[2] - lis[1] <= lis[0]:
		tmp += lis[2] - lis[1]
		lis[2] -= tmp
		lis[0] -= tmp
		check2(sorted(lis), tmp + lis[0])
		return
	count = lis[0]
	lis[2] -= lis[0]
	lis[0] = 0
	lis = sorted(lis)
	count += lis[1]
	print(max(tmp, count))
n = int(input())
inputs = []
for i in range(n):
	tmp = input().split(' ')
	tmp = list(map(int, tmp))
	inputs.append(sorted(tmp))
for i in range(n):
	check(inputs[i])


import math
for _ in range(int(input())):
	(a, b, c) = sorted(list(map(int, input().split())))
	x = c - b
	ans = min(x, a)
	a -= ans
	c -= ans
	ans += min(b - a // 2, c - math.ceil(a / 2)) + a
	print(ans)


def resolve():
	lista = [int(i) for i in input().split()]
	lista.sort()
	sub = lista[2] - lista[1]
	return lista[0] + min(lista[1], lista[2] - lista[0]) if sub >= lista[0] else sub + (lista[0] - sub) // 2 + lista[1]
q = int(input())
for __ in range(q):
	print(resolve())