You play your favourite game yet another time. You chose the character you didn't play before. It has $str$ points of strength and $int$ points of intelligence. Also, at start, the character has $exp$ free experience points you can invest either in strength or in intelligence (by investing one point you can either raise strength by $1$ or raise intelligence by $1$).

Since you'd like to make some fun you want to create a jock character, so it has more strength than intelligence points (resulting strength is strictly greater than the resulting intelligence).

Calculate the number of different character builds you can create (for the purpose of replayability) if you must invest all free points. Two character builds are different if their strength and/or intellect are different.


-----Input-----

The first line contains the single integer $T$ ($1 \le T \le 100$) — the number of queries. Next $T$ lines contain descriptions of queries — one per line.

This line contains three integers $str$, $int$ and $exp$ ($1 \le str, int \le 10^8$, $0 \le exp \le 10^8$) — the initial strength and intelligence of the character and the number of free points, respectively.


-----Output-----

Print $T$ integers — one per query. For each query print the number of different character builds you can create.


-----Example-----
Input
4
5 3 4
2 1 0
3 5 5
4 10 6

Output
3
1
2
0



-----Note-----

In the first query there are only three appropriate character builds: $(str = 7, int = 5)$, $(8, 4)$ and $(9, 3)$. All other builds are either too smart or don't use all free points.

In the second query there is only one possible build: $(2, 1)$.

In the third query there are two appropriate builds: $(7, 6)$, $(8, 5)$.

In the fourth query all builds have too much brains.

Difficulty: EASY

