A. Creating a Character(Educational Codeforces Round 72 (Rated for Div. 2) )

< div>

You play your favourite game yet another time. You chose the character you didn’t play before. It has str

“>strstr points of strength and in t

“>intint points of intelligence. Also, at start, the character has exp

“>expexp free experience points you can invest either in strength or in intelligence (by investing one point you can either raise strength by 1

“>11or raise intelligence by1

” >11).

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). p>

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 math>”>TT (1 T100

“> 1T100 1≤T≤100) — the number of queries. NextT

“> TT lines contain descriptions of queries — one per line.< /span>

This line contains three integers st r

“>str< /span>str, int

“>int int and exp

“>expexp (1< mi>str,in t108

“>1s tr,int1081 ≤str,int≤108, 0exp< /mi>108

“>0ex< span id="MathJax-Span-71" class="mi">p108 0≤exp≤108) — the initial strength and intelligence of the character and the number of free points, respectively.

Output

Print T

“>T Tintegers — one per query. For each query print the number of different character builds you can create.< /p>

Example
input

Copy
4

5 3 4
2 1 0
3 5 5
4 10 6

output

Copy

3

1
2
0

Note

In the first query there are only three appropriate character builds:(str=7,int= 5)

“>( str=7,in t=5)< /span>(str=7,int=5), (< mn>8,4)

“>(8,4)(8,4) and (9,3)

“>(9,3)< /span>(9,3). All other builds are either too smart or don’t use all free points.< /span>

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

“>(2,1) span>(2,1). p>

In the third query there are two appropriate builds:(7, 6)

“>(7,6)(7,6), (8,5)

“>(8,5)(8,5).

In the fourth query all builds have too much brains.

< pre>int main()

{

int cnt,n,m,k;

while(cin>>n)

{

while(n–)

{

cin
>>m>>k>>cnt;

cout
<1)/2, 0), cnt+1 )<<endl;

}

}

ok;

}

You play your favourite game yet another time. You chose the character you didn’t play before. It has str

“>str span>str points of strength and int

“>i nt span>int points of intelligence. Also, at start, the character hasexp

“>expexp free experience points you can invest either in strength or in intelligence (by investing one point you can either raise strength by 1

“>1 1 or raise intelligence by1

“>11).< /span>

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 dif ferent 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

“>TT (1< mo>≤T100

“>1T1001≤T≤100) — the number of queries. Next T

“>TT lines contain descriptions of queries — one per line.

This line contains three integers str

“>st< span id="MathJax-Span-39" class="mi">rstr, int

“>in tint and exp

“>expexp (< mn>1str, int108

“>1str,int10 8< /span>1≤str,int≤108, 0< mi>exp108< /mn>

“>0 exp1080≤exp≤108) — the initial strength and intelligence of the character and the number of free points, respectively. span>

Output

PrintT

“>TTintegers — one per query . For each query print the number of different character builds you can create.

Example

input

Copy

4

5 3 4
2 1 0
3 5 5
4 10 6

output

Copy

3

1
2
0

Note

In the first query there are only three appropriate character builds:(str=7,int= 5)

“>( str=7,int=5) (str=7,int=5), (8 ,4)

“>(8,4)( 8,4) and (9,3)

“>(9 ,3)< /span>(9,3). All other builds are either too smart or don’t use all free points.< /span>

In the second query there is only one possible build:< span class="MathJax_Preview">(2,1) mo>

“>(2,1)(2,1).

In the third query there are two appropriate builds: (7,6 )

“>(7,6)(7,6), (8,5)“>(8,5)(8,5).

In the fourth query all builds have too much brains.

< span style="color: #0000ff;">int main()

{
int cnt,n,m,k;
while(cin>>n)
{
while(n--)
{
cin
>>m>>k>>cnt;
cout
<1)/2, 0), cnt+1 )<<endl;
}
}
ok;
}

You play your favourite game yet another time. You chose the character you didn’t play before. It has str

“>strstr points of strength and  int