Solutions:
q = int(input())
for i in range(q):
	(s, i, e) = map(int, input().split())
	if s <= i and e >= i - s + 1:
		print((e - (i - s + 1)) // 2 + 1)
	elif s > i and e >= s - i - 1:
		print((e - (s - i - 1)) // 2 + (s - i))
	elif s > i and e < s - i - 1:
		print(e + 1)
	else:
		print(0)


for i in range(int(input())):
	(s, i, e) = list(map(int, input().split()))
	print(max(0, min(e + 1, (s - i + e + 1) // 2)))


def solve():
	n = int(input())
	for _ in range(n):
		(s, i, e) = map(int, input().split())
		n_s = s + e
		if n_s > i:
			print(min(e + 1, n_s - (n_s + i) // 2))
		else:
			print('0')
solve()


import math
t = int(input())
for _ in range(t):
	(s, i, e) = map(int, input().split())
	if s - i > e:
		print(e + 1)
	else:
		ans = math.ceil((s - i + e) / 2)
		if ans <= 0:
			print(0)
		else:
			print(ans)


import math
t = int(input())
v = []
for i in range(t):
	(stro, inte, expo) = [int(s) for s in input().split()]
	if stro - inte > expo:
		r = expo + 1
	elif math.fabs(stro - inte) < expo:
		r = (stro - inte + expo) // 2 + (stro - inte + expo) % 2
	elif stro - inte == expo:
		r = expo
	else:
		r = 0
	v.append(r)
print(*v, sep='\n')


R = lambda : map(int, input().split())
for _ in range(int(input())):
	(a, b, c) = R()
	k = a + c - b
	p = (a + b + c) // 2
	if k % 2:
		p = p - b + 1
	else:
		p -= b
	if p <= 0:
		print(0)
	else:
		print(min(c + 1, p))


for i in range(int(input())):
	(n, k, d) = map(int, input().split())
	min_str = max(0, (d + k - n + 2) // 2)
	print(max(d - min_str + 1, 0))


t = int(input())
for test in range(t):
	(s, i, e) = map(int, input().split())
	d = s - i
	if d > 0:
		d -= 1
		f = max(e - d, 0)
		if f % 2 == 0:
			res = e - f // 2 + 1
		else:
			res = e - (f + 1) // 2 + 1
	elif d == 0:
		if e > 0:
			res = (e - 1) // 2 + 1
		else:
			res = 0
	else:
		d = i - s
		if e < d + 1:
			res = 0
		else:
			e = e - d - 1
			res = e // 2 + 1
	print(res)


from math import ceil
T = int(input())
for t in range(T):
	(s, i, e) = map(int, input().split())
	print(min(e + 1, max(ceil((e - i + s) / 2), 0)))


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


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


for _ in range(int(input())):
	ans = 0
	cnt = 0
	(s, i, e) = map(int, input().split())
	b = (s - i + e - 1) // 2
	if b < 0:
		print(0)
	elif b == 0:
		print(1)
	elif b >= e:
		print(e + 1)
	else:
		print(b + 1)


for itr in range(int(input())):
	(s, i, x) = list(map(int, input().split()))
	adds = (-s + x + i) // 2
	if adds < 0:
		print(x + 1)
	else:
		print(max(0, x - adds))


def solve():
	(strength, intelligence, exp) = input().split()
	intelligence = int(intelligence)
	exp = int(exp)
	strength = int(strength)
	if exp == 0:
		if strength > intelligence:
			print(1)
		else:
			print(0)
		return
	delta = strength - intelligence
	min_strength = exp - (exp - delta) / 2
	print(min(max(exp - (exp - delta) // 2, 0), exp + 1))

def go():
	T = int(input())
	for i in range(T):
		solve()
go()


def create_character(s, i, e):
	ans = 0
	if s > i + e:
		ans = e + 1
	elif s + e <= i:
		ans = 0
	else:
		s += e
		ans = (s - i + 1) // 2
	return ans
t = int(input())
while t:
	(s, i, e) = map(int, input().split())
	print(create_character(s, i, e))
	t = t - 1


from bisect import *
from collections import *
from itertools import *
import functools
import sys
from math import *
from decimal import *
from copy import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 10 ** 5 + 10
MOD = 10 ** 9 + 7

def isprime(n):
	n = abs(int(n))
	if n < 2:
		return False
	if n == 2:
		return True
	if not n & 1:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return True

def mhd(a, b):
	return abs(a[0] - b[0]) + abs(b[1] - a[1])

def charIN(x=' '):
	return sys.stdin.readline().strip().split(x)

def arrIN(x=' '):
	return list(map(int, sys.stdin.readline().strip().split(x)))

def eld(x, y):
	a = y[0] - x[0]
	b = x[1] - y[1]
	return (a * a + b * b) ** 0.5

def lgcd(a):
	g = a[0]
	for i in range(1, len(a)):
		g = math.gcd(g, a[i])
	return g

def ms(a):
	msf = -MAX
	meh = 0
	st = en = be = 0
	for i in range(len(a)):
		meh += a[i]
		if msf < meh:
			msf = meh
			st = be
			en = i
		if meh < 0:
			meh = 0
			be = i + 1
	return (msf, st, en)

def ncr(n, r):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % MOD
		den = den * (i + 1) % MOD
	return num * pow(den, MOD - 2, MOD) % MOD

def flush():
	return sys.stdout.flush()

def fac(n):
	ans = 1
	for i in range(1, n + 1):
		ans *= i
		ans %= MOD
	return ans
for _ in range(int(input())):
	(s, i, e) = arrIN()
	t = e
	if s + e <= i:
		print(0)
	elif s <= i:
		x = i - s
		s += x
		e -= x
		print((e + 1) // 2)
	elif i + e < s:
		print(e + 1)
	elif i + e == s:
		print(e)
	else:
		x = s - i
		e -= x
		ans = (e + 1) // 2 + x
		print(ans)


import sys
f = sys.stdin
t = int(next(f))
for _ in range(t):
	(s, i, e) = next(f).split()
	s = int(s)
	i = int(i)
	e = int(e)
	if s + e <= i:
		print(0)
	elif s <= i:
		i -= s
		e -= i
		if e % 2 == 0:
			print(e // 2)
		else:
			print(e // 2 + 1)
	else:
		s -= i
		if e < s:
			print(e + 1)
		elif e == s:
			print(e)
		else:
			e -= s
			if e % 2 == 0:
				print(e // 2 + s)
			else:
				print(e // 2 + 1 + s)


t = int(input())

def solve(a, b, c):
	mxa = a + c
	leng = mxa - b
	if leng <= 0:
		return 0
	return min((leng - 1) // 2 + 1, c + 1)
while t:
	t -= 1
	row = input().split(' ')
	(a, b, c) = (int(row[0]), int(row[1]), int(row[2]))
	print(solve(a, b, c))


n = int(input())
for i in range(n):
	(s, i, e) = map(int, input().strip().split())
	r = (i + e - s) // 2
	if r < 0:
		print(e + 1)
	else:
		print(max(0, e - r))


import math
t = int(input())
while t:
	(s, i, e) = map(int, input().split())
	if s + e <= i:
		print(0)
	else:
		if s - i > e:
			print(e + 1)
		if s - i == e:
			print(e)
		if s - i < e:
			print(math.ceil((e + s - i) / 2))
	t = t - 1


for _ in range(int(input())):
	(s, i, e) = map(int, input().split())
	cnt = 0
	if s + e > i:
		maxx = s + e
		if s > i + e:
			minn = s
		else:
			r = abs(s - i)
			minn = max(s, i) + (e - r) // 2 + 1
		cnt = maxx - minn + 1
	print(cnt)


import math
t = int(input())
for i in range(0, t):
	(st, i, exp) = map(int, input().split())
	a = st + exp
	if a <= i:
		print(0)
	else:
		b = (a - i) / 2
		if math.ceil(b) > exp:
			print(exp + 1)
		else:
			print(math.ceil(b))


import math
ntc = int(input())
for tcs in range(ntc):
	(s, i, e) = list(map(int, input().split()))
	if s + e > i:
		res = math.ceil((s + e - i) / 2)
		print(min(res, e + 1))
	else:
		print(0)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	if b != a:
		if abs(a - b) <= c:
			mba = b + c
			mb = (a + b + c + 1) // 2
			bm = min(mba, mb)
			print(bm - b)
		elif a - b > c:
			print(c + 1)
		elif b - a > c:
			print(0)
	elif a == b:
		if c % 2 == 0:
			print(c // 2)
		else:
			print((c + 1) // 2)


import sys
input = sys.stdin.readline
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
for _ in range(int(input())):
	(s, i, e) = map(int, input().split())
	x = max(0, (e + i - s + 2) // 2)
	print(max(0, e - x + 1))


for _ in range(int(input())):
	(s, i, e) = map(int, input().split())
	y = s - i + e
	if y <= 0:
		print(0)
	elif y // 2 == y / 2:
		if y // 2 <= e:
			print(y // 2)
		else:
			print(e + 1)
	elif y / 2 < e:
		print(y // 2 + 1)
	else:
		print(e + 1)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	a += c
	if a > b:
		diff = a - b
		val = 0
		if diff % 2 == 0:
			val = diff // 2
		else:
			val = diff // 2 + 1
		print(min(val, c + 1))
	else:
		print(0)


gi = lambda : list(map(int, input().split()))
for k in range(gi()[0]):
	(s, i, x) = gi()
	ans = 0
	if s > i:
		if x < (s + x - i) // 2:
			ans = x
		else:
			ans = (s + x - i) // 2
			if (s + x - i) % 2 == 0:
				ans -= 1
		ans += 1
	elif s + x <= i:
		ans = 0
	else:
		ans = (s + x - i) // 2 + 1
		if (s + x - i) % 2 == 0:
			ans -= 1
	print(ans)


tests = int(input())
for _ in range(tests):
	(s, i, eps) = map(int, input().split())
	d = s + eps - i + 1
	if d > 0:
		print(min(d // 2, eps + 1))
	else:
		print(0)


T = int(input())
for i in range(0, T):
	(s, i, exp) = (int(i) for i in input().split())
	if s + exp <= i:
		print(0)
	elif i + exp < s:
		print(exp + 1)
	else:
		print(exp + 1 - (i + exp - s + 2) // 2)


def add(a, b, c):
	l = 0
	h = c
	count = 0
	while l <= h:
		mid = (l + h) // 2
		if a + mid > b + c - mid:
			count = c - mid + 1
			h = mid - 1
		else:
			l = mid + 1
	return count
n = int(input())
for i in range(n):
	(a, b, c) = [int(x) for x in input().split()]
	print(add(a, b, c))


t = int(input())
for you in range(t):
	l = input().split()
	s = int(l[0])
	i = int(l[1])
	e = int(l[2])
	z = max(0, (i + e - s) // 2 + 1)
	print(max(0, e - z + 1))


n = int(input())
for _ in range(n):
	(s, i, e) = map(int, input().split())
	res = 0
	if e == 0:
		if s > i:
			print(1)
		else:
			print(0)
		continue
	if s > i + e:
		print(e + 1)
		continue
	if s > i:
		print(e - (e + i - s) // 2)
		continue
	if s <= i:
		e -= i + 1 - s
		s += i + 1 - s
		if e < 0:
			print(0)
			continue
		else:
			print(e - (e + i - s) // 2)


t = int(input())
for case in range(t):
	(s, i, e) = [int(x) for x in input().split(' ')]
	x = min(max(0, (i + e - s) // 2 + 1), e + 1)
	print(e - x + 1)


t = int(input())
for _ in range(t):
	(s, i, e) = map(int, input().split())
	c = 0
	diff = abs(s - i)
	if s > i:
		if diff - 1 > e:
			c += e + 1
		else:
			e -= diff - 1
			c += diff - 1
			c += e // 2 + 1
	elif diff + 1 <= e:
		e -= diff + 1
		c += e // 2 + 1
	print(c)


import sys
input = sys.stdin.readline

def getInt():
	return int(input())

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

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

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

def addDictList(d, key, val):
	if key not in d:
		d[key] = []
	d[key].append(val)

def addDictInt(d, key, val):
	if key not in d:
		d[key] = 0
	d[key] = val

def addDictCount(d, key):
	if key not in d:
		d[key] = 0
	d[key] += 1

def addDictSum(d, key, val):
	if key not in d:
		d[key] = 0
	d[key] += val
t = getInt()
for _ in range(t):
	(a, b, c) = getVars()
	cc = c
	if b > a:
		if c < b - a:
			print(0)
			continue
		else:
			cc -= b - a
	else:
		cc += a - b
	res = cc // 2
	if cc % 2 == 1:
		res += 1
	print(min(res, c + 1))


n = int(input())
for i in range(n):
	(a, b, c) = [int(d) for d in input().split()]
	max1 = a + c
	min1 = max(a, a + (b - a + c) // 2 + 1)
	print(max(0, max1 - min1 + 1))


for TT in range(1, int(input()) + 1):
	(a, b, c) = map(int, input().split())
	l = max(-1, (b + c - a) // 2)
	r = c
	print(r - l if r >= l else 0)


from sys import stdin
for _ in range(int(input())):
	(s, e, p) = map(int, input().split())
	x1 = (p + e - s) // 2
	ans = max(0, p - x1)
	if x1 < 0:
		ans = p + 1
	if ans == 0 and s > e:
		ans = 1
	print(ans)


T = int(input())
while T > 0:
	T -= 1
	(s, i, p) = map(int, input().split())
	if s - i + p <= 0:
		print(0)
		continue
	mx = s - i + p
	mn = max(s - i - p, 1)
	if mx == mn:
		print(1)
	else:
		print((mx - mn) // 2 + 1)


import sys, math, queue, collections
MOD = 10 ** 9 + 7
sys.setrecursionlimit(1000000)
for _ in range(int(input())):
	(s, m, e) = map(int, input().split())
	y = max(0, (s + e - m + 1) // 2)
	print(min(y, e + 1))


import math
t = int(input())
for i in range(t):
	(s, it, exp) = map(int, input().split())
	x = math.floor((it + exp - s) / 2)
	if x < 0:
		x = -1
	res = exp - x
	if res < 0:
		res = 0
	print(res)


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

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

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

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=None):
	if hi == None:
		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(100000.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 float_array():
	return list(map(float, 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())):
	(s, i, e) = int_array()
	max_x = e
	min_x = (i + e - s) // 2 + 1
	min_x = max(0, min_x)
	ans = max_x - min_x + 1
	ans = max(ans, 0)
	print(ans)


def bin_search(a, b, c):
	hi = c
	lo = 0
	ans = 0
	while lo <= hi:
		mid = (hi + lo) // 2
		if a + mid > b + c - mid:
			ans = c + 1 - mid
			hi = mid - 1
		else:
			lo = mid + 1
	return ans
for i in ' ' * int(input()):
	(a, b, c) = map(int, input().split())
	print(bin_search(a, b, c))


T = int(input())
for _ in range(T):
	(S, I, E) = map(int, input().split())
	S = S + E
	s = 0
	if S > I:
		a = (S - I - 1) // 2
		if a > E:
			print(E + 1)
		else:
			if S > I:
				a += 1
			print(a)
	else:
		print(0)


t = int(input())
while t > 0:
	t -= 1
	(s, i, e) = [int(x) for x in input().split()]
	ms = s + e
	if ms <= i:
		print(0)
	else:
		c = (ms - i + 1) // 2
		print(min(c, e + 1))


for i in range(int(input())):
	(s, intel, e) = map(int, input().split())
	min_s = max(0, (intel - s + e + 2) // 2)
	print(max(e - min_s + 1, 0))


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	d = (a + b + c) // 2 + 1
	e = a + c
	print(min([c + 1, max([0, e - d + 1])]))


import math
t = int(input())
for i in range(t):
	(stre, intel, exp) = map(int, input().split())
	se = int(max(0, (exp + intel - stre + 2) / 2))
	output = max(0, exp - se + 1)
	print(output)


for T in range(int(input())):
	[strength, intelligence, experience] = input().split(' ')
	strength = int(strength)
	intelligence = int(intelligence)
	experience = int(experience)
	if strength + experience > intelligence:
		print(strength + experience - max((strength + experience + intelligence) // 2, strength - 1))
	else:
		print(0)


def codeforcesA(ss, ii, ee):
	lst = set()
	(l, r) = (0, ee)
	while l <= r:
		cent = (l + r) // 2
		(a, b) = (ss + cent, ii + (ee - cent))
		if a > b:
			lst.add((a, b))
			r = cent - 1
		else:
			l = cent + 1
	if ss + ee > ii:
		lst.add((ss + ee, ii))
	lst = list(sorted(lst))
	if len(lst) > 0:
		return lst[-1][0] - lst[0][0] + 1
	return 0
t = int(input())
for _ in range(0, t):
	(ss, ii, ee) = map(int, input().split())
	print(codeforcesA(ss, ii, ee))


T = int(input())
for i in range(T):
	(x, y, n) = map(int, input().split())
	max = (n - y + x - 1) // 2
	if max < 0:
		print(0)
	elif max > n:
		print(n + 1)
	else:
		print(max + 1)


from math import ceil
t = int(input())
for _ in range(t):
	(s, i, e) = [int(p) for p in input().split()]
	if e == 0:
		if s > i:
			print(1)
			continue
		else:
			print(0)
			continue
	x = max(0, ceil((i + e - s + 1) / 2))
	print(max(e - x + 1, 0))


import math

def get_n(charactor):
	(S, I, P) = charactor
	low = max(0, math.ceil((I - S + P + 0.01) / 2))
	if P == 0 and S > I:
		return 1
	else:
		return len(range(low, P + 1))
T = int(input())
for i in range(T):
	charactor = map(int, input().split())
	print(get_n(charactor))


for _ in [0] * int(input()):
	(s, i, e) = map(int, input().split())
	print(max(0, min(e + 1, (s + i + e + 1) // 2 - i)))


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
for j in range(int(input())):
	(str1, int1, exp1) = map(int, input().split())
	original = exp1
	diff = str1 - int1
	exp1 += diff
	if exp1 > 0:
		print(min(math.ceil(exp1 / 2), original + 1))
	else:
		print(0)


for i in range(int(input())):
	(s, i, e) = map(int, input().split())
	m = max(0, (e + i - s + 2) // 2)
	print(max(0, e - m + 1))


import sys
import math
from collections import defaultdict
input = lambda : sys.stdin.readline().rstrip()
for t in range(int(input())):
	(s, i, e) = map(int, input().split())
	x = (i + e - s) / 2
	if x < 0:
		print(e + 1)
	elif x == 0:
		print(e)
	elif x >= e:
		print(0)
	else:
		print(e - int(x))


from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
import math

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

def fun(x):
	return sum((int(i) for i in str(x)))

def find(n):
	if n == 3:
		return 3
	while 1:
		flag = 0
		for i in range(2, int(sqrt(n)) + 1):
			if n % i == 0:
				n += 1
				break
			if i == int(sqrt(n)):
				flag = 1
				break
		if flag:
			break
	return n
t = int(input())
for _ in range(t):
	(s, i, exp) = sp()
	l = 0
	r = exp
	mid = l + r >> 1
	ans = 0
	if not exp and s > i:
		print(1)
	elif not exp:
		print(0)
	else:
		ans = max((exp + i - s + 2) / 2, 0)
		print(max(exp - int(ans) + 1, 0))


from math import *
a = int(input())
for i in range(a):
	b = [int(i) for i in input().split()]
	c = b[0] + b[2]
	d = b[1]
	if b[2] == 0 and c > d:
		print(1)
	elif c - d > 0:
		if ceil((c - d) / 2) > b[2] + 1:
			print(b[2] + 1)
		else:
			print(ceil((c - d) / 2))
	else:
		print(0)


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


n = int(input())
for i in range(n):
	su = 0
	(s, it, e) = [int(i) for i in input().split()]
	su = (s + it + e + 2) // 2
	su = e - (su - s) + 1
	if su > e:
		su = e + 1
	if su < 0:
		su = 0
	print(su)


from math import ceil
for _ in range(int(input())):
	(strength, intelligence, free_exp) = map(int, input().split())
	ans = 0
	i = (free_exp + intelligence - strength) / 2
	if i < 0:
		ans = free_exp + 1
	else:
		ans = ceil(free_exp - i)
		if ans < 0:
			ans = 0
	print(ans)


def solve():
	lst = set()
	(s, i, e) = map(int, input().split())
	(l, r) = (0, e)
	while l <= r:
		mid = (l + r) // 2
		(a1, a2) = (mid, e - mid)
		(a11, a22) = (s + a1, i + a2)
		if a11 > a22:
			lst.add((a11, a22))
			r = mid - 1
		else:
			l = mid + 1
	if s + e > i:
		lst.add((s + e, i))
	lst = list(sorted(lst))
	if len(lst) > 0:
		return lst[-1][0] - lst[0][0] + 1
	return 0
t = int(input())
for _ in range(0, t):
	print(solve())


t = int(input())
for i in range(t):
	(s, i, e) = map(int, input().split())
	mas = max(0, (e + i - s + 2) // 2)
	print(max(0, e - mas + 1))


import math
t = int(input())
for i in range(t):
	cnt = 0
	l = input().split(' ')
	s = int(l[0])
	intel = int(l[1])
	exp = int(l[2])
	dif = s + exp - intel
	if exp == 0 and dif > 0:
		print(1)
	else:
		print(min(max(math.floor((dif + 1) / 2), 0), exp + 1))


T = int(input())
for _ in range(T):
	(Str, Int, Exp) = map(int, input().split())
	if Str == Int:
		result = int(Exp / 2) if Exp % 2 == 0 else int(Exp / 2 + 1)
		print('{}'.format(result))
	elif Str < Int:
		diff = Int - Str + 1
		Str += diff
		Exp -= diff
		if Exp < 0:
			print(0)
		else:
			result = int(Exp / 2 + 1)
			print('{}'.format(result))
	else:
		diff = Str - Int - 1
		Int += diff
		Exp -= diff
		if Exp < 0:
			print(diff + Exp + 1)
		else:
			result = diff + int(Exp / 2 + 1)
			print('{}'.format(result))


import math
for i in range(int(input())):
	(st, ins, exp) = map(int, input().split())
	a = (ins + exp - st + 2) // 2
	b = max(0, a)
	print(max(0, exp - b + 1))


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


t = int(input())
while t > 0:
	(s, i, n) = map(int, input().split())
	if s > i:
		d = s - i
		if n > d:
			v = int((n - d) / 2)
			print(n - v)
		elif n == d:
			print(n)
		else:
			print(n + 1)
	else:
		d = i - s
		v = int((n + d) / 2)
		if n > d:
			print(n - v)
		else:
			print(0)
	t -= 1


TT = int(input())
from math import ceil
for T in range(TT):
	(s, i, e) = [int(x) for x in input().split()]
	vals = (i + e - s) / 2
	valsalso = vals - e - s
	if vals > e:
		print(0)
	elif vals < 0:
		print(e + 1)
	elif vals > int(vals):
		print(e + 1 - ceil(vals))
	else:
		print(int(e - vals))


q = int(input())
for _ in range(q):
	(st, it, ex) = map(int, input().split())
	min_add = max(0, (it + ex - st + 2) // 2)
	ans = max(ex - min_add + 1, 0)
	print(ans)


for _ in range(int(input())):
	(s, i, e) = map(int, input().split())
	(lo, hi, res) = (0, e, 0)
	if s + e <= i:
		print(0)
		continue
	while lo <= hi:
		mi = (lo + hi) // 2
		if s + mi > i + (e - mi):
			res = mi
			hi = mi - 1
		else:
			lo = mi + 1
	print(e - res + 1)


for T in range(int(input())):
	(st, it, exp) = [int(x) for x in input().split()]
	from math import ceil
	x = (it + exp - st) / 2
	if x > exp:
		print(0)
	elif x < 0:
		print(exp + 1)
	elif x > int(x):
		print(exp + 1 - ceil(x))
	else:
		print(int(exp - x))


from sys import stdin
n = int(stdin.readline().strip())

def f(s, i, e):
	x = i - s + e
	if x % 2 == 0:
		ans = x // 2
		ans += 1
	else:
		ans = x // 2
		ans += 1
	return ans
for i in range(n):
	(s, i, e) = map(int, stdin.readline().strip().split())
	y = f(s, i, e)
	y = max(y, 0)
	print(max(e - y + 1, 0))


import math
tc = int(input())
for _ in range(tc):
	line = input().split()
	intel = int(line[1])
	exp = int(line[2])
	strength = int(line[0])
	if strength > intel + exp:
		print(exp + 1)
	elif strength + exp < intel:
		print(0)
	elif strength < intel:
		print(math.ceil((exp - abs(intel - strength)) / 2))
	else:
		print(math.ceil((exp - abs(intel - strength)) / 2) + abs(intel - strength))


for q in range(int(input())):
	dat = [int(i) for i in input().split()]
	v = dat[0] + dat[2] - dat[1] + 1
	print(max(0, min(v // 2, dat[2] + 1)))


import sys
input = sys.stdin.readline
t = int(input())
for ll in range(t):
	(sl, il, ex) = map(int, input().split())
	minads = max(0, (ex + il - sl + 2) // 2)
	print(max(0, ex - minads + 1))


n = int(input())
for i in range(0, n):
	line = input()
	line = line.split()
	s = int(line[0])
	i = int(line[1])
	e = int(line[2])
	maxs = 0
	dif = i - s
	nos = 0
	if dif >= 0:
		e = e - dif
		if e <= 0:
			nos = 0
		else:
			s = s + dif
			maxs = s + e
			dif = e // 2
			dif2 = e - dif
			s = s + dif2
			i = i + dif
			if s <= i:
				nos = maxs - s
			else:
				nos = maxs - s + 1
	else:
		ogs = s
		maxs = s + e
		dif = e // 2
		dif2 = e - dif
		s = s + dif2
		i = i + dif
		xtra = s - i
		dif = xtra // 2
		s = s - dif
		i = i + dif
		if s < ogs:
			nos = maxs - ogs + 1
		elif s == i:
			nos = maxs - s
		else:
			nos = maxs - s + 1
	print(nos)


t = int(input())
for test in range(t):
	(a, b, c) = list(map(int, input().split()))
	if a <= b:
		c -= b - a + 1
		a = b + 1
	ans = 0
	if c < 0:
		print(0)
	elif c == 0:
		print(1)
	elif b + c < a:
		print(c + 1)
	else:
		tmp = (b + c - a + 2) // 2
		print(c - tmp + 1)


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


from bisect import bisect_left as bl
from collections import defaultdict as dd
for _ in range(int(input())):
	(a, b, c) = [int(i) for i in input().split()]
	ans = c - (c + b - a) // 2
	print(max(0, min(ans, c + 1)))


t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	if m >= n + k:
		print(0)
	else:
		l = 0
		r = k
		while l <= r:
			mid = (l + r) // 2
			if mid + m < n + (k - mid):
				l = mid + 1
				ans = mid + 1
			else:
				r = mid - 1
		print(ans)


t = int(input())
while t > 0:
	(s, i, exp) = map(int, input().split())
	ans = -1
	if s < i:
		if i - s + 1 > exp:
			ans = 0
		else:
			exp = exp - (i - s + 1)
			s += i - s + 1
	if exp == 0 and s > i:
		ans = 1
	if ans == -1:
		d = s - i
		D = (exp - d) // 2 + 1
		if D < 0:
			D = 0
		ans = exp + 1 - D
	print(ans)
	t -= 1


from sys import stdin, stdout
outputs = []
for __ in range(int(stdin.readline().strip())):
	(a, b, c) = map(int, stdin.readline().strip().split())
	if c == 0:
		if a > b:
			outputs.append(1)
		else:
			outputs.append(0)
	else:
		r = c + 1
		l = 0
		while l + 1 < r:
			m = (l + r) // 2
			if a + m > b + (c - m):
				r = m
			else:
				l = m
		outputs.append(c - r + 1 + (1 if a > b + c else 0))
for output in outputs:
	stdout.write(f'{output}\n')


import math
t = int(input())
for j in range(t):
	(s, i, e) = map(int, input().split())
	print(max(min(s - i + e - (s - i + e) // 2, e + 1), 0))


import math
a = int(input())
for i in range(a):
	(str1, int1, exp) = map(int, input().split())
	if exp == 0:
		if str1 <= int1:
			print('0')
		else:
			print('1')
	else:
		print(min(exp + 1, max(0, 1 + (str1 - int1 + exp) // 2))) if (str1 - int1 + exp) % 2 != 0 else print(min(exp + 1, max(0, (str1 - int1 + exp) // 2)))


def main():
	T = int(input())
	for i in range(T):
		(a, b, c) = input().split()
		(a, b, c) = (int(a), int(b), int(c))
		ans = (a + c - b + 1) // 2
		ans = max(ans, 0)
		ans = min(ans, c + 1)
		print(ans)
main()


n = int(input())
for i in range(n):
	inp = input().split()
	str = int(inp[0])
	intel = int(inp[1])
	exp = int(inp[2])
	diff = str + exp - intel
	if exp == 0 and diff > 0:
		print(1)
	elif exp == 0 and diff <= 0:
		print(0)
	elif diff > 0:
		if diff % 2 == 0:
			max_d = int(diff / 2)
		elif diff % 2 == 1:
			max_d = int(diff // 2 + 1)
		ans = min(exp, max_d)
		if exp < max_d:
			ans += 1
		print(ans)
	else:
		print(0)


def ans(s, i, e):
	if e == 0:
		if s > i:
			return 1
		return 0
	if s < i:
		d = min(i - s, e)
		s += d
		e -= d
		return ans(s, i, e)
	if s > i:
		d = min(s - i, e)
		i += d
		e -= d
		return ans(s, i, e) + d
	return (e + 1) // 2
n = int(input())
for k in range(n):
	line = [int(x) for x in input().split()]
	strength = line[0]
	intel = line[1]
	expr = line[2]
	print(ans(strength, intel, expr))


import math

def calc(a, b, exp):
	if exp < 0:
		return 0
	if exp == 0:
		if a > b:
			return 1
		else:
			return 0
	if a > b:
		t = math.ceil((a + b + exp) / 2) - 1
		ans = a + exp - t
		if (a + b + exp) % 2 == 0:
			ans -= 1
		if a + b + exp - t < a:
			ans -= a - (a + b + exp - t)
		return ans
	if a < b:
		return calc(b, b, exp - (b - a))
	if a == b:
		return calc(a + 1, b, exp - 1)
T = int(input())
while T:
	(a, b, exp) = [int(x) for x in input().split()]
	print(calc(a, b, exp))
	T -= 1


n = int(input())
for i in range(n):
	(a, b, c) = [int(x) for x in input().split()]
	l = 0
	r = c
	while r - l > 1:
		mid = (l + r) // 2
		if a + mid > b + c - mid:
			r = mid
		else:
			l = mid
	if a > b + c:
		print(c + 1)
	elif a + r > b + c - r:
		print(c - r + 1)
	else:
		print(0)


for _ in range(int(input())):
	(stri, inti, expi) = [int(i) for i in input().split()]
	cond = (expi - (stri - inti) + 1) // 2 + (expi - (stri - inti) + 1) % 2
	cond = max(cond, 0)
	print(max(expi - cond + 1, 0))


t = int(input())
for _ in range(t):
	(s, i, e) = map(int, input().split())
	ans = 0
	zz = s
	s += e
	if s <= i:
		ans = 0
	else:
		if (s - i) % 2 == 0:
			ans = (s - i) // 2
		else:
			ans = (s - i) // 2 + 1
		if e == 0:
			ans = 1
		else:
			ans = min(s - zz + 1, ans)
			if ans == 0:
				ans = 1
	print(ans)


from math import *
t = int(input())
for z in range(t):
	(s, i, re) = map(int, input().split())
	e = re - (i - s)
	re += 1
	if e <= 0:
		print(0)
		continue
	print(min(ceil(e / 2), re))


n = int(input())
for _ in range(n):
	(str, int_, exp) = map(int, input().split())
	sum = str + int_ + exp
	int_max = (sum - 1) // 2
	print(max(min(int_max - int_ + 1, exp + 1), 0))


def person(s, w, f):
	if s + f <= w:
		return 0
	elif w + f < s:
		return f + 1
	else:
		temp = s + f - w
		if temp % 2 == 0:
			return temp // 2
		else:
			return (temp + 1) // 2
t = int(input())
for j in range(t):
	(s, i, e) = [int(x) for x in input().split()]
	print(person(s, i, e))


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

def ss():
	return [x for x in input()]

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

def mi():
	return map(int, input().split())
t = ii()
for i in range(t):
	(a, b, c) = mi()
	a += c
	if a > b:
		print(min((a - b - 1) // 2 + 1, c + 1))
	else:
		print(0)


import math

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

def mi():
	return map(int, input().split())
T = ii()
for _ in range(T):
	(s, i, e) = mi()
	ans = math.ceil((s + e - i) / 2)
	if ans < 0:
		print(0)
	elif ans > e:
		print(e + 1)
	else:
		print(ans)


T = int(input())
for tc in range(T):
	(s, t, e) = map(int, input().split())
	sol = int((t - s + e) // 2)
	if e == 0:
		if s > t:
			print(1)
		else:
			print(0)
	elif sol < 0:
		print(e + 1)
	elif sol > e:
		print(0)
	else:
		print(e - sol)


for _ in range(int(input())):
	(s, i, e) = map(int, input().split())
	if e == 0:
		if s > i:
			print(1)
			continue
		else:
			print(0)
			continue
	if s + e > i:
		invest_x = (i - s + e) // 2
		startFrom = invest_x + 1
		if invest_x < 0:
			print(e + 1)
		else:
			print(e - startFrom + 1)
	else:
		print(0)


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


t = int(input())
for j in range(t):
	t = input().split(' ')
	f = int(t[0])
	i = int(t[1])
	e = int(t[2])
	if f + e <= i:
		print(0, end='\n')
	else:
		if f <= i:
			e -= i - f + 1
			f = i + 1
		a = max(0, (i + e - f) // 2 + 1)
		print(e - a + 1, end='\n')


from sys import stdin, stdout
import heapq
import cProfile, math
from collections import Counter, defaultdict, deque
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
import operator as op
from functools import reduce
import sys
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
fac_warm_up = False
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7

class MergeFind:

	def __init__(self, n):
		self.parent = list(range(n))
		self.size = [1] * n
		self.num_sets = n
		self.lista = [[_] for _ in range(n)]

	def find(self, a):
		to_update = []
		while a != self.parent[a]:
			to_update.append(a)
			a = self.parent[a]
		for b in to_update:
			self.parent[b] = a
		return self.parent[a]

	def merge(self, a, b):
		a = self.find(a)
		b = self.find(b)
		if a == b:
			return
		if self.size[a] < self.size[b]:
			(a, b) = (b, a)
		self.num_sets -= 1
		self.parent[b] = a
		self.size[a] += self.size[b]
		self.lista[a] += self.lista[b]

	def set_size(self, a):
		return self.size[self.find(a)]

	def __len__(self):
		return self.num_sets

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def prime_factors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def all_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 fibonacci_modP(n, MOD):
	if n < 2:
		return 1
	return (cached_fn(fibonacci_modP, (n + 1) // 2, MOD) * cached_fn(fibonacci_modP, n // 2, MOD) + cached_fn(fibonacci_modP, (n - 1) // 2, MOD) * cached_fn(fibonacci_modP, (n - 2) // 2, MOD)) % MOD

def factorial_modP_Wilson(n, p):
	if p <= n:
		return 0
	res = p - 1
	for i in range(n + 1, p):
		res = res * cached_fn(InverseEuler, i, p) % p
	return res

def binary(n, digits=20):
	b = bin(n)[2:]
	b = '0' * (digits - len(b)) + b
	return b

def is_prime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

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

def warm_up_fac(MOD):
	global factorial_modP, fac_warm_up
	if fac_warm_up:
		return
	factorial_modP = [1 for _ in range(fac_warm_up_size + 1)]
	for i in range(2, fac_warm_up_size):
		factorial_modP[i] = factorial_modP[i - 1] * i % MOD
	fac_warm_up = True

def InverseEuler(n, MOD):
	return pow(n, MOD - 2, MOD)

def nCr(n, r, MOD):
	global fac_warm_up, factorial_modP
	if not fac_warm_up:
		warm_up_fac(MOD)
		fac_warm_up = True
	return factorial_modP[n] * (pow(factorial_modP[r], MOD - 2, MOD) * pow(factorial_modP[n - r], MOD - 2, MOD) % MOD) % MOD

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def display_2D_list(li):
	for i in li:
		print(i)

def prefix_sum(li):
	sm = 0
	res = []
	for i in li:
		sm += i
		res.append(sm)
	return res

def get_int():
	return int(stdin.readline().strip())

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

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result

def ncr(n, r):
	return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

def binary_search(i, li):
	fn = lambda x: li[x] - x // i
	x = -1
	b = len(li)
	while b >= 1:
		while b + x < len(li) and fn(b + x) > 0:
			x += b
		b = b // 2
	return x
TestCases = True
fac_warm_up_size = 10 ** 5 + 100
optimise_for_recursion = False

def main():
	(s, i, e) = get_tuple()
	print(min(max(0, (s + e + 1 - i) // 2), e + 1))
if TestCases:
	for i in range(get_int()):
		main()
else:
	main() if not optimise_for_recursion else threading.Thread(target=main).start()


for _ in range(int(input())):
	line = tuple(map(int, input().split()))
	(_str, _int, _exp) = line
	if _int - _str >= _exp:
		print(0)
	else:
		diff = _str + _exp - _int
		tmp = (diff + 1) // 2
		result = tmp if tmp <= _exp + 1 else _exp + 1
		print(result)


N = int(input())
for i in range(N):
	(s, n, e) = list(map(int, input().split()))
	if e == 0:
		if s > n:
			print(1)
		else:
			print(0)
		continue
	s += e
	if s - n > 0 and s - n <= 2 * e:
		print((s - n) // 2 + (s - n) % 2)
	elif s - n > 2 * e:
		print(e + 1)
	else:
		print(0)


for q in range(int(input())):
	(x, y, z) = map(int, input().split())
	if x <= y:
		z -= y - x + 1
		if z < 0:
			print(0)
		else:
			print(z // 2 + 1)
	elif z < x - y:
		print(z + 1)
	else:
		z -= x - y + 1
		print(x - y + z // 2 + 1)


from math import *
t = int(input())
for _ in range(t):
	(s, i, e) = list(map(int, input().split(' ')))
	temp = int(ceil((e + (s - i)) / 2))
	if temp > e:
		print(e + 1)
	elif temp < 0:
		print(0)
	else:
		print(temp)


import sys
import math
import bisect

def solve(a, b, c):
	if c + a <= b:
		return 0
	if b + c < a:
		min_val = a
	else:
		tmp = a + b + c
		if tmp % 2 == 0:
			min_val = 2 + (tmp - 2) // 2
		else:
			min_val = (tmp + 1) // 2
	max_val = a + c
	return max_val - min_val + 1

def main():
	for _ in range(int(input())):
		(a, b, c) = map(int, input().split())
		ans = solve(a, b, c)
		print(ans)
main()


t = int(input())
for i in range(t):
	(a, b, n) = map(int, input().split())
	print(min(max((a - b + n + 1) // 2, 0), n + 1))


import math
q = int(input())
for i in range(q):
	(s, i, f) = map(int, input().split())
	d = i - s
	x = (f - d - 1) // 2
	print(min(max(x + 1, 0), f + 1))


import math
for i in range(int(input())):
	a = str(input())
	a = a.split(' ')
	stre = a[0]
	inte = a[1]
	exp = a[2]
	st = int(stre)
	intel = int(inte)
	expe = int(exp)
	if expe + st <= intel:
		print(0)
	elif expe + st > intel:
		if st < intel:
			a = st + expe
			b = a - intel
			b = float(b / 2)
			print(math.ceil(b))
		if st > intel + expe:
			print(expe + 1)
		elif st >= intel:
			a = st + expe
			b = a - intel
			b = float(b / 2)
			print(math.ceil(b))


import math
import sys
from heapq import heappop
from heapq import heappush
from heapq import heapify
from bisect import insort
from sys import stdin, stdout
from collections import defaultdict
inp = lambda : int(stdin.readline())
sip = lambda : input()
mulip = lambda : map(int, input().split())
lst = lambda : list(map(int, stdin.readline().split()))
slst = lambda : list(sip())
arr2d = lambda x: [[int(j) for j in input().split()] for i in range(x)]
odds = lambda l: len(list(filter(lambda x: x % 2 != 0, l)))
evens = lambda l: len(list(filter(lambda x: x % 2 == 0, l)))
mod = pow(10, 9) + 7
for _ in range(inp()):
	(s, i, x) = mulip()
	ans = max(0, min((s - i + x + 1) // 2, x + 1))
	print(ans)


import math
t = int(input())
while t > 0:
	t -= 1
	(a, b, c) = map(int, input().split())
	val = b + c - a
	val /= 2
	ans = math.floor(val)
	if ans < 0:
		ans = -1
	value = c - ans
	if value >= 0:
		print(int(value))
	else:
		print(int(0))


d = int(input())
for _ in range(d):
	(strong, inta, expa) = map(int, input().split())
	if expa == 0:
		if strong > inta:
			print(1)
		else:
			print(0)
	elif strong + expa <= inta:
		print(0)
	elif strong > expa + inta:
		print(expa + 1)
	else:
		sr = strong + inta + expa
		print(strong + expa - sr // 2)


from sys import stdin

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

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

def li():
	return list(mi())

def si():
	return stdin.readline()
for _ in range(ii()):
	(a, b, c) = mi()
	if a > b:
		p = a - b
		k = c
		c -= p
		c = (c + 1) // 2
		p = min(k + 1, p + c)
		p = max(1, p)
	else:
		p = b - a
		c -= p
		p = max(0, (c + 1) // 2)
	print(p)


def char(s, i, exp):
	dif = s - i
	r = exp
	l = 0
	ans = None
	while r >= l:
		m = l + (r - l) // 2
		mreal = exp * -1 + m * 2
		if mreal + dif > 0:
			r = m - 1
			ans = m
		else:
			l = m + 1
	if ans == None:
		if dif > 0:
			return 1
		return 0
	return exp + 1 - ans
T = int(input())
for _ in range(T):
	(s, i, exp) = map(int, input().split())
	print(char(s, i, exp))


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

def read_list():
	return list(map(int, input().split(' ')))
t = read_int()
for _ in range(t):
	(strength, intelligence, exp) = read_list()
	if exp == 0:
		if strength > intelligence:
			print(1)
		else:
			print(0)
		continue
	initial_diff = strength - intelligence
	if initial_diff > exp:
		print(exp + 1)
		continue
	min_strength_upgrade = int((exp - initial_diff) / 2) + 1
	possible_chars = exp - min_strength_upgrade + 1
	print(max(possible_chars, 0))


import math
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	if a >= b:
		c2 = c - (a - b)
		if c2 < 0:
			minA = a
		else:
			b2 = a + c2 // 2
			a2 = a + c2 - c2 // 2
			if a2 == b2:
				a2 += 1
			minA = a2
	else:
		c2 = c - (b - a)
		if c2 <= 0:
			minA = b + 1
		else:
			b2 = b + c2 // 2
			a2 = b + c2 - c2 // 2
			if a2 == b2:
				a2 += 1
			minA = a2
	print(max(0, a + c - minA + 1))


for _ in range(int(input())):
	(s, i, e) = list(map(int, input().strip().split()))
	if s + e <= i:
		ans = 0
	elif e == 0:
		ans = 1
	else:
		upper = s + e
		buper = (s + e + i) // 2
		if s > buper:
			king = s - 1
		else:
			king = buper
		ans = upper - king
	print(ans)


for k in range(int(input())):
	(s, i, n) = map(int, input().split())
	if n == 0:
		if s > i:
			print(1)
		else:
			print(0)
	else:
		print(min(n + 1, max(0, n - (i + n - s) // 2)))


for _ in range(int(input())):
	(s, i, e) = list(map(int, input().split()))
	c = 0
	if s > i:
		if i + e < s:
			c += e + 1
		else:
			t1 = s + e
			t2 = t1 - i
			if t2 % 2 != 0:
				c += t2 // 2 + 1
			else:
				c += t2 // 2
	elif s + e > i:
		t1 = i - s
		s += t1
		e -= t1
		if e % 2 != 0:
			c += e // 2 + 1
		else:
			c += e // 2
	print(c)


t = int(input())
for _ in range(t):
	(st, br, e) = [int(x) for x in str(input()).split()]
	if st + e <= br:
		print(0)
	elif br + e < st:
		print(e + 1)
	elif st > br:
		ans = e - (e + br - st) // 2
		print(ans)
	else:
		diff = br - st
		st = br + 1
		e = e - (diff + 1)
		ans = e - (e + br - st) // 2
		print(ans)


T = int(input())
for t in range(T):
	(strength, intellect, experience) = map(int, input().split())
	strength += experience + 1
	a = max(0, strength - intellect) // 2
	print(min(a, experience + 1))


import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
sys.setrecursionlimit(100000)
input = sys.stdin.readline

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

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

def read_float():
	return float(input())

def read_float_n():
	return list(map(float, input().split()))

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

def read_str_n():
	return list(map(str, input().split()))

def error_print(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		error_print(e - s, 'sec')
		return ret
	return wrap

def slv2(S, I, E):
	ans = 0
	for i in range(0, E + 1):
		if S + i > I + (E - i):
			ans += 1
	return ans

def slv(S, I, E):
	z = S - I + E
	if z < 0:
		return 0
	return min(math.ceil(z / 2), E + 1)

def main():
	N = read_int()
	for _ in range(N):
		(S, I, E) = read_int_n()
		print(slv(S, I, E))
main()


n = int(input())
for i in range(n):
	s = input().split()
	(st, il, exp) = (int(s[0]), int(s[1]), int(s[2]))
	if st + exp <= il:
		print(0)
	elif exp == 0:
		print(1)
	elif il + exp >= st:
		print((st + exp - il) // 2 + (st + exp - il) % 2)
	else:
		print(exp + 1)


t = int(input())
for test in range(t):
	(stre, intel, expe) = map(int, input().split())
	c = 1
	a = max(0, (expe + intel - stre + 2) // 2)
	print(max(expe - a + 1, 0))


from sys import stdin, stdout

def bsearch(s, i, f, l, r, tmp):
	if l > r:
		return str(tmp)
	mid = (l + r) // 2
	if s + mid > i + (f - mid):
		tmp = max(tmp, f - mid + 1)
		return bsearch(s, i, f, l, mid - 1, tmp)
	else:
		return bsearch(s, i, f, mid + 1, r, tmp)
stdout.write('\n'.join([(lambda s, i, f: bsearch(s, i, f, 0, f, 0))(*map(int, stdin.readline().split())) for i in range(int(stdin.readline()))]))


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


def solve(first, second):
	found = False
	count = 0
	while not found and first <= e:
		if s + first > i + second:
			count = e - first + 1
			found = True
		else:
			first += 1
			second -= 1
	return count
t = int(input())
for _ in range(t):
	(s, i, e) = map(int, input().split())
	count = 0
	first = 0
	second = e
	if e <= 1000:
		count = solve(first, second)
	else:
		found = False
		while not found and first <= e:
			if s + first > i + second:
				found = True
			else:
				first += 1000
				second -= 1000
		first = max(0, first - 1000)
		count = solve(first, e - first)
	print(count)


t = int(input())
for _ in range(t):
	(s, i, e) = map(int, input().split())
	half = (s + i + e) // 2
	maxeven = half + 1
	maxeven = max(maxeven, s)
	print(max(s + e - maxeven + 1, 0))


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 i in range(t):
	(a, b, c) = invr()
	print(max(0, c - max(0, math.ceil((c + b - a + 1) / 2)) + 1))


T = int(input())
for i in range(T):
	[strength, intelligence, experience] = [int(x) for x in input().split()]
	k = strength - intelligence
	s = (k + experience) / 2
	p = int(s)
	if k + experience <= 0:
		print(0)
	elif p == s:
		print(min(p, experience + 1))
	else:
		print(min(p + 1, experience + 1))


t = int(input())
import math
while t > 0:
	t -= 1
	(str_, int_, exp) = map(int, input().split())
	print(max(min((str_ + exp - int_ + 1) // 2, exp + 1), 0))


class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	(s, i, e) = Read.list_int()
	f = max(e - (i - s), 0)
	if f % 2 == 0:
		r = f // 2
	else:
		r = f // 2 + 1
	print(min(r, e + 1))
query_count = Read.int()
for j in range(query_count):
	solve()


import math

def f(s, i, e):
	if e == 0:
		return 1 if s > i else 0
	value = math.ceil((s - i + e) / 2)
	return len(range(0, e + 1 if value > e else value))
n = int(input())
for a in range(n):
	(s, i, e) = map(int, input().split())
	print(f(s, i, e))


t = int(input())
while t > 0:
	t -= 1
	(s, i, e) = list(map(int, input().split()))
	ans = max(0, s + e - max(s, (i + s + e) // 2 + 1) + 1)
	print(ans)


t = int(input())
while t > 0:
	c = 0
	start = 0
	(s, i, e) = list(map(int, input().split()))
	if e == 0:
		if s > i:
			print(1)
			t -= 1
			continue
		else:
			print(0)
			t -= 1
			continue
	if s + e > i:
		x = (i - s + e) // 2
		k = x + 1
		if x < 0:
			print(e + 1)
		else:
			print(e - k + 1)
	else:
		print(0)
	t -= 1


def mi():
	return map(int, input().split())
for _ in range(int(input())):
	(s, i, x) = mi()
	(l, h, ans) = (0, x, -1)
	while l <= h:
		mid = (l + h) // 2
		if s + mid <= i + (x - mid):
			l = mid + 1
		else:
			h = mid
			ans = mid
			if l == h:
				break
	if ans != -1:
		print(x - ans + 1)
	elif x == 0:
		if s > i:
			print(1)
		else:
			print(0)
	else:
		print(0)


for _ in range(int(input())):
	(a, b, p) = map(int, input().split())
	print(max(0, p - max(0, (b + p - a + 2) // 2) + 1))


def bs(s, i, e):
	low = 0
	high = e + 1
	while low < high:
		mid = (low + high) // 2
		if s - mid > i + mid:
			low = mid + 1
		else:
			high = mid
	return low
t = int(input())
output = ''
for _ in range(t):
	(s, i, e) = [int(x) for x in input().split(' ')]
	s += e
	output += f'{bs(s, i, e)}\n'
print(output)


import math
n = int(input())
for _ in range(n):
	(s, i, j) = map(int, input().split())
	k = s - i
	k += 1
	ans = (j + k) // 2
	if ans < 0:
		ans = 0
	print(min(ans, j + 1))


from math import ceil
for _ in range(int(input())):
	(Str, Brain, Exp) = map(int, input().split())
	if Str > Brain:
		Str += Exp
		X = ceil((Str - Brain) / 2)
		print(min(Exp + 1, int(X)))
	elif Str == Brain:
		print(int(ceil(Exp / 2)))
	else:
		Upto = Brain - Str
		if Exp > Upto:
			Str += Upto
			Exp -= Upto
			print(int(ceil(Exp / 2)))
		else:
			print(0)


n = int(input())
ans = []
for i in range(n):
	(s, i, e) = map(int, input().split())
	if i - s >= e:
		k = 0
		ans.append(k)
	elif e == 0:
		ans.append(1)
	elif s >= i:
		k = 1
		s += e
		if (s - i) // 2 <= e:
			k += (s - i) // 2
			if (s - i) % 2 == 0:
				k -= 1
		else:
			k += e
		ans.append(k)
	elif i > s:
		k = 1
		s += e
		if (s - i) // 2 <= e:
			k += (s - i) // 2
			if (s - i) % 2 == 0:
				k -= 1
		else:
			k += e
		ans.append(k)
for i in ans:
	print(i)


t = int(input())
for _ in range(t):
	(s, i, e) = map(int, input().split())
	if s > i:
		q = s - i + e
		z = q / 2
		if z == int(z):
			print(min(int(z), e + 1))
		else:
			print(min(int(z) + 1, e + 1))
	else:
		v = i - s + 1
		if v <= e:
			e = e - v
			s = s + v
			q = s - i + e
			z = q / 2
			if z == int(z):
				print(min(int(z), e + 1))
			else:
				print(min(int(z) + 1, e + 1))
		else:
			print(0)


t = int(input())
while t:
	(a, b, k) = map(int, input().split())
	ans = (b - a + k) // 2
	d = k - ans
	if d > k + 1:
		print(k + 1)
	elif d < 0:
		print('0')
	else:
		print(d)
	t -= 1


def rint():
	return int(input())

def rints():
	return list(map(int, input().split()))
t = rint()
for _ in range(t):
	(s, i, e) = rints()
	if e == 0:
		print(1 if s > i else 0)
		continue
	e -= max(0, i - s + 1)
	s = max(s, i + 1)
	if e < 0:
		print(0)
		continue
	to_int = min(s - 1 - i, e)
	to_int += (e - to_int) // 2
	print(to_int + 1)


cases = int(input())
for case in range(cases):
	(a, b, n) = map(int, input().split())
	d = a - b
	k = (n - d) // 2 + 1
	k = max(k, 0)
	ans = max(0, n - k + 1)
	print(ans)


T = int(input())
for i in range(T):
	(s, i, e) = list(map(int, input().split()))
	if s > i + e:
		a = e + 1
	else:
		a = min((s + e - i - 1) // 2 + 1, e)
	if a <= 0:
		print(0)
	else:
		print(a)


import math
t = int(input())
for _ in range(t):
	(str1, int1, exp1) = list(map(int, input().split()))
	if exp1 == 0:
		if str1 > int1:
			print(1)
		else:
			print(0)
	else:
		ans = (str1 - int1 + exp1) / 2
		if ans >= 0:
			print(min(exp1 + 1, math.ceil(ans)))
		else:
			print(0)


import math

def solve(s, i, e):
	if e == 0:
		return int(s > i)
	else:
		return max(e - max((i + e - s) // 2, -1), 0)
x = '4\n5 3 4\n2 1 0\n3 5 5\n4 10 6'
source = input
n = int(source())
for t in range(n):
	(s, i, e) = map(int, source().split())
	print(solve(s, i, e))
if False:
	solve(5, 3, 4)
	solve(2, 1, 0)
	solve(3, 5, 5)
	solve(4, 10, 6) == 0
	solve(4, 10, 7) == 1
	solve(6, 6, 0) == 0
	solve(7, 6, 0) == 1
	solve(7, 6, 1) == 1
	solve(8, 6, 1) == 1
	solve(8, 5, 2) == 3
	solve(3, 0, 2) == 3
	solve(4, 0, 2) == 3
	solve(3, 0, 0) == 1


from math import ceil
Q = int(input())
for q in range(Q):
	(s, i, e) = map(int, input().split())
	diff = i - s
	if diff >= e:
		print(0)
	elif diff >= 0:
		e = e - diff - 1
		s = s + diff + 1
		print(min((e + s - i + (e + s - i) % 2) // 2, e + 1))
	else:
		print(min((e + s - i + (e + s - i) % 2) // 2, e + 1))


import math
n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split(' '))
	m = max(0, (c + b - a + 2) / 2)
	print(math.ceil(max(c - m + 1, 0)))


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


q = int(input())
while q:
	(Str, Int, Exp) = map(int, input().split())
	Answer = 0
	if Str + Exp <= Int:
		print(0)
	else:
		left = 0
		right = Exp + 1
		while right - left > 1:
			mid = (right + left) // 2
			if Str + Exp - mid > Int + mid:
				left = mid
			else:
				right = mid
		print(left + 1)
	q -= 1


T = int(input())
for i in range(T):
	(S, I, E) = map(int, input().split())
	if S + E <= I:
		print(0)
		continue
	elif E == 0:
		print(1)
		continue
	elif S <= I:
		E -= I - S + 1
		S += I - S + 1
	if S <= I + E:
		print(E + 1 - ((I + E - S) // 2 + 1))
	else:
		print(E + 1)


T = int(input())
for i in range(T):
	(s, k, f) = map(int, input().split())
	print(min(f + 1, max(0, (s + f - k + 1) // 2)))


import sys
from collections import defaultdict as dd
from itertools import permutations as pp
from itertools import combinations as cc
from collections import Counter as ccd
from random import randint as rd
from bisect import bisect_left as bl
from heapq import heappush as hpush
from heapq import heappop as hpop
mod = 10 ** 9 + 7

def ri(flag=0):
	if flag == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())

def check(mid):
	temp1 = a + mid
	temp2 = b + (n - mid)
	if temp1 > temp2:
		return 1
	return 0
for _ in range(ri(1)):
	(a, b, n) = ri()
	let = n - (b + n - a) // 2
	if let > n + 1:
		let = n + 1
	print(max(0, let))


def main():
	T = int(input())
	for k in range(T):
		(s, i, e) = (int(d) for d in input().split(' '))
		(l, r) = (0, e + 7)
		builds = 0
		if s + e > i:
			builds = 1
		while l + 1 < r:
			m = (l + r) // 2
			if e - m >= 0 and s + e - m > i + m:
				l = m
			else:
				r = m
		builds += l
		print(builds)
main()


n = int(input())
answers = []
for i in range(n):
	(strr, intt, expp) = [int(x) for x in input().split()]
	answer = max(0, int((strr + expp - intt + 1) / 2))
	if answer > expp + 1:
		answer = expp + 1
	answers.append(answer)
for answer in answers:
	print(answer)


from math import *
a = int(input())
for i in range(a):
	(a, b, c) = map(int, input().split())
	ans = 0
	if a > b:
		d = a - b
		if d <= c:
			d += c
			ans = ceil(d / 2)
		elif c < d:
			ans = c + 1
	else:
		d = b - a
		if d < c:
			e = c - d
			ans = ceil(e / 2)
		else:
			ans = 0
	print(ans)


T = int(input())
for i in range(T):
	(Str, Int, exp) = map(int, input().split())
	ans = max(0, (exp + Int - Str + 2) / 2)
	ans = int(ans)
	print(max(0, exp - ans + 1))


from math import ceil
for _ in range(int(input().strip())):
	(s, i, e) = [int(i) for i in input().strip().split(' ')]
	ee = max(s, (s + i + e) // 2 + 1) - s
	print(max(e - ee + 1, 0))


for i in range(int(input())):
	(st, it, ex) = (int(s) for s in input().split())
	l = 0
	r = ex + 7
	ans = 0
	if st + ex > it:
		ans = 1
	while l + 1 < r:
		m = (l + r) // 2
		if ex - m >= 0 and st + ex - m > it + m:
			l = m
		else:
			r = m
	print(ans + l)


for _ in range(int(input())):
	(s, i, e) = map(int, input().split())
	x = max(-1, (e + i - s) // 2)
	print(max(0, e - x))


t = int(input())
for _ in range(t):
	(stri, inti, exp) = map(int, input().split())
	a = (inti + exp - stri) // 2
	if a < 0:
		a = -1
	print(max(0, exp - a))


n = int(input())

def get_ways(a, b, n):
	return max(0, n - max(0, (b + n - a) // 2 + 1) + 1)
for i in range(n):
	(strength, intel, exp) = [int(x) for x in input().split()]
	print(get_ways(strength, intel, exp))


from sys import stdin
from sys import setrecursionlimit as SRL
SRL(10 ** 7)
rd = stdin.readline
rrd = lambda : map(int, rd().strip().split())
T = int(input())
while T:
	(a, b, c) = rrd()
	print(max(0, a + c - max(a - 1, (a + c + b) // 2)))
	T -= 1


t = int(input())
for i in range(0, t):
	(st, it, ex) = map(int, input().split())
	r = (st + ex - it + 1) // 2
	if r > ex:
		r = ex + 1
	if r < 0:
		r = 0
	print(r)


import math

def main():
	T = int(input())
	for _ in range(T):
		(s, i, e) = [int(x) for x in input().split()]
		x = (i + e - s) // 2 + 1
		if x > e:
			print(0)
		elif x < 0:
			print(e + 1)
		else:
			print(e - x + 1)
main()


for q in range(int(input())):
	(s, i, e) = map(int, input().split())
	if s < i:
		if s + e <= i:
			print('0')
			continue
		e -= i - s
		s = i
	r = s - i
	if r > e:
		print(e + 1)
		continue
	print(e - ((e - r) // 2 + 1) + 1)


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


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


a = int(input())
for i in range(a):
	(r, c, d) = map(int, input().split(' '))
	m = max(0, (d + c - r + 2) // 2)
	print(max(0, d - m + 1))


def main():
	(strength, intelligence, exp) = map(int, input().split())
	print(max(0, exp - max(0, (exp + intelligence - strength + 2) // 2) + 1))
	return

def test():
	t = int(input())
	while t:
		main()
		t -= 1
test()


from math import ceil
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	count = 0
	if b >= a:
		if c < b - a:
			pass
		else:
			c = c - b + a
			if c == 0:
				pass
			else:
				count += ceil(c / 2)
	elif c < a - b:
		count += c + 1
	else:
		a += c
		count += ceil(abs(a - b) / 2)
	print(count)


t = int(input())
for case_num in range(t):
	(a, b, c) = map(int, input().split(' '))
	ans = c - (b - a + c) // 2
	print(max(min(ans, c + 1), 0))


import sys
from math import floor
test_case = int(sys.stdin.readline())
while test_case:
	test_case -= 1
	(tmp1, tmp2, tmp3) = sys.stdin.readline().rstrip().split()
	(strength, intele, xp) = (int(tmp1), int(tmp2), int(tmp3))
	strength += xp
	if strength <= intele:
		print(0)
		continue
	ans = min(floor((strength - intele) / 2), xp + 1)
	if ans != xp + 1:
		ans += 1 if (strength - intele) % 2 else 0
	print(ans)


import math
for w in range(int(input())):
	(s, t, e) = tuple(map(int, input().split()))
	if e == 0:
		if s > t:
			print(1)
		else:
			print(0)
	elif s > t:
		x = (t + e - s) // 2
		if x > 0:
			print(max(e - math.ceil(x), 0))
		elif x == 0:
			print(e)
		else:
			print(e + 1)
	else:
		if s - t + 1 > e:
			print(0)
		else:
			q = s - t + 1
			s += q
			e -= q
		x = (t + e - s) // 2
		if e == 0:
			if s > t:
				print(1)
			else:
				print(0)
		elif x > 0:
			print(max(e - math.ceil(x), 0))
		elif x == 0:
			print(e)
		else:
			print(e + 1)


import sys
import math
t = int(sys.stdin.readline())
for i in range(t):
	(a, b, e) = map(int, sys.stdin.readline().split())
	x = max(0, (b - a + e + 2) // 2)
	print(max(0, e - x + 1))


t = int(input())
for _ in range(t):
	(s, i, e) = map(int, input().split())
	ans = None
	if s + e <= i:
		ans = 0
	elif s <= i:
		e -= i - s
		ans = (e + 1) // 2
	else:
		ans = e + 1
		e -= s - i
		if e >= 0:
			ans -= (e + 2) // 2
	print(ans)


t = int(input())
l1 = []
for i in range(t):
	l2 = [int(a) for a in input().split()]
	a = l2[2] + l2[0]
	if a > l2[1]:
		b = int((a + l2[1]) / 2)
		if a - b <= l2[2] + 1:
			l1.append(a - b)
		else:
			l1.append(l2[2] + 1)
	else:
		l1.append(0)
for k in range(t):
	print(l1[k])


for _ in range(int(input())):
	(strength, intel, exp) = list(map(int, input().split()))
	if exp == 0:
		if strength > intel:
			print(1)
		else:
			print(0)
	elif strength + exp <= intel:
		print(0)
	else:
		x = (exp + intel - strength) // 2
		if x < 0:
			print(exp + 1)
		else:
			x += 1
			print(exp - x + 1)


T = int(input())
while T != 0:
	re = input()
	s = int(re.split(' ')[0])
	i = int(re.split(' ')[1])
	e = int(re.split(' ')[2])
	imp1 = max(0, (i + e - s + 2) // 2)
	print(max(0, e - imp1 + 1))
	T -= 1


import math
import sys
from collections import defaultdict
rt = lambda : map(int, input().split())
ri = lambda : int(input())
rl = lambda : list(map(int, input().split()))

def main():
	T = ri()
	for _ in range(T):
		(s, i, e) = rt()
		minx = (i - s + e) // 2 + 1
		if minx > e:
			ans = 0
		else:
			minx = max(0, minx)
			ans = e - minx + 1
		print(ans)
main()


def find(a, b, c):
	temp = b + c - a
	left = max(temp // 2, -1)
	return max(c - left, 0)
for _ in range(int(input())):
	(a, b, c) = list(map(int, input().strip().split(' ')))
	print(find(a, b, c))


def printRes(st, _in, _ex):
	max_val = (st + _in + _ex) // 2
	diff = st + _ex
	if diff - max_val < 0:
		return 0
	if st > max_val:
		return _ex + 1
	return diff - max_val
t = int(input())
for i in range(t):
	(st, _in, _ex) = [int(x) for x in input().split()]
	print(printRes(st, _in, _ex))


t = int(input())
while t:
	t -= 1
	(s, i, e) = map(int, input().split())
	mx = s + e
	dif = mx - i + 1
	if dif <= 0:
		print(0)
		continue
	print(max(0, min(e + 1, dif // 2)))


t = int(input(''))
import math
for q in range(t):
	ans = 0
	a = input('').split(' ')
	strn = int(a[0])
	ing = int(a[1])
	exp = int(a[2])
	if strn <= ing:
		if exp - strn + ing + 1 > 0:
			if exp - math.ceil((exp - strn + ing + 1) / 2) >= 0:
				ans = ans + exp - math.ceil((exp - strn + ing + 1) / 2) + 1
			else:
				ans = 0
	elif exp - strn + ing + 1 > 0:
		if exp - math.ceil((exp - strn + ing + 1) / 2) >= 0:
			ans = ans + exp - math.ceil((exp - strn + ing + 1) / 2) + 1
		else:
			ans = 0
	elif exp != 0:
		ans = ans + exp + 1
	else:
		ans = 1
	print(ans)


import math
t = int(input())
for i in range(0, t):
	Read = input().split(' ')
	S = int(Read[0])
	I = int(Read[1])
	E = int(Read[2])
	l = int(max(0.0, math.floor(float(I + E - S + 2) / 2.0)))
	res = max(0, E - l + 1)
	print(res)


n = int(input())
for i in range(0, n):
	p = input().rstrip().split(' ')
	A = int(p[0])
	B = int(p[1])
	C = int(p[2])
	D = 0
	if A <= B:
		T = B - A + 1
		if C >= T:
			C = C - T
			A = B + 1
		else:
			C = -1
	if C == -1:
		print(0)
	else:
		I = 0
		J = C
		V = 0
		while I <= J:
			m = (I + J) // 2
			G = A
			H = B
			if G + m > H + (C - m):
				V = C - m + 1
				J = m - 1
			elif G + m <= H + (C - m):
				I = m + 1
		print(D + V)


t = int(input())
for _ in range(t):
	(st, it, ex) = map(int, input().split())
	print(min(ex + 1, max(0, (st + ex - it + 1) // 2)))


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	if a < b:
		c -= abs(a - b)
		print(max(0, (c + 1) // 2))
	elif a == b:
		print((c + 1) // 2)
	else:
		k = min(a - b, c)
		l = max(0, (c - k + 1) // 2)
		if a - b > c:
			print(c + 1)
		else:
			print(k + l)


INT_MAX = 10 ** 20 + 7
MOD = 10 ** 9 + 7
from sys import stdin, stdout

def INPUT():
	return list((int(i) for i in stdin.readline().split()))
import math

def inp():
	return stdin.readline()

def out(x):
	return stdout.write(x)
for i in range(int(inp())):
	(s, x, e) = INPUT()
	t = min(s, x)
	s -= t
	x -= t
	if s == x:
		out(str(int(math.ceil(e / 2))))
		print()
	elif s == 0:
		if x >= e:
			print(0)
		else:
			ans = int(math.ceil((e - x) / 2))
			print(ans)
	elif s > e:
		print(e + 1)
	else:
		ans = int(math.ceil((e + s) / 2))
		print(ans)


t = int(input())
l = []
for i in range(t):
	(st, inte, ex) = map(int, input().split())
	if st + ex <= inte:
		l.append(0)
	else:
		maxst = st + ex
		minst = (st + ex + inte) // 2 + 1
		if st > minst:
			minst = st
		l.append(maxst - minst + 1)
for i in range(t):
	print(l[i])


t = int(input())
while t:
	t -= 1
	(str, intel, exp) = input().split()
	str = int(str)
	intel = int(intel)
	exp = int(exp)
	str += exp
	if str <= intel:
		print(0)
		continue
	print(min(exp, (str - intel - 1) // 2) + 1)


def query(S, I, E):
	if S + E <= I:
		return 0
	ans = E - max(0, I + E - S) // 2
	if I + E < S:
		ans += 1
	return ans
T = int(input())
for tc in range(T):
	(S, I, E) = map(int, input().split())
	print(query(S, I, E))


def ph(x):
	if x - int(x) >= 0.5:
		return int(x) + 1
	else:
		return int(x)
n = int(input())
a = []
for i in range(n):
	a.append([int(x) for x in input().split()])
for (x, y, z) in a:
	if x > y + z:
		print(z + 1)
		continue
	if z == 0:
		if x > y:
			print(1)
		else:
			print(0)
		continue
	if x > y:
		print(ph((x + z - y) / 2))
	else:
		if x + z <= y:
			print(0)
			continue
		print(ph((x + z - y) / 2))


for cas in range(int(input())):
	(a, b, c) = map(int, input().split())
	l = (b + c - a) // 2 + 1
	r = c
	print(max(0, r - max(l, 0) + 1))


def func():
	(n, m, exp) = map(int, input().split())
	addm = max((m + exp - n + 2) // 2, 0)
	ans = max(0, exp - addm + 1)
	print(ans)
T = int(input())
for i in range(0, T):
	func()


def read(t=int):
	return list(map(t, input().strip().split(' ')))
t = read()[0]
while t > 0:
	t -= 1
	(s, i, k) = read()
	(l, r) = (0, k)
	while l < r:
		x = (l + r) // 2
		y = k - x
		if s + x <= i + y:
			l = x + 1
		else:
			r = x
	if r + s <= k - r + i:
		r = k + 1
	print(k - r + 1)


import sys
import os
from io import IOBase, BytesIO

def main():
	for tc in range(int(input())):
		(s, i, e) = get_ints()
		if s + e <= i:
			print(0)
		else:
			s += e
			if (s - i) % 2 == 0:
				print(min(e + 1, (s - i) // 2))
			else:
				print(min(e + 1, (s - i) // 2 + 1))
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		py2 = round(0.5)
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2 == 1:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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 get_array():
	return list(map(int, sys.stdin.readline().split()))

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

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


import sys
input = sys.stdin.readline
import math
t = int(input())
for i in range(t):
	(s, i, f) = map(int, input().split())
	if s <= i:
		de = i + 1 - s
		if f - de >= 0:
			s += de
			f = f - de
		else:
			f = 0
			s += f
	if f == 0:
		if s > i:
			print(1)
		else:
			print(0)
	else:
		diff = s - i
		if f < diff:
			print(f + 1)
		else:
			i = math.ceil((1 + f - diff) / 2)
			print(f - i + 1)


from math import ceil
for t in range(int(input())):
	(a, b, exp) = list(map(int, input().split()))
	print(min(exp + 1, max(ceil((a + exp - b) / 2), 0)))


def getResult(s, i, e):
	r = (s + i + e) // 2
	if s + e - r < 0:
		return 0
	if s > r:
		return e + 1
	return s + e - r
t = int(input())
for i in range(t):
	(s, i, e) = [int(x) for x in input().split()]
	print(getResult(s, i, e))


import math
test = int(input())
for i in range(test):
	inp = input()
	inp = inp.split(' ')
	s = int(inp[0])
	i = int(inp[1])
	e = int(inp[2])
	k = (i + e - s) // 2
	if k < 0:
		print(e + 1)
	elif e - k > 0:
		print(e - k)
	else:
		print(0)


T = int(input())
for t in range(T):
	(s, i, e) = map(int, input().split())
	min_s = max((s + i + e) // 2 + 1, s)
	max_s = s + e
	c = max(0, max_s - min_s + 1)
	print(c)


import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(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)
q = ii()
for j in range(q):
	(s, i, e) = mi()
	if s + e <= i:
		print(0)
	elif s > i + e:
		print(e + 1)
	else:
		print(math.ceil((s + e - i) / 2))


from collections import defaultdict as DD
from bisect import bisect_left as BL
from bisect import bisect_right as BR
from itertools import combinations as IC
from itertools import permutations as IP
from random import randint as RI
import sys
MOD = pow(10, 9) + 7

def IN(f=0):
	if f == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
tc = IN(1)
for _ in range(tc):
	(s, t, k) = IN()
	x = k - (k + t - s) // 2
	if x > k + 1:
		x = k + 1
	print(max(0, x))


import math
T = int(input())
for i in range(T):
	(s, i, e) = (int(x) for x in input().split())
	d = (i + e - s) / 2
	if d.is_integer():
		d = int(d + 1)
	else:
		d = math.ceil(d)
	if d <= 0:
		print(e + 1)
	elif d > e:
		print('0')
	else:
		print(e - d + 1)


import math
c = int(input())
for i in range(c):
	(si, um, ex) = list(map(int, input().split()))
	x = (um + ex - si) / 2
	x = math.floor(x) + 1
	r = ex - x + 1
	if r > ex + 1:
		r = ex + 1
	if r <= 0:
		print(0)
	else:
		print(r)


import math
qwe = int(input())
for i in range(0, qwe):
	ar = []
	for t in input().split(' '):
		ar.append(int(t))
	num = math.ceil((ar[2] + ar[1] - ar[0]) / 2)
	rem = (ar[2] + ar[1] - ar[0]) % 2
	if ar[0] + ar[2] < ar[1]:
		print(0)
		continue
	if ar[1] + ar[2] < ar[0]:
		print(ar[2] + 1)
		continue
	if rem == 0:
		print(ar[2] - num)
	else:
		print(ar[2] - num + 1)


import math
t = input()
t = int(t)
while t:
	(s, i, e) = map(int, input().split())
	sant = 0
	if s > i:
		sant = 1
	ans = e - (i + e - s) // 2
	if (i + e - s) // 2 >= e:
		print(sant)
	elif e == 0:
		print(sant)
	elif (i + e - s) // 2 < 0:
		print(e + 1)
	else:
		print(e - (i + e - s) // 2)
	t -= 1


def f(s, i, e):
	x = (s + e - i) / 2
	if x < 0:
		return 0
	if x == int(x):
		return int(x)
	else:
		return int(x + 1)
a = int(input())
for i in range(a):
	c = list(map(int, input().split()))
	print(min(f(c[0], c[1], c[2]), c[2] + 1))


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


for ii in range(int(input())):
	(s, i, e) = map(int, input().split())
	if s <= i:
		if e <= i - s:
			print(0)
			continue
		else:
			e -= i - s + 1
			s = i + 1
	if e < s - i:
		print(e + 1)
		continue
	x = s - i + e
	x = x // 2
	if x + i != s + e - x:
		x += 1
	print(x)


T = int(input())
result = []
for x in range(T):
	(s, i, e) = input().split(' ')
	(s, i, e) = (int(s), int(i), int(e))
	if s > i:
		if s - i > e:
			result.append(e + 1)
		else:
			temp1 = s - i - 1
			temp2 = int((e - temp1) / 2 + 1)
			result.append(temp1 + temp2)
	elif i - s >= e:
		result.append(0)
	else:
		temp1 = i - s + 1
		temp2 = int((e - temp1) / 2 + 1)
		result.append(temp2)
for x in result:
	print(x)


import sys

def main():

	def input():
		return sys.stdin.readline()[:-1]
	T = int(input())
	for k in range(T):
		(s, i, t) = map(int, input().split())
		print(max(0, min(t + 1, t - (i + t - s) // 2)))
main()


from math import floor, ceil

def main():
	T = int(input())
	for t in range(T):
		(str_, int_, exp_) = map(int, input().split())
		max_str = str_ + exp_
		if max_str <= int_:
			print(0)
		else:
			dist = max_str - int_
			ans = ceil(dist / 2)
			if max_str - (ans - 1) < str_:
				ans = max_str - str_ + 1
			print(ans)
main()


t = int(input())
for ti in range(t):
	(a, b, e) = (int(i) for i in input().split(' '))
	if e == 0:
		if a > b:
			print(1)
		else:
			print(0)
	elif a + e <= b:
		print(0)
	elif b >= a:
		e -= b - a + 1
		a = b + 1
		print((e >> 1) + 1)
	else:
		if a - b & 1:
			a += 1
			if e & 1:
				a -= 1
		print(min(e + 1, (e + 1 >> 1) + (a - b >> 1)))


def main():
	t = int(input())
	for _ in range(t):
		(a, b, e) = map(int, input().split())
		xmin = max(0, (b - a + e) // 2 + 1)
		print(max(0, e - xmin + 1))
main()


t = int(input())
for _ in range(t):
	(s, i, e) = map(int, input().split())
	k = s - i
	if k <= -e:
		print(0)
	elif -e < k <= e:
		print((e + 1 + k) // 2)
	elif e < k:
		print(e + 1)


cases = int(input())
for t in range(cases):
	(stri, inti, expi) = list(map(int, input().split()))
	v = stri - inti
	if v > expi:
		print(expi + 1)
	elif v == expi:
		print(expi)
	elif stri > inti:
		diff = expi - v
		print(v + diff - diff // 2)
	elif stri == inti:
		print(expi - expi // 2)
	elif v + expi <= 0:
		print(0)
	else:
		diff = expi + v
		print(diff - diff // 2)


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


def main():
	t = int(input())
	for _ in range(t):
		(s, i, e) = map(int, input().split())
		if s + e <= i:
			print(0)
		elif s > i + e:
			print(e + 1)
		else:
			print(e - (i - s + e) // 2)
	return
main()


for _ in range(int(input())):
	(s, i, e) = map(int, input().split())
	if s + e <= i:
		print(0)
	else:
		mn = max(s, (s + e + i) // 2 + 1)
		ans = s + e - mn + 1
		print(ans)


t = int(input())
for h in range(t):
	(a, b, c) = map(int, input().split())
	r = (a + c - b + 1) // 2
	if r > c + 1:
		r = c + 1
	if r < 0:
		r = 0
	print(r)


from math import ceil
t = int(input())
for o in range(t):
	(a, b, c) = map(int, input().split())
	print(min(max(ceil((a - b + c) / 2), 0), c + 1))


import math
n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	k = (a - b + c) / 2
	j = math.ceil(k)
	j = min(j, c + 1)
	j = max(0, j)
	print(j)


t = int(input())
for _ in range(t):
	(g, s, avail) = map(int, input().split())
	count = 0
	if g > s:
		dif = g - s
		if dif - 1 > avail:
			count += avail
			count += 1
		else:
			avail -= dif - 1
			count += dif - 1
			if avail % 2 == 0:
				count += avail // 2
				count += 1
			else:
				count += avail // 2
				count += 1
	else:
		dif = s - g
		if dif + 1 > avail:
			pass
		else:
			avail -= dif + 1
			if avail % 2 == 0:
				count += avail // 2
				count += 1
			else:
				count += avail // 2
				count += 1
	print(count)


T = int(input())
answer = [0 for x in range(T)]
i = 0
while i < T:
	(streng, intel, expir) = tuple((int(x.strip()) for x in input().split(' ')))
	if expir == 0:
		if streng > intel:
			answer[i] = 1
		else:
			answer[i] = 0
	if streng < intel:
		if abs(streng - intel) >= expir:
			answer[i] = 0
		else:
			answer[i] = (expir + (streng - intel) + 1) // 2
	elif streng > intel:
		if streng - intel < expir:
			if streng - intel & 1:
				answer[i] = streng - intel + 1
			else:
				answer[i] = expir - 1
			answer[i] = (expir + (streng - intel) + 1) // 2
		elif streng - intel == expir:
			answer[i] = expir
		else:
			answer[i] = expir + 1
	elif expir & 1:
		answer[i] = (expir + 1) // 2
	else:
		answer[i] = expir // 2
	i += 1
for a in answer:
	print(a)


import math
from decimal import *
getcontext().prec = 30
t = int(input())
while t:
	t -= 1
	(s, i, e) = map(int, input().split())
	x = (i + e - s) / 2
	if x >= e:
		print(0)
	elif x < 0:
		print(e + 1)
	elif math.ceil(x) != x:
		print(int(e - math.floor(x)))
	else:
		print(int(e - x))


import math
for t in range(int(input())):
	(f, s, n) = map(int, input().split())
	if s - f >= n:
		print(0)
	else:
		b = math.ceil((n + (f - s)) / 2)
		if b > n + 1:
			b = n + 1
		print(b)


import sys
num = sys.stdin.readline().strip()
data = []
try:
	while True:
		line = sys.stdin.readline().strip()
		if line == '':
			break
		lines = list(map(int, line.split()))
		data.append(lines)
except:
	pass
for pair in data:
	(str_, int_, exp) = pair
	if exp == 0:
		if str_ > int_:
			count = 1
		else:
			count = 0
	elif exp == 1:
		if str_ > int_ + 1:
			count = 2
		elif str_ == int_ + 1 or str_ == int_:
			count = 1
		else:
			count = 0
	else:
		diff = str_ - int_
		if diff > exp:
			count = exp + 1
		else:
			count = (str_ - int_ + exp + 1) // 2
			if count < 0:
				count = 0
	print(count)


def check(midd):
	if b + midd < a + (add - midd):
		return True
	return False
for _ in range(int(input())):
	(a, b, add) = map(int, input().split())
	l = 1
	r = add
	ans = 0
	while l <= r:
		mid = (l + r) // 2
		if check(mid):
			ans = mid
			l = mid + 1
		else:
			r = mid - 1
	if ans == 0 and a > b:
		print(1)
	elif ans == 0 and a + add > b:
		print(1)
	elif ans == 0:
		print(0)
	else:
		print(ans + 1)


from math import ceil
for _ in range(int(input())):
	(Str, Int, Exp) = map(int, input().split())
	if Str > Int:
		print(max(0, ceil((Exp - (Str - Int)) / 2)) + min(Exp + 1, Str - Int))
	else:
		bnd = ceil((Exp - (Int - Str)) / 2)
		print(max(bnd, 0))


t = int(input())
for _ in range(t):
	(a, b, c) = list(map(int, input().split()))
	k = (b + c - a) / 2
	if k < 0:
		print(c + 1)
	else:
		t = int(k) + 1
		if t > c:
			print(0)
		else:
			print(c + 1 - t)


n = int(input())
for i in range(n):
	(s, i, e) = [int(x) for x in input().split()]
	if s - i > e:
		print(e + 1)
		continue
	x = (s + e - i) / 2
	if x < 0:
		print(0)
	else:
		y = (s + e - i) // 2
		if abs(x - y) >= 0.5:
			print(y + 1)
		else:
			print(y)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	a = a + c - b
	b = 0
	if a <= 0:
		print(0)
	elif c == 0 and a > b:
		print(1)
	else:
		k = a // 2
		if a & 1:
			print(min(c + 1, k + 1))
		else:
			print(min(c + 1, k))


import math
n = int(input())
for i in range(n):
	(st, inte, exp) = map(int, input().split())
	addS = max(0, (exp + inte - st + 2) / 2)
	addS = max(0, exp - addS + 1)
	if addS < 0:
		print(0)
	else:
		print(math.ceil(addS))


def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def sieve_of_eratosthenes(n):
	ans = []
	arr = [1] * (n + 1)
	(arr[0], arr[1], i) = (0, 0, 2)
	while i * i <= n:
		if arr[i] == 1:
			j = i + i
			while j <= n:
				arr[j] = 0
				j += i
		i += 1
	for k in range(n):
		if arr[k] == 1:
			ans.append(k)
	return ans

def nc2(x):
	if x == 1:
		return 0
	else:
		return x * (x - 1) // 2

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def mex(li):
	check = [0] * 1001
	for i in li:
		check[i] += 1
	for i in range(len(check)):
		if check[i] == 0:
			return i

def sumdigits(n):
	ans = 0
	while n != 0:
		ans += n % 10
		n //= 10
	return ans

def product(li):
	ans = 1
	for i in li:
		ans *= i
	return ans
from math import *
from collections import deque
max_steps = 100005
for _ in range(int(input())):
	(s, i, e) = map(int, input().split())
	if i - s > e - 1:
		print(0)
	else:
		p = s + e - i
		print(min(e + 1, ceil(p / 2)))


T = int(input())
for _ in range(T):
	(s, i, e) = map(int, input().split(' '))
	result = min((s + e - i + 1) // 2, e + 1) if s + e - i > 0 else 0
	print(result)


t = int(input())
for j in range(t):
	(a, b, c) = map(int, input().split())
	if c == 0:
		if a > b:
			print(1)
			continue
		print(0)
	else:
		if a + c <= b:
			print(0)
			continue
		k = (a + b + c) // 2
		print(a + c - k if a + c - k <= c else c + 1)


import math
t = int(input())
a = []
for i in range(t):
	b = list(map(int, input().split()))
	a.append(b)
for i in a:
	s = i[0]
	b = i[1]
	e = i[2]
	x = math.floor((b + e - s) / 2)
	if x < 0:
		x = -1
	if e - x < 0:
		print(0)
	else:
		print(e - x)


q = int(input())

def foo(st, it, exp):
	it2 = it
	if st - it >= 1:
		r = st - it - 1
		if r > exp:
			it2 += exp
			exp = 0
		else:
			exp -= r
			it2 += r
	else:
		r = it - st + 1
		if r > exp:
			return 0
		else:
			exp -= r
			st += r
	it2 += exp // 2
	return it2 - it + 1
for i in range(q):
	(st, it, exp) = map(int, input().split())
	print(foo(st, it, exp))


import math
for _ in range(int(input())):
	(s, i, e) = map(int, input().split())
	if s > i:
		if e == 0:
			print(1)
		else:
			r = s - i
			if r > e:
				print(e + 1)
			else:
				y = math.ceil((e + r) / 2)
				x = e - y
				print(e + 1 - (x + 1))
	elif i >= s:
		k = i - s
		if k >= e:
			print(0)
		else:
			e = e - k
			print(math.ceil(e / 2))


t = int(input())
for a in range(t):
	(s, i, e) = map(int, input().split())
	kq = 0
	if s == i:
		if e % 2 == 0:
			kq = e // 2
		else:
			kq = e // 2 + 1
	elif s < i:
		if s + e <= i:
			kq = 0
		else:
			e = e - (i - s)
			if e % 2 == 0:
				kq = e // 2
			else:
				kq = e // 2 + 1
	elif i + e < s:
		kq = e + 1
	elif i + e == s:
		kq = e
	else:
		t1 = s + e
		t2 = (s + i + e) // 2 + 1
		kq = t1 - t2 + 1
	print(kq)


import math
t = int(input())
for _ in range(t):
	(x, y, m) = map(int, input().split())
	if x + m <= y:
		print(0)
	else:
		if x < y:
			m = m - (y - x) - 1
			x = x + (y - x) + 1
		diff = x - y
		if diff > m:
			print(m + 1)
		else:
			print(math.ceil((m + diff) / 2))


from math import ceil

def satyam():
	t = int(input())
	for YY in range(t):
		satyam = 9999
		(st, it, exp) = [int(i) for i in input().split()]
		satyammm = 9999
		val = (it + exp - st) / 2
		if val > exp:
			print(0)
		elif val < 0:
			print(exp + 1)
		elif val > int(val):
			print(exp + 1 - ceil(val))
		else:
			print(int(exp - val))
satyam()


import sys
import math
input = sys.stdin.readline

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

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

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

def invr():
	return map(int, input().split())
t = inp()
for _ in range(t):
	(a, b, c) = invr()
	ans = max(0, (b - a + c + 1 + 1) // 2)
	ans = max(0, c - ans + 1)
	print(ans)


t = int(input())
for _ in range(t):
	(n, m, k) = map(int, input().split())
	if m + k - n < 0:
		print(k + 1)
	elif 2 * k <= m + k - n:
		print(0)
	else:
		x = (m + k - n) // 2 + 1
		print(k - x + 1)


mylist = []
t = int(input())
for i in range(t):
	mylist.append(list(map(int, input().split(' ')))[:3])
for i in range(t):
	ans = 0
	if mylist[i][0] + mylist[i][2] > mylist[i][1]:
		if mylist[i][1] >= mylist[i][0]:
			mylist[i][2] -= mylist[i][1] - mylist[i][0] + 1
			mylist[i][0] = mylist[i][1] + 1
		diff = mylist[i][0] + mylist[i][2] - mylist[i][1]
		ans = min(mylist[i][2] + 1, int(diff / 2) + int(diff % 2))
	print(ans)


import math
n = int(input())

def num(s, i, e):
	if e - (i + e - s) / 2 == 0:
		return 0
	if e - (i + e - s) / 2 > 0 and e - (i + e - s) / 2 < 1:
		return 1
	if e - (i + e - s) / 2 >= 1:
		if s - i > e:
			return e + 1
		else:
			return math.ceil(e - (i + e - s) / 2)
	else:
		return 0
for i in range(0, n):
	l = input()
	l = l.split()
	s = int(l[0])
	i = int(l[1])
	e = int(l[2])
	print(num(s, i, e))


T = int(input())
for _ in range(T):
	(s, i, e) = map(int, input().split())
	a = max(0, (i + e - s) // 2)
	while s + a <= i + e - a:
		a += 1
	print(max(0, e - a + 1))


t = int(input())
for i in range(t):
	(st, it, e) = map(int, input().split())
	st += e
	ans1 = min(e + 1, max(st - it + 1, 0) // 2)
	print(ans1)


tc = int(input())
anns = []
for _ in range(tc):
	temp = [int(i) for i in input().split()]
	s = temp[0]
	i = temp[1]
	exp = temp[2]
	if exp == 0 and s - i > 0:
		d = 1
	elif exp == 0 and s - i <= 0 or s + exp - i <= 0:
		d = 0
	elif -s + i + exp < 0:
		d = exp + 1
	else:
		t = int((-s + i + exp) / 2)
		u = exp + 1
		if u - t - 1 > 0:
			d = u - t - 1
		else:
			d = 0
	anns.append(d)
for k in anns:
	print(k)


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, i, e) = get_list()
	x = max(0, (i + e - s + 2) // 2)
	print(max(0, e - x + 1))


import sys, os, io

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

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

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

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools
from collections import deque, defaultdict, OrderedDict
import collections

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		(s, i, p) = ria()
		if p == 0 and s > i:
			print(1)
		else:
			z = s + p
			if z <= i:
				print(0)
			else:
				c = (z + i) // 2 + 1
				f = z - c + 1
				if z - f < s:
					print(p + 1)
				else:
					print(f)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			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, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			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()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

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

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


import math, sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
lili = lambda : list(map(int, sys.stdin.readlines()))
li = lambda : list(map(int, input().split()))

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
t = int(input())
for i in range(0, t):
	(a, b, c) = li()
	if a + c <= b:
		print(0)
	elif (a + c - b) % 2 == 0:
		print(min(c + 1, (a + c - b) // 2))
	else:
		print(min(c + 1, (a + c - b) // 2 + 1))


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(s, i, e) = [int(i) for i in input().split()]
	x = (i + e - s) // 2
	if x < 0:
		print(e + 1)
	elif x > e:
		print(0)
	else:
		print(e - x)


def main(a):
	a = a.split(' ')
	(x, y, z) = (int(a[0]), int(a[1]), int(a[2]))
	if y - x >= z:
		return 0
	else:
		w = (x + z - y + 1) // 2
	return min(w, z + 1)
a = int(input())
b = []
for i in range(a):
	b.append(main(input()))
for j in b:
	print(j)


def strint(l):
	r = l[0] + l[2] - l[1]
	if r % 2 == 0:
		r = r // 2
	else:
		r = (r + 1) // 2
	return max(0, min(r, l[2] + 1))
for i in range(int(input())):
	print(strint(list(map(int, input().strip().split()))))


n = int(input())
for _ in range(0, n):
	(strr, intt, expp) = map(int, input().split())
	if strr > intt:
		ans = 0
		temp = expp
		expp -= strr - intt
		if expp >= 0:
			if expp % 2 == 0:
				ans = expp // 2
				ans += strr - intt
			else:
				ans = expp // 2
				ans += 1
				ans += strr - intt
		else:
			ans = temp + 1
		print(max(ans, 1))
	else:
		expp -= intt - strr
		ans = 0
		if expp % 2 == 0:
			ans = expp // 2
		else:
			ans = expp // 2
			ans += 1
		print(max(0, ans))


def get_n(a, b, c):
	ans = (b + c - a) // 2 + 1
	ans = max(0, ans)
	ans = len(range(ans, c + 1))
	return ans
T = int(input())
for i in range(T):
	(a, b, c) = map(int, input().split())
	print(get_n(a, b, c))


for i in range(int(input())):
	(str_, int_, exp_) = map(int, input().split())
	if str_ + exp_ - int_ > 0:
		print(min((str_ + exp_ - int_) // 2 + (str_ + exp_ - int_) % 2, exp_ + 1))
	else:
		print(0)


for _ in range(int(input())):
	(a, b, k) = map(int, input().split())
	l = 0
	h = k
	if a + k <= b:
		print(0)
	else:
		while l < h:
			mid = (l + h) // 2
			if a + mid > b + k - mid:
				h = mid
			else:
				l = mid + 1
		print(k - l + 1)


T = int(input())
for _ in range(T):
	(s, i, e) = map(int, input().split())
	(inf, sup) = (0, e)
	minadds = max(0, (e + i - s + 2) // 2)
	print(max(0, e - minadds + 1))


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


import math
n = int(input())
for i in range(n):
	(a, b, c) = [int(item) for item in input().split()]
	ans = min(c + 1, max(0, math.ceil((a - b + c) / 2)))
	print(ans)


t = int(input())
for _ in range(t):
	(s, i, e) = (int(x) for x in input().split())
	x = (i + e - s) // 2
	if x > e:
		print(0)
	elif x < 0:
		print(e + 1)
	else:
		print(e - x)


import math
for _ in range(int(input())):
	(s, i, e) = map(int, input().split())
	i += e
	if i < s:
		print(e + 1)
	else:
		i = i - s
		i = i // 2 + 1
		i = e + 1 - i
		print(max(0, i))


t = int(input())
for kjdl in range(t):
	(s, i, e) = map(int, input().split())
	l = -1
	r = e
	if s + e <= i:
		print(0)
		continue
	while r - l > 1:
		m = (r + l) // 2
		if s + m <= i + e - m:
			l = m
		else:
			r = m
	print(e - r + 1)


t = int(input())
for i in range(t):
	(s, i, e) = map(int, input().split())
	d = s - i
	if s + e <= i:
		print(0)
	elif s > i + e:
		print(e + 1)
	else:
		print((e + 1 + d) // 2)


t = int(input())
for i in range(t):
	(st, x, exp) = map(int, input().split())
	r = (st + exp - x + 1) // 2
	if r > exp + 1:
		r = exp + 1
	if r < 0:
		r = 0
	print(r)


T = int(input())
for _ in range(T):
	(s, i, exp) = map(int, input().strip().split())
	min_add_s = max(0, (exp + i - s + 2) // 2)
	print(max(0, exp - min_add_s + 1))


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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 value():
	return tuple(map(int, input().split()))

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

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	(a, b, p) = value()
	print(max(0, p - max(0, (b + p - a + 2) // 2) + 1))


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


n = int(input())
for _ in range(n):
	(st, inte, exp) = map(int, input().split())
	adds = max(0, (inte + exp - st + 2) // 2)
	print(max(0, exp - adds + 1))


t = int(input())
for _ in range(t):
	(str, inti, exp) = map(int, input().split())
	minAdds = max(0, int((exp + inti - str + 2) / 2))
	print(max(0, exp - minAdds + 1))


import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop, heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10 ** 9 + 7
inf = float('inf')

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

def LI():
	return list(map(int, sys.stdin.readline().split()))
t = I()
for _ in range(t):
	(s, t, e) = LI()
	if s + e <= t:
		print(0)
		continue
	print(min(math.ceil((s + e - t) / 2), e + 1))


import random

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

def lcm(a, b):
	return a * b / gcd(a, b)
for _ in range(int(input())):
	(s, i, e) = map(int, input().split())
	ans = 0
	if s < i:
		k = min(i - s, e)
		s += k
		e -= k
	if i < s:
		if s - i > e:
			print(e + 1)
		else:
			k = min(s - i, e)
			if (e - k) % 2 == 0:
				ans = (e - k) // 2 + k
			else:
				ans = 1 + (e - k) // 2 + k
			print(ans)
	elif e:
		if e % 2 == 0:
			print(e // 2)
		else:
			print(e // 2 + 1)
	else:
		print(0)


for _ in range(int(input())):
	(x, y, z) = map(int, input().split())
	mins = max(0, (y + z - x + 2) // 2)
	print(max(0, z - mins + 1))


import math
t = int(input())
while t != 0:
	t -= 1
	(s, i, e) = [int(x) for x in input().split()]
	d = s - i
	if e == 0:
		if s > i:
			print(1)
		else:
			print(0)
	else:
		if e % 2 == 0:
			total = (e + 1) // 2 + math.ceil(d / 2)
		else:
			total = (e + 1) // 2 + math.floor(d / 2)
		print(min(max(total, 0), e + 1))


n = int(input())
for i in range(n):
	(a, s, d) = map(int, input().split())
	if a + d > s:
		if a - s > d:
			print(d + 1)
		else:
			print((a - s + d) // 2 + (a - s + d) % 2)
	else:
		print(0)


for _ in range(int(input())):
	(stre, inte, exp) = map(int, input().split())
	minAddS = max(0, (inte + exp - stre + 2) // 2)
	print(max(0, exp - minAddS + 1))


from sys import stdin
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
for _ in range(I()):
	(a, b, c) = R()
	ans = 0
	l = 0
	r = c
	while l <= r:
		m = (l + r) // 2
		if a + m > b + (c - m):
			ans = c - m + 1
			r = m - 1
		else:
			l = m + 1
	print(ans)


for _ in [0] * int(input()):
	(a, b, c) = map(int, input().split())
	print(max(0, min(c + 1, a - b + c + 1 >> 1)))


def jock(st, nt, ex):
	d = st - nt
	if d == 0:
		if ex % 2 == 0:
			return int(ex / 2)
		else:
			return int(ex / 2) + 1
	elif d > 0:
		if ex < d:
			return ex + 1
		elif ex == d:
			return ex
		elif (ex - d) % 2 == 0:
			return d + int((ex - d) / 2)
		else:
			return d + 1 + int((ex - d) / 2)
	elif ex <= -d:
		return 0
	else:
		ex = ex + d
		if ex % 2 == 0:
			return int(ex / 2)
		else:
			return int(ex / 2) + 1
t = int(input())
for i in range(t):
	c = input().split()
	st = int(c[0])
	nt = int(c[1])
	ex = int(c[2])
	print(jock(st, nt, ex))


t = int(input())
for y in range(t):
	(s, i, e) = map(int, input().split())
	x = (e + i - s) // 2
	if x >= 0:
		if e - x >= 0:
			print(e - x)
		else:
			print(0)
	else:
		print(e + 1)


import math
for _ in range(int(input())):
	(s, i, e) = map(int, input().split())
	if s > i + e:
		print(e + 1)
	elif s == i + e:
		print(e)
	else:
		a = math.ceil((s + i + e) / 2) - i
		print(0 if a <= 0 else a)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	l = 0
	r = c + 1
	while l < r:
		m = (r + l) // 2
		if a + m > b + c - m:
			r = m
		else:
			l = m + 1
	if l > c:
		print(0)
	else:
		print(c - l + 1)


t = int(input())
for i in range(t):
	(forca, intel, exp) = map(int, input().split())
	count = 0
	if intel > forca:
		j = int(intel - forca)
	else:
		j = 0
	exp = exp - j
	if exp <= 0 and intel > forca:
		print(0)
	elif intel > forca:
		(intel, forca) = (0, 1)
		exp -= 1
		print(int(exp / 2) + 1)
	elif forca - intel > exp:
		print(exp + 1)
	elif forca - intel == exp or forca - intel == exp - 1:
		print(exp)
	else:
		k = int((intel + exp - forca) / 2 + 1)
		(forca2, intel2) = (forca + k, intel + exp - k)
		if forca2 > intel2:
			count += exp + 1 - k
		print(count)


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


import math
n = int(input())
for _ in range(n):
	(s, i, e) = map(int, input().split())
	c = 0
	dsi = 0
	if s > i:
		dsi = s - i
		if dsi <= e:
			e -= dsi
			c = (e + 1) // 2 + dsi
		else:
			c = e + 1
	else:
		dsi = i - s
		if dsi < e:
			e -= dsi
			c = (e + 1) // 2
		else:
			c = 0
	print(c)


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(Str, Int, Exp) = map(int, input().split())
	if Str == Int:
		result = int(Exp / 2) if Exp % 2 == 0 else int(Exp / 2 + 1)
		print('{}'.format(result))
	elif Str < Int:
		diff = Int - Str + 1
		Str += diff
		Exp -= diff
		if Exp < 0:
			print(0)
		else:
			result = int(Exp / 2 + 1)
			print('{}'.format(result))
	else:
		diff = Str - Int - 1
		Int += diff
		Exp -= diff
		if Exp < 0:
			print(diff + Exp + 1)
		else:
			result = diff + int(Exp / 2 + 1)
			print('{}'.format(result))


def x(a):
	return int(a) + 1
t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	if a <= b:
		if c <= b - a:
			print(0)
			continue
	low = 0
	high = c
	while low < high:
		mid = (low + high) // 2
		if a + mid > b + c - mid:
			high = mid
		else:
			low = mid + 1
	print(c - low + 1)


t = input()
resultados = []
for i in range(int(t)):
	linea = input()
	linea = linea.split(' ')
	fuerza = int(linea[0])
	inteligencia = int(linea[1])
	experiencia = int(linea[2])
	cont = (fuerza + experiencia - inteligencia) % 2 + (fuerza + experiencia - inteligencia) // 2
	if cont <= 0:
		resultados.append(0)
	elif cont > experiencia + 1:
		cont = experiencia + 1
		resultados.append(cont)
	else:
		resultados.append(cont)
for r in resultados:
	print(r)


t = int(input())
a = []
for i in range(t):
	a.append([int(i) for i in input().split()])
for (s, i, e) in a:
	f = 0
	if e == 0:
		if s > i:
			print(1)
		elif s <= i:
			print(0)
		continue
	if s + e <= i:
		print(0)
	else:
		if s > i + e:
			f = 0
		else:
			f = (i + e - s) // 2 + 1
		print(e - f + 1)


query = int(input())
for q in range(query):
	(a, b, c) = map(int, input().split())
	print(max(c + 1 - max((-a + b + c + 2) // 2, 0), 0))


def dell(a):
	if a < 0:
		if a % 2 == 0:
			return int(a / 2)
		else:
			return int(a / 2) - 1
	else:
		return int(a / 2)
q = int(input())
for t in range(q):
	(str, inn, exp) = [int(i) for i in input().split()]
	xmin = max(0, dell(inn + exp - str) + 1)
	print(max(exp - xmin + 1, 0))


import math
t = int(input())
for i in range(t):
	(s, ina, exp) = [int(i) for i in input().split()]
	a = ina + exp - s
	a = a / 2
	a = max(-1, a)
	b = exp - a
	print(max(0, math.ceil(b)))


for i in range(int(input())):
	(s, i1, e) = input().split()
	s = int(s)
	i1 = int(i1)
	e = int(e)
	b = s - i1 + e
	c = s - i1 - e
	count = 0
	if b <= 0:
		print(0)
	elif c <= 0:
		c = 1
		x = b - c + 1
		x1 = x // 2
		count = x - x1
		print(count)
	elif c > 0:
		x = b - c + 1
		x1 = x // 2
		count = x - x1
		print(count)


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


def mm(x, y, z):
	s = x + y + z
	if s % 2 == 0:
		return s // 2 + 1
	else:
		return (s + 1) // 2

def ans(x, y, z):
	m = mm(x, y, z)
	if x + z < m:
		return 0
	elif x <= m:
		return x + z - m + 1
	else:
		return z + 1
t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	print(ans(a, b, c))


nb = int(input())
queries = []
for i in range(nb):
	queries.append(list(map(int, input().split())))

def binary_search_smallest_valid_added_strength(strength, intelligence, exp, a, b):
	if a == b:
		if check_if_stats_are_valid(strength, intelligence, a, exp - a):
			return a
		else:
			return a + 1
	half = a + int((b - a) / 2)
	if check_if_stats_are_valid(strength, intelligence, half, exp - half):
		return binary_search_smallest_valid_added_strength(strength, intelligence, exp, a, half)
	else:
		return binary_search_smallest_valid_added_strength(strength, intelligence, exp, half + 1, b)

def check_if_stats_are_valid(strengh, intelligence, added_strength, added_intelligence):
	if strengh + added_strength > intelligence + added_intelligence:
		return True
	else:
		return False

def count_valid_settings(initial_conf):
	(strength, intelligence, exp) = initial_conf
	if exp == 0:
		if check_if_stats_are_valid(strength, intelligence, 0, 0):
			return 1
		else:
			return 0
	minimum_added_strength = binary_search_smallest_valid_added_strength(strength, intelligence, exp, 0, exp)
	if minimum_added_strength > exp:
		return 0
	else:
		return exp - minimum_added_strength + 1
for i in range(nb):
	print(count_valid_settings(queries[i]))


t = int(input())
ans = []
for i in range(t):
	ss = input()
	a = ss.split()
	s = int(a[0])
	i = int(a[1])
	n = int(a[2])
	p = (n + i - s) / 2
	if p >= n:
		ans.append(0)
		continue
	if p < 0:
		ans.append(n + 1)
	else:
		ans.append(n - (n + i - s + 2) // 2 + 1)
for i in range(t):
	print(ans[i])


from sys import stdin

def func(arr):
	return
for _ in range(int(stdin.readline())):
	(s, i, ex) = map(int, stdin.readline().split())
	c = ex
	if s >= i:
		k = s - i
		count = 0
		ex += k
		if ex % 2 == 0:
			count += ex // 2
		else:
			count += (ex + 1) // 2
		print(min(c + 1, count))
	else:
		k = i - s
		if ex > k:
			ex -= k
			count = 0
			if ex % 2 == 0:
				count += ex // 2
			else:
				count += (ex + 1) // 2
			print(min(count, c + 1))
		else:
			print(0)


def binarySearch(l, r, x, y, num):
	mid = (l + r) // 2
	while l <= r and l >= 0 and (r <= num):
		if mid + x > y + (num - mid) and (mid == 0 or mid - 1 + x <= y + (num + 1 - mid)):
			return mid
		elif mid + x <= y + (num - mid):
			l = mid + 1
			mid = (l + r) // 2
		elif mid - 1 >= 0:
			r = mid - 1
			mid = (l + r) // 2
		else:
			return 0
outputs = []
for __ in range(int(input())):
	(s, i, e) = list(map(int, input().split()))
	if i - s >= e:
		outputs.append(0)
	else:
		if i >= s:
			e -= i - s + 1
			s += i - s + 1
		if e == 0:
			outputs.append(1)
		elif e == 1:
			if s - i > 1:
				outputs.append(2)
			else:
				outputs.append(1)
		elif s - i > e:
			outputs.append(e + 1)
		else:
			outputs.append(e - binarySearch(1, e, s, i, e) + 1)
for output in outputs:
	print(output)


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
for _ in range(ii()):
	(s, i, e) = f()
	if s + e - i & 1:
		print(min(e + 1, max(0, (s + e - i + 1) // 2)))
	else:
		print(min(e + 1, max(0, (s + e - i) // 2)))


t = int(input())
for _ in range(t):
	(s, i, e) = map(int, input().split())
	if s + e <= i:
		print(0)
	elif s > i and e == 0:
		print(1)
	else:
		total = s + e + i
		print(min(e + 1, total - i - total // 2))


import math
for _ in range(int(input())):
	(s, i, e) = [int(j) for j in input().split()]
	if i + e < s:
		print(e + 1)
		continue
	s += e
	if s > i:
		print(math.ceil((s - i) / 2))
	else:
		print(0)


import math
t = int(input())
for i in range(t):
	delta = input()
	delta = delta.split()
	for i in range(len(delta)):
		delta[i] = int(delta[i])
	num = min(max(0, math.ceil((delta[0] + delta[2] - delta[1]) / 2)), delta[2] + 1)
	print(num)


t = int(input())
for _ in range(t):
	sie = input().split()
	s = int(sie[0])
	i = int(sie[1])
	e = int(sie[2])
	lowerBound = max(0, (i + e - s) // 2 + 1)
	upperBound = e
	answer = max(0, upperBound - lowerBound + 1)
	print(answer)


for t in range(int(input())):
	(st, inte, free) = map(int, input().split())
	minstr = max(0, int((free + inte - st + 2) / 2))
	print(max(free - minstr + 1, 0))


import math

def getint():
	return int(input())

def getlist():
	return list(map(int, input().split()))
t = getint()
for _ in range(t):
	(s, i, e) = getlist()
	print(max(0, min(e + 1, (s - i + e + 1) // 2)))


from math import ceil
t = int(input())
for i in range(t):
	(a, b, f) = map(int, input().split())
	if a + f <= b:
		print(0)
		continue
	z = ceil((f - (b - a)) / 2)
	print(min(f + 1, z))


for i in range(int(input())):
	(st, it, exp) = map(int, input().split())
	x = max((exp - st + it + 2) // 2, 0)
	print(max(exp - x + 1, 0))


import sys, time
from os import path
from collections import *
from heapq import *
from math import *

def solve(kkkk):
	(s, i, e) = inm()
	ans = 0
	if s + e > i:
		(l, r) = [0, e]
		while l <= r:
			mid = int((l + r) / 2)
			if s + mid > i + e - mid:
				r = mid - 1
			else:
				l = mid + 1
		ans = e - l + 1
	out(ans)

def main():
	t = 1
	t = inp()
	for i in range(t):
		solve(i + 1)
localsys = 0
start_time = time.time()
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
	localsys = 1
cin = sys.stdin.readline
cout = sys.stdout.write

def inp():
	return int(cin().strip())

def ins():
	return list(cin().strip())

def inm():
	return map(int, cin().strip().split())

def ina():
	return list(map(int, cin().strip().split()))

def out(a):
	cout(str(a) + '\n')

def outa(a):
	cout(' '.join(map(str, a)) + '\n')

def outm(a, b, c=None, d=None):
	cout(str(a) + ' ' + str(b))
	if c != None:
		cout(' ' + str(c))
	if d != None:
		cout(' ' + str(d))
	cout('\n')

def crarr(a, n):
	return [a for i in range(n)]
main()
if localsys:
	print('\n\nTime Elapsed :', time.time() - start_time, 'seconds')


from math import ceil
for _ in range(int(input())):
	(stre, intl, exp) = map(int, input().split())
	addS = max(0, ceil((exp + intl - stre + 1) / 2))
	print(max(0, exp - addS + 1))


ll = lambda : list(map(int, input().split()))
testcases = 1
[testcases] = ll()
import math
for _ in range(testcases):
	[s, i, e] = ll()
	if s + e <= i:
		print(0)
	else:
		l = 0
		h = e
		ans = 99999999
		while l <= h:
			mid = (h + l) // 2
			if s + mid > i + e - mid:
				ans = min(ans, mid)
				h = mid - 1
			else:
				l = mid + 1
		if ans == 99999999:
			print(1)
		else:
			print(e - ans + 1)


n = int(input())
i = 0
while i < n:
	ar = list(map(int, input().split()))
	if ar[0] < ar[1]:
		diff = ar[1] - ar[0]
		if diff >= ar[2]:
			print(0)
		else:
			print(int((ar[2] - diff + 1) / 2))
	else:
		diff = ar[0] - ar[1]
		if diff > ar[2]:
			print(ar[2] + 1)
		else:
			print(ar[2] - int((ar[2] - diff) / 2))
	i += 1


import sys

def rint():
	return map(int, sys.stdin.readline().split())
T = int(input())
for t in range(T):
	(ss, ii, ee) = rint()
	max_ss = ss + ee
	min_ss = max(ss, (ss + ee + ii) // 2 + 1)
	print(max(0, max_ss - min_ss + 1))


import math
for t in range(int(input())):
	(n, m, k) = map(int, input().split())
	x = n + k
	x = x - m
	if x <= 0:
		print(0)
	elif k + m < n:
		print(k + 1)
	elif k + m == n:
		print(k)
	else:
		print(math.ceil(x / 2))


t = int(input())
for itr in range(t):
	(a, b, c) = list(map(int, input().split()))
	answer = 0
	left = 0
	right = c
	realMax = -1
	while left <= right:
		mid = (left + right) // 2
		rem = c - mid
		if a + rem > mid + b:
			realMax = mid
			left = mid + 1
		else:
			right = mid - 1
	answer = realMax + 1
	print(answer)


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(s, i, e) = list(map(int, input().split()))
	ans = 0
	if i >= s:
		diff = i - s + 1
		e -= diff
	else:
		diff = min(s - i - 1, e)
		ans += diff
		e -= diff
	if e >= 0:
		ans += e // 2 + 1
	print(ans)


t = int(input())
while t:
	(s, i, e) = map(int, input().split())
	x = (i + e - s) // 2
	x += 1
	x = max(x, 0)
	print(max(0, e - x + 1))
	t -= 1


n = int(input())
for x in range(n):
	(a, b, c) = list(map(int, input().split()))
	value = c + a
	if value <= b:
		print(0)
	else:
		print(min((a + c - b + 1) // 2, c + 1))


from math import ceil
for _ in range(int(input())):
	(s, i, e) = (int(s) for s in input().split())
	w = max(ceil((e - (s - i) + 1) / 2), 0)
	ans = max(e - w + 1, 0)
	print(ans)


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


import math
for _ in range(int(input())):
	(s, i, e) = map(int, input().split())
	print(min(e + 1, max(e - int(math.floor((i + e - s) / 2)), 0)))


import sys
input = sys.stdin.readline
T = int(input())
for testcases in range(T):
	(s, i, e) = map(int, input().split())
	print(min(max(0, (s + e - i + 1) // 2), e + 1))


cases = int(input())
from math import ceil
for _ in range(cases):
	x = [int(i) for i in input().split()]
	diff = x[0] - x[1]
	s = max(0, ceil((1 - diff + x[-1]) / 2))
	print(max(x[-1] - s + 1, 0))


for _ in range(int(input())):
	(st, inte, exp) = (*map(int, input().split()),)
	if st + exp <= inte:
		print(0)
		continue
	l = max((st + inte + exp) // 2 + 1, st)
	r = st + exp
	print(r - l + 1)


t = int(input())
while t:
	t = t - 1
	(s, i, e) = map(int, input().split())
	if e == 0:
		if s > i:
			print(1)
		else:
			print(0)
	elif s + e > i:
		inp = (i - s + e) // 2
		st = inp + 1
		if inp < 0:
			print(e + 1)
		else:
			print(e - st + 1)
	else:
		print(0)


t = int(input())
for i in range(t):
	(st, inte, ex) = map(int, input().split())
	if ex == 0:
		if st > inte:
			print(1)
		else:
			print(0)
	else:
		temp = st + ex
		if temp > inte:
			avg = (temp + inte) // 2
			print(min(temp - avg, temp - st + 1))
		else:
			print(0)


from math import ceil
t = int(input())
for i in range(t):
	(a, b, n) = map(int, input().split())
	if n == 0:
		if a > b:
			print('1')
		else:
			print('0')
	elif a == b:
		print(ceil(n / 2))
	elif a > b:
		print(min(ceil((a + n - b) / 2), n + 1))
	else:
		g = a
		a += b - a
		n -= b - g
		print(max(ceil(n / 2), 0))


q = int(input())
for i in range(q):
	(st, inte, ex) = [int(x) for x in input().split()]
	print(max(0, st + ex - max(st - 1, int((st + inte + ex) / 2))))


t = int(input())
for _ in range(t):
	(s, i, e) = map(int, input().split())
	d = (i + e - s) // 2 + 1
	print(max(0, min(e - d + 1, e + 1)))


import sys
from collections import deque
IS_LOCAL = False

def read_one(dtype=int):
	return dtype(input())

def read_multiple(f, dtype=int):
	return f(map(dtype, input().split()))

def swap(x, y):
	return (y, x)

def solve(s, i, e):
	x = min(max((s + e - i - 1) // 2 + 1, 0), e)
	if s + e - x > i + x:
		x += 1
	print(x)

def main():
	T = 4
	xs = [[1000, 1, 0], [2, 1, 0], [3, 5, 5], [4, 10, 6]]
	if not IS_LOCAL:
		T = read_one(int)
		for _ in range(T):
			(s, i, e) = read_multiple(tuple)
			solve(s, i, e)
	else:
		for (s, i, e) in xs:
			solve(s, i, e)
if len(sys.argv) > 1 and sys.argv[1] == 'True':
	IS_LOCAL = True
main()


T = int(input())
while T:
	(s, i, e) = map(int, input().split())
	x = i + e - s + 1
	if x >= 0:
		ans = 2 * e - x + 1
		if x % 2 == 0:
			ans += 1
	else:
		ans = 2 * e + 2
	if ans >= 0:
		print(ans // 2)
	else:
		print(0)
	T -= 1


q = int(input())
for i in range(q):
	(s, i1, ex) = map(int, input().strip().split(' '))
	c = 0
	if s + ex > i1:
		if (s + ex - i1) % 2 == 0:
			c = (s + ex - i1) // 2
		else:
			c = (s + ex - i1) // 2 + 1
	if c > ex:
		c = ex + 1
	print(c)


def kek(strong, intl, exp):
	if exp + strong <= intl:
		return 0
	l = 0
	r = exp + 1
	while l + 1 < r:
		m = (l + r) // 2
		if intl + m < strong + exp - m:
			l = m
		else:
			r = m
	return l + 1
n = int(input())
for i in range(n):
	(st, intel, exp) = list(map(int, input().split()))
	print(kek(st, intel, exp))


t = int(input())
for u in range(t):
	n = 0
	(s, i, e) = map(int, input().split())
	if s + e - i > 0:
		if (s + e - i) % 2 == 0:
			n = (s + e - i) / 2
		else:
			n = (s + e - i + 1) / 2
		if n > e + 1:
			n = e + 1
	print(int(n))


T = int(input())
for _ in range(T):
	(strr, intt, exp) = map(int, input().split())
	low = max(0, (exp + intt - strr + 2) // 2)
	print(max(0, exp - low + 1))


for _ in range(int(input())):
	(st, it, ex) = map(int, input().split())
	if st - it == ex:
		print(ex)
	elif st - it > ex:
		print(ex + 1)
	else:
		s = st - it
		x = (ex - s) // 2
		if ex - x > 0:
			print(ex - x)
		else:
			print(0)


import math
n = int(input())
for _ in range(n):
	inp = list(map(int, input().split()))
	s = inp[0]
	i = inp[1]
	exp = inp[2]
	if exp == 0 and s > i:
		print(1)
		continue
	elif exp == 0 and s <= i:
		print(0)
		continue
	result = min(exp + 1, max(0, math.ceil((s + exp - i) / 2)))
	print(result)


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
import itertools

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

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

def Lstr():
	return list(sys.stdin.readline().strip())

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

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

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

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

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

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

def solution():
	for _ in range(Int()):
		(s, i, e) = Mint()
		if s + e <= i:
			print(0)
		elif s > i + e:
			print(e + 1)
		else:
			print(e - (e + i - s) // 2)
solution()


import math
for _ in range(int(input())):
	(x, y, z) = map(int, input().split())
	minx = max(0, math.ceil((y + z - x + 1) / 2))
	print(max(0, z - minx + 1))


n = int(input())
for i in range(n):
	(x, y, z) = list(map(int, input().split()))
	print(int(max(0, z - max((y + z - x + 1) / 2, 0) + 1)))


for test in range(int(input())):
	(st, inte, ex) = map(int, input().split())
	if ex == 0:
		if st > inte:
			print(1)
		else:
			print(0)
	else:
		print(min(ex + 1, max(0, ex - (inte + ex - st) // 2)))


import sys
input = sys.stdin.readline
for i in range(int(input())):
	(s, i, e) = map(int, input().split())
	s += e
	if s <= i:
		print(0)
	else:
		yy = (s + i) // 2
		print(min(s - yy, e + 1))


for _ in range(int(input())):
	(s, i, exp) = map(int, input().split())
	l = 0
	h = exp
	if i - s >= exp:
		print(0)
	elif exp == 0:
		print(1)
	else:
		while l < h:
			mid = (l + h) // 2
			if s + mid <= i + (exp - mid):
				l = mid + 1
			else:
				h = mid
		print(exp - l + 1)


import math
n = int(input())
while n:
	n -= 1
	pp = 0
	(s, i, e) = map(int, input().split())
	g = (e + i - s + 2) / 2
	addS = max(0, g)
	h = e - addS + 1
	print(math.ceil(max(0, h)))


n = int(input())
for j in range(n):
	(st, i, ex) = list(map(int, input().split()))
	s = 0
	e = ex + 1
	while s < e:
		m = (s + e) // 2
		if st + m > i + ex - m:
			e = m
		else:
			s = m + 1
	if s > ex:
		print(0)
	else:
		print(ex + 1 - s)


for _ in range(int(input())):
	(s, i, e) = input().split(' ')
	s = int(s)
	i = int(i)
	e = int(e)
	s = s + e
	if s > i and e != 0:
		temp = (s - i) // 2
		temp = i + temp
		temp = s - temp
		if temp > e:
			s = s - e
			if s - i > e:
				print(e + 1)
			else:
				print(e)
		else:
			s = s - e
			if s - i > e:
				print(temp + 1)
			else:
				print(temp)
	elif s > i and e == 0:
		print(1)
	else:
		print(0)


def busqueda_binaria(strg, intg, exp):
	minimo = 0
	maximo = exp
	ultimo_valido = -1
	intg_base = intg
	strg_base = strg
	while maximo >= minimo:
		medio = int((minimo + maximo) / 2)
		intg = intg_base + medio
		exp_restante = exp - medio
		strg = strg_base + exp_restante
		if strg > intg:
			ultimo_valido = medio
			minimo = medio + 1
		else:
			maximo = medio - 1
	return ultimo_valido + 1

def pj_posibilidad(strg, intg, exp):
	maneras = busqueda_binaria(strg, intg, exp)
	return maneras

def recv_pj():
	results = list()
	queries = input()
	num_pj = int(queries)
	for i in range(num_pj):
		querie = input()
		pj_desc = querie.split(' ')
		res = pj_posibilidad(int(pj_desc[0]), int(pj_desc[1]), int(pj_desc[2]))
		results.append(res)
	for result in results:
		print(result)

def main():
	recv_pj()
main()


import math
t = int(input())
for nt in range(t):
	(s, i, e) = map(int, input().split())
	temp = i + e
	if temp < s:
		print(e + 1)
	else:
		print(max(0, e + 1 - (temp - s) // 2 - 1))


from math import ceil

def main():
	c = int(input())
	for i in range(c):
		(str2, int2, c) = [int(v) for v in input().split()]
		if str2 + c <= int2:
			print(0)
			continue
		x = (int2 + c - str2) // 2 + 1
		if x > 0:
			if x <= c:
				print(c + 1 - x)
			else:
				print(0)
		else:
			print(c + 1)
main()


t = int(input())
for _ in range(t):
	(stre, inte, exp) = map(int, input().split())
	add = max(0, (exp + inte - stre + 2) // 2)
	print(max(0, exp - add + 1))


for _ in range(int(input())):
	(str, _int, exp) = map(int, input().split())
	val = (str + _int + exp) // 2
	if str + exp - val < 0:
		print(0)
		continue
	if str > val:
		print(exp + 1)
	else:
		print(str + exp - val)


for _ in range(int(input())):
	(Str, Int, Exp) = map(int, input().split())
	print(max(min((Str + Int + Exp + 1) // 2, Int + Exp + 1) - Int, 0))


import math
T = int(input())
for _ in range(T):
	(s, i, e) = [int(j) for j in input().split()]
	xmax = e
	xmin = max(0, math.ceil((i + e - s) / 2 + 0.5))
	ans = max(0, xmax - xmin + 1)
	print(ans)


t = int(input())
while t:
	t -= 1
	(a, b, c) = [int(x) for x in input().split()]
	if a + c <= b:
		print(0)
	else:
		c -= max(0, b - a)
		a += max(0, b - a)
		if a == b:
			print(c - (c // 2 + 1) + 1)
		else:
			c -= a - b
			if c >= 0:
				print(a - b + c - (c // 2 + 1) + 1)
			else:
				print(c + a - b + 1)


t = int(input())
for i in range(t):
	(strength, intelligence, exp) = map(int, input().split())
	k = int((intelligence + exp - strength) // 2)
	if k < 0:
		print(exp + 1)
		continue
	if exp == 0 and strength > intelligence:
		print(1)
		continue
	print(max(min(exp, exp - k), 0))


def solve():
	(s, i, e) = map(int, input().split())
	lo = 0
	hi = e
	while lo < hi:
		mid = lo + (hi - lo >> 1)
		if s + mid > i + (e - mid):
			hi = mid
		else:
			lo = mid + 1
	if s + lo > i + (e - lo):
		print(e - lo + 1)
	else:
		print(0)
t = int(input())
for _ in range(t):
	solve()


T = int(input().strip())
for t in range(T):
	(s, i, n) = [int(x) for x in input().strip().split()]
	if (n + s - i) % 2 == 0:
		res = (n + s - i) / 2
	else:
		res = (n + s - i + 1) / 2
	print(max(min(int(res), n + 1), 0))


for _ in range(int(input())):
	(s, i, e) = list(map(int, input().strip().split()))
	if s + e <= i:
		ans = 0
	elif e == 0:
		ans = 1
	else:
		(au, bu) = (s + e, i)
		(ad, bd) = (s, i + e)
		if ad > bd:
			ans = au - ad + 1
		elif ad == bd:
			ans = au - ad
		else:
			ans = au - ad - (bd - ad) // 2
	print(ans)


t = int(input())
for j in range(t):
	(s, i, exp) = map(int, input().split())
	flag = 0
	if exp == 0 and s > i:
		print(1)
		flag = 1
	if exp == 0 and s <= i and (flag == 0):
		print(0)
		flag = 1
	if exp > 0 and s < i and (flag == 0):
		if s + exp <= i:
			print(0)
		if s + exp > i:
			if (s + i + exp) % 2 == 0:
				print((i + s + exp) // 2 - i)
			else:
				print((i + s + exp) // 2 - i + 1)
		flag = 1
	if exp > 0 and s == i and (flag == 0):
		if exp % 2 == 0:
			print(int(exp / 2))
		else:
			print(exp // 2 + 1)
		flag = 1
	if exp > 0 and s > i and (flag == 0):
		if i + exp == s:
			print(exp)
		if i + exp < s:
			print(exp + 1)
		if i + exp > s:
			if (s + i + exp) % 2 == 0:
				print((i + s + exp) // 2 - i)
			else:
				print((i + s + exp) // 2 - i + 1)
		flag = 1


n = int(input())
for i in range(n):
	(s, i, exp) = list(map(float, input().split()))
	x = (i + exp - s) / 2
	if x < 0:
		print(int(exp) + 1)
	elif x == 0:
		print(int(exp))
	else:
		import math
		if exp - math.floor(x) < 0:
			print('0')
		else:
			print(int(exp - math.floor(x)))


n = int(input())
power = [0] * n
intelegent = [0] * n
exp = [0] * n
f = [0] * n
for i in range(n):
	(power[i], intelegent[i], exp[i]) = [int(i) for i in input().split()]
for i in range(n):
	r = power[i] - intelegent[i]
	if r < -exp[i]:
		f[i] = 0
	elif r > exp[i]:
		f[i] = exp[i] + 1
	elif exp[i] == r:
		f[i] = exp[i]
	elif (exp[i] - r) % 2 == 0:
		f[i] = exp[i] + 1 - ((exp[i] - r) // 2 - 1 + 2)
	else:
		f[i] = exp[i] + 1 - ((exp[i] - r) // 2 + 1)
for i in f:
	print(i)


T = int(input())
ss = []
for i in range(T):
	(s, i, e) = map(int, input().split())
	if s - i > e:
		otv = e + 1
		ss.append(otv)
	if s - i == e:
		otv = e
		ss.append(otv)
	if s - i < e:
		import math
		otv = math.ceil((e + (s - i)) / 2)
		if otv <= 0:
			ss.append(0)
		else:
			ss.append(otv)
for i in range(len(ss)):
	print(int(ss[i]))


import os
import sys
from io import BytesIO, IOBase
import math
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')
for _ in range(int(input())):
	(x, y, z) = map(int, input().split())
	tl = max((y + z - x + 2) // 2, 0)
	tr = z
	print(max(0, tr - tl + 1))


qtos_casos = int(input())
for x in range(0, qtos_casos):
	(a, b, c) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	adds = max(0, (b + c - a + 2) // 2)
	resp = max(0, c - adds + 1)
	print(resp)


from sys import stdin
input = stdin.readline
t = int(input())
for _ in range(t):
	(a, b, exp) = [int(x) for x in input().split()]
	x = -1
	l = 0
	r = exp + 1
	while l < r:
		m = l + (r - l) // 2
		if a + m > b + (exp - m):
			x = m
			r = m
		else:
			l = m + 1
	if x == -1:
		print(0)
	else:
		print(exp - x + 1)


def func(s, i, e):
	if s + e <= i:
		return 0
	else:
		tot = s + e + i
		mid = int(tot / 2) + 1
		ans = s + e - mid + 1
		return min(e + 1, ans)
T = int(input())
for _ in range(T):
	(s, i, e) = map(int, input().split())
	ans = func(s, i, e)
	print(ans)


import math

def new_cal(a, b, c):
	rr = a + c
	if rr > b:
		l = 0
		r = c
		ans = 0
		while l <= r:
			mid = (l + r) // 2
			if a + mid > b + (c - mid):
				ans = mid
				r = mid - 1
			else:
				l = mid + 1
		res = rr - (ans + a - 1)
	else:
		res = 0
	return res
a = int(input())
for _ in range(a):
	(s, i, p) = map(int, input().split())
	total = new_cal(s, i, p)
	print(total)


import math
t = int(input())
f = []
for j in range(t):
	(s, i, e) = map(int, input().split())
	if i + e >= s:
		k = math.ceil((s + e - i) / 2)
	else:
		k = e + 1
	if k <= 0:
		f += [0]
	else:
		f += [k]
for i in f:
	print(i)


T = int(input())
for _ in [0] * T:
	(s, i, e) = map(int, input().split())
	if e == 0 and s > i:
		print(1)
		continue
	if s < i:
		e -= i - s
		s = i
	if e <= 0:
		print(0)
		continue
	print(min((s + e - i + 1) // 2, e + 1))


import math
t = int(input())
for j in range(t):
	(a, b, c) = map(int, input().strip().split())
	tmp = (b - a + c) / 2
	if tmp > c:
		print(0)
	elif 0 < tmp <= c:
		print(c - math.floor(tmp))
	elif tmp == 0:
		print(c)
	elif tmp < 0:
		print(c + 1)


def STR():
	return list(input())

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

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

def MAP2():
	return map(float, input().split())

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

def STRING():
	return input()
from heapq import heappop, heappush
from bisect import *
from collections import deque, Counter
from math import *
from itertools import permutations
dx = [-1, 1, 0, 0]
dy = [0, 0, 1, -1]
for tt in range(INT()):
	(x, y, z) = MAP()
	if z == 0 and x <= y:
		print(0)
	elif z == 0 and x > y:
		print(1)
	elif x + z <= y:
		print(0)
	else:
		(l, r) = (0, z)
		while l <= r:
			mid = l + (r - l) // 2
			if x + (z - mid) > mid + y:
				l = mid + 1
			else:
				r = mid - 1
		if r >= 0:
			print(r + 1)
		else:
			print(0)


T = int(input())
for i in range(T):
	inp = input()
	inp_arr = inp.split(' ')
	inp_arr_int = []
	for i in inp_arr:
		inp_arr_int.append(int(i))
	str_var = inp_arr_int[0]
	int_var = inp_arr_int[1]
	exp_var = inp_arr_int[2]
	if (int_var + exp_var - str_var + 1) % 2 == 0:
		minimum = max(0, (int_var + exp_var - str_var + 1) // 2)
	else:
		minimum = max(0, (int_var + exp_var - str_var + 1) // 2 + 1)
	if minimum > exp_var:
		print(0)
	else:
		print(exp_var - minimum + 1)


for _ in range(int(input())):
	(st, i, ex) = map(int, input().split())
	minAddStr = max(0, (ex + i - st + 2) // 2)
	print(int(max(ex - minAddStr + 1, 0)))


t = int(input())
for i in range(t):
	(stren, intel, exp) = map(int, input().split())
	if exp == 0:
		if intel < stren:
			print(1)
		else:
			print(0)
	elif intel > stren:
		if intel - stren - 1 >= exp:
			print(0)
		else:
			exp -= intel - stren + 1
			print(exp // 2 + 1)
	elif intel == stren:
		exp -= 1
		print(exp // 2 + 1)
	elif stren - intel - 1 >= exp:
		print(exp + 1)
	else:
		print((exp - (stren - intel - 1)) // 2 + stren - intel)


def solve(s, i, e):
	mx = s + e
	mn = max(s, (s + i + e) // 2 + 1)
	if mn > mx:
		return 0
	return mx - mn + 1

def main():
	from sys import stdin
	T = int(stdin.readline().strip())
	for _ in range(T):
		(s, i, e) = list(map(int, stdin.readline().strip().split()))
		print(solve(s, i, e))
main()


t = int(input())
for test in range(t):
	(stre, inte, expe) = [int(s) for s in input().split(' ')]
	aux = (stre + expe - inte) / 2
	if aux < 0:
		print(0)
	elif int(aux) == aux:
		print(min(int(aux), expe + 1))
	else:
		print(min(int(aux) + 1, expe + 1))


import math
t = int(input())
while t > 0:
	(s, i, e) = map(int, input().split())
	minAdds = max(0, (e - s + i + 2) // 2)
	print(max(0, e - minAdds + 1))
	t -= 1


n = int(input())
for i in range(n):
	(s, i, e) = (int(i) for i in input().split())
	if s > i + e:
		print(e + 1)
	elif s + e <= i:
		print(0)
	else:
		r = s - i
		r = e + r
		t = 0
		if r % 2:
			t = 1
		r = r // 2
		if t:
			r += 1
		print(r)


T_T = int(input().strip())
while T_T:
	T_T = T_T - 1
	(strength, intelligence, experence) = map(int, input().strip().split())
	ans = 0
	dif = strength + experence - intelligence
	if strength > intelligence + experence:
		print(experence + 1)
	elif dif <= 0:
		print(0)
	elif experence == 0:
		print(1)
	else:
		print(min(dif + 1 >> 1, experence))


Q = int(input())
for q in range(Q):
	(a, b, c) = tuple(map(int, input().split()))
	d = a
	a += c
	if a <= b:
		print(0)
	else:
		print(1 + min(a - d, (a - b - 1) // 2))


import math
t = int(input())
for i in range(t):
	(str1, int1, exp) = list(map(int, input().split()))
	x = str1 + exp
	if x > int1:
		if int1 + exp < str1:
			print(exp + 1)
		else:
			print(math.ceil((x - int1) / 2.0))
	else:
		print(0)


t = int(input())
while t:
	t -= 1
	(_str, _int, _exp) = map(int, input().split())
	_str -= 1
	x = int(max((_int - _str + 1 + _exp) / 2, 0))
	print(max(0, _exp - x + 1))


from sys import stdin, stdout
from collections import Counter
import math

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

def rmult_int():
	return [int(x) for x in stdin.readline().rstrip().split()]

def rmult_str():
	return stdin.readline().rstrip().split()

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

def rsingle_char():
	return stdin.read(1)

def main():
	t = rsingle_int()
	for i in range(t):
		(s, intel, exp) = rmult_int()
		if exp <= intel - s:
			print(0)
		elif exp == 0:
			print(1)
		elif s <= intel:
			print(math.ceil((s + exp - intel) / 2))
		elif s - intel == 1:
			print('{}'.format(exp // 2 + 1))
		elif s - intel > exp:
			print('{}'.format(exp + 1))
		else:
			res = exp // 2 + 1
			if exp % 2 == 0:
				res += math.ceil((s - intel) / 2) - 1
				print('{}'.format(res))
			else:
				res += (s - intel) // 2
				print('{}'.format(res))
main()


import math
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	if a - b > c:
		print(c + 1)
	elif b - a > c:
		print(0)
	else:
		ans = (a - b + c) / 2
		if ans < 0:
			ans = 0
		print(math.ceil(ans))


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(a, b, c) = map(int, sys.stdin.readline().split())
	(l, r) = (0, 100000000000)
	ans = 0
	while l <= r:
		mid = (l + r) // 2
		k = mid
		if a + c - b - 2 * (k - 1) >= 1 and k - 1 <= c:
			ans = mid
			l = mid + 1
		else:
			r = mid - 1
	print(ans)


def main():
	t = int(input())
	for i in range(t):
		(strength, intel, exp) = map(int, input().split())
		if strength + exp <= intel:
			print(0)
		else:
			num = exp + strength - intel
			if num % 2 == 0:
				ans = num // 2
			else:
				ans = num // 2 + 1
			ans = min(ans, exp + 1)
			print(ans)
main()


for _ in range(int(input())):
	(s, i, e) = list(map(int, input().split()))
	if i > s:
		e -= i - s
	s = max(s, i)
	ans = 0
	if s > i:
		ans += max(1, min(s - i, e + 1))
		e -= s - i
		e = max(e, 0)
		i = s
	if e < 0:
		print(0)
		continue
	if e == 0:
		print(ans)
		continue
	print(ans + (e + 1) // 2)


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


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


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


n = int(input())
for _ in range(n):
	(a, b, c) = [int(e) for e in input().split()]
	mx = a + c
	mn = max(a, a + (b - a + c) // 2 + 1)
	print(max(0, mx - mn + 1))