“>intint points of intelligence. Also, at start, the character has exp

“>expexp free experience points you can invest either in strength or in intelligence (by investing one point you can either raise strength by 1

“> 11 or raise intelligence by 1

“>11).

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 replayabili ty) 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

“>TT (1T100

“>1T1001≤T≤100) — the number of queries. Next T

“>TT lines contain descriptions of queries — one per line.

This line contains three integers str

“> strstr, int

“>intint and exp

“>expexp (1str,int108

“>1str,int10< span id="MathJax-Span-64" class="mn">81≤str,int≤108, 0exp108

“>0exp1080≤exp≤108) — the initial strength and intelligence of the character and the number of free points, respectively.

Output

Print T

“>TT integers — one per query. For each query print the number of different character builds you can create.

Example
input

Copy

4

5 3 4
2 1 0
3 5 5
4 10 6

output

Copy

3

1
2
0

Note

In the first query there are only three appropriate character builds: (str=7,int=5)

“>(str=7,int=5)(str=7,int=5), (8,4)

“>(8,4)(8,4) and (9,3)

“>(9,3)(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)

“>(2,1)(2,1).

In the third query there are two appropriate builds: (7,6)

“>(7,6)(7,6), (8,5)

“>(8,5)(8,5).

In the fourth query all builds have too much brains.

 

 

int main()

{
int cnt,n,m,k;
while(cin>>n)
{
while(n--)
{
cin
>>m>>k>>cnt;
cout
<1)/2 , 0 ) , cnt+1 )<<endl;
}
}
ok;
}

You play your favourite game yet another time. You chose the character you didn‘t play before. It has str

“>strstr points of strength and int

“>intint points of intelligence. Also, at start, the character has exp

“>expexp free experience points you can invest either in strength or in intelligence (by investing one point you can either raise strength by 1

“>11 or raise intelligence by 1

“>11).

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

“>TT (1T100

“>1T1001≤T≤100) — the number of queries. Next T

“>TT lines contain descriptions of queries — one per line.

This line contains three integers str

“>strstr, int

“>intint and exp

“>expexp (1str,int108

“>1str,int1081≤str,int≤108, 0exp108

“>0exp1080≤exp≤108) — the initial strength and intelligence of the character and the number of free points, respectively.

Output

Print T

“>TT integers — one per query. For each query print the number of different character builds you can create.

Example
input

Copy

4

5 3 4
2 1 0
3 5 5
4 10 6

output

Copy

3

1
2
0

Note

In the first query there are only three appropriate character builds: (str=7,int=5)

“>(str=7,int=5)(str=7,int=5), (8,4)

“>(8,4)(8,4) and (9,3)

“>(9,3)(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)

“>(2,1)(2,1).

In the third query there are two appropriate builds: (7,6)

“>(7,6)(7,6), (8,5)

“>(8,5)(8,5).

In the fourth query all builds have too much brains.

 

 

int main()

{
int cnt,n,m,k;
while(cin>>n)
{
while(n--)
{
cin
>>m>>k>>cnt;
cout
<1)/2 , 0 ) , cnt+1 )<<endl;
}
}
ok;
}

You play your favourite game yet another time. You chose the character you didn‘t play before. It has str

“>strstr points of strength and int

“>intint points of intelligence. Also, at start, the character has exp

“>expexp free experience points you can invest either in strength or in intelligence (by investing one point you can either raise strength by 1

“>11 or raise intelligence by 1

“>11).

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

“>TT (1T100

“>1T1001≤T≤100) — the number of queries. Next T

“>TT lines contain descriptions of queries — one per line.

This line contains three integers str

“>strstr, int

“>intint and exp

“>expexp (1str,int108

“>1str,int1081≤str,int≤108, 0exp108

“>0exp1080≤exp≤108) — the initial strength and intelligence of the character and the number of free points, respectively.

Output

Print T

“>TT integers — one per query. For each query print the number of different character builds you can create.

Example
input

Copy

4

5 3 4
2 1 0
3 5 5
4 10 6

output

Copy

3

1
2
0

Note

In the first query there are only three appropriate character builds: (str=7,int=5)

“>(str=7,int=5)(str=7,int=5), (8,4)

“>(8,4)(8,4) and (9,3)

“>(9,3)(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)

“>(2,1)(2,1).

In the third query there are two appropriate builds: (7,6)

“>(7,6)(7,6), (8,5)

“>(8,5)(8,5).

In the fourth query all builds have too much brains.

 

 

int main()

{
int cnt,n,m,k;
while(cin>>n)
{
while(n--)
{
cin
>>m>>k>>cnt;
cout
<1)/2 , 0 ) , cnt+1 )<<endl;
}
}
ok;
}

You play your favourite game yet another time. You chose the character you didn‘t play before. It has str

“>strstr points of strength and int

“>intint points of intelligence. Also, at start, the character has exp

“>expexp free experience points you can invest either in strength or in intelligence (by investing one point you can either raise strength by 1

“>11 or raise intelligence by 1

“>11).

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

“>TT (1T100

“>1T1001≤T≤100) — the number of queries. Next T

“>TT lines contain descriptions of queries — one per line.

This line contains three integers str

“>strstr, int

“>intint and exp

“>expexp (1str,int108

“>1str,int1081≤str,int≤108, 0exp108

“>0exp1080≤exp≤108) — the initial strength and intelligence of the character and the number of free points, respectively.

Output

Print T

“>TT integers — one per query. For each query print the number of different character builds you can create.

Example
input

Copy

4

5 3 4
2 1 0
3 5 5
4 10 6

output

Copy

3

1
2
0

Note

In the first query there are only three appropriate character builds: (str=7,int=5)

“>(str=7,int=5)(str=7,int=5), (8,4)

“>(8,4)(8,4) and (9,3)

“>(9,3)(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)

“>(2,1)(2,1).

In the third query there are two appropriate builds: (7,6)

“>(7,6)(7,6), (8,5)

“>(8,5)(8,5).

In the fourth query all builds have too much brains.

 

You play your favourite game yet another time. You chose the character you didn‘t play before. It has str

“>strstr points of strength and int

“>intint points of intelligence. Also, at start, the character has exp

“>expexp free experience points you can invest either in strength or in intelligence (by investing one point you can either raise strength by 1

“>11 or raise intelligence by 1

“>11).

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

“>TT (1T100

“>1T1001≤T≤100) — the number of queries. Next T

“>TT lines contain descriptions of queries — one per line.

This line contains three integers str

“>strstr, int

“>intint and exp

“>expexp (1str,int108

“>1str,int1081≤str,int≤108, 0exp108

“>0exp1080≤exp≤108) — the initial strength and intelligence of the character and the number of free points, respectively.

Input

Output

Print T

“>TT integers — one per query. For each query print the number of different character builds you can create.

Output

Example
input

Copy

4

5 3 4
2 1 0
3 5 5
4 10 6

output

Copy

3

1
2
0

Example

input

Copy

4

5 3 4
2 1 0
3 5 5
4 10 6

output

Copy

3

1
2
0

input

Copy

4

5 3 4
2 1 0
3 5 5
4 10 6

input

Copy

Copy

output

Copy

3

1
2
0

output

Copy

Copy

Note

In the first query there are only three appropriate character builds: (str=7,int=5)

“>(str=7,int=5)(str=7,int=5), (8,4)

“>(8,4)(8,4) and (9,3)

“>(9,3)(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)

“>(2,1)(2,1).

In the third query there are two appropriate builds: (7,6)

“>(7,6)(7,6), (8,5)

“>(8,5)(8,5).

In the fourth query all builds have too much brains.

 

Note

int main()

{
int cnt,n,m,k;
while(cin>>n)
{
while(n--)
{
cin
>>m>>k>>cnt;
cout
<1)/2 , 0 ) , cnt+1 )<<endl;
}
}
ok;
}

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 553 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.