The All-Berland Team Programming Contest will take place very soon. This year, teams of four are allowed to participate.There are $$$a$$$ programmers and $$$b$$$ mathematicians at Berland State University. How many maximum teams can be made if:  each team must consist of exactly $$$4$$$ students,  teams of $$$4$$$ mathematicians or $$$4$$$ programmers are unlikely to perform well, so the decision was made not to compose such teams. Thus, each team must have at least one programmer and at least one mathematician.Print the required maximum number of teams. Each person can be a member of no more than one team.

The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) —the number of test cases. This is followed by descriptions of $$$t$$$ sets, one per line. Each set is given by two integers $$$a$$$ and $$$b$$$ ($$$0 \le a,b \le 10^9$$$).

Print $$$t$$$ lines. Each line must contain the answer to the corresponding set of input data — the required maximum number of teams.

NoteIn the first test case of the example, two teams can be composed. One way to compose two teams is to compose two teams of $$$2$$$ programmers and $$$2$$$ mathematicians.In the second test case of the example, only one team can be composed: $$$3$$$ programmers and $$$1$$$ mathematician in the team.

package main
import "fmt"

func countways(a, b int) int{
	if a > b{
		return countways(b, a)
	} else if a!=0 && b / a >= 3{
		return a
	} else if a==0 {
		return 0
	} else{
		d := b - a
		count := int(d / 2)
		b -= 3*count
		a -= count
		count += int((a+b)/4)
		return count
	}
}

func main(){
	var N_INPS, a, b ,i int
	fmt.Scanf("%d\n",&N_INPS)
	var inps [][2]int
	for i=0; i<N_INPS;i++{
		fmt.Scanf("%d %d\n", &a, &b)
		inps = append(inps,[2]int{a,b})
	}
	for _, inp := range inps{
		fmt.Println(countways(inp[0], inp[1]))
	}
}

package main
import "fmt"

func countways(a, b int64) int64{
	if a > b{
		return countways(b, a)
	} else if b > 3*a {
		return a
	} else if a == b {
		return int64(a/2)
	} else{
		d := b - a
		count := int64(d / 2)
		b -= 3*count
		a -= count
		count += int64((a+b)/4)
		return count
	}
}

func main(){
	var N_INPS, a, b ,i int64
	fmt.Scanf("%d\n",&N_INPS)
	var inps [][2]int64
	for i=0; i<N_INPS;i++{
		fmt.Scanf("%d %d\n", &a, &b)
		inps = append(inps,[2]int64{a,b})
	}
	for _, inp := range inps{
		fmt.Println(countways(inp[0], inp[1]))
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var a,b int
		fmt.Fscan(in,&a,&b)
		fmt.Fprintln(out,min((a+b)/4,min(a,b)))
	}
}
func min (x,y int) int {
	if x>y{
		return y
	} else {
		return x
	}
}

package main

import (
	"fmt"
)

func solve(){
	var a,b int64
	fmt.Scan(&a,&b)
	if a < b{
		a,b = b,a
	}
	if a > 3 * b{
		fmt.Println(b)
	}else{
		fmt.Println((a + b) / 4)
	}
}

func main(){
	n := 0
	fmt.Scan(&n)
	for i := 0;i < n;i++{
		solve()
	}
}

package main

import (
	"fmt"
)

func solve(){
	var a,b int64
	fmt.Scan(&a,&b)
	if a < b{
		a,b = b,a
	}
	if a >= 3 * b{
		fmt.Println(b)
	}else{
		fmt.Println((a + b) / 4)
	}
}

func main(){
	n := 0
	fmt.Scan(&n)
	for i := 0;i < n;i++{
		solve()
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
var sc = bufio.NewScanner(os.Stdin)

func scan() string {
	for sc.Scan() {
		break
	}
	return sc.Text()
}

func scanInt64() int64 {
	i, err := strconv.ParseInt(scan(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func scanInt() int {
	i, err := strconv.Atoi(scan())
	if err != nil {
		panic(err)
	}
	return i
}

func solve(){

}

func main(){
	sc.Split(bufio.ScanWords)
	n := scanInt()
	for i := 0;i < n;i++{
		a := scanInt64()
		b := scanInt64()
		if a < b{
			a,b = b,a
		}
		if a >= 3 * b{
			fmt.Println(b)
		}else{
			fmt.Println((a + b) / 4)
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
)

//goland:noinspection GoUnusedFunction
func min(a int, nums ...int) int {
	min := a

	for _, num := range nums {
		if num < min {
			min = num
		}
	}
	return min
}

//goland:noinspection GoUnusedFunction
func max(a int, nums ...int) int {
	max := a

	for _, num := range nums {
		if num > max {
			max = num
		}
	}
	return max
}

//goland:noinspection GoUnusedFunction
func fprintlnArr(w io.Writer, arr []int) {
	for _, val := range arr {
		fmt.Fprint(w, val, " ")
	}
	fmt.Fprintln(w)
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		var a, b int
		fmt.Fscan(in, &a, &b)
		fmt.Fprintln(out, sort.Search((a+b)/4, func(x int) bool {
			return min(a, b) <= x
		}))
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
)

//goland:noinspection GoUnusedFunction
func min(a int, nums ...int) int {
	min := a

	for _, num := range nums {
		if num < min {
			min = num
		}
	}
	return min
}

//goland:noinspection GoUnusedFunction
func max(a int, nums ...int) int {
	max := a

	for _, num := range nums {
		if num > max {
			max = num
		}
	}
	return max
}

//goland:noinspection GoUnusedFunction
func fprintlnArr(w io.Writer, arr []int) {
	for _, val := range arr {
		fmt.Fprint(w, val, " ")
	}
	fmt.Fprintln(w)
}

func upperBoundSearch(a int, b int) int {
	l, r := 0, (a+b)/4
	for l < r {
		x := l + (r-l)/2
		if min(a, b) > x {
			l = x + 1
		} else {
			r = x
		}
	}

	return l
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		var a, b int
		fmt.Fscan(in, &a, &b)
		fmt.Fprintln(out, sort.Search((a+b)/4, func(x int) bool {
			return min(a, b) <= x
		}))
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

//goland:noinspection GoUnusedFunction
func min(a int, nums ...int) int {
	min := a

	for _, num := range nums {
		if num < min {
			min = num
		}
	}
	return min
}

//goland:noinspection GoUnusedFunction
func max(a int, nums ...int) int {
	max := a

	for _, num := range nums {
		if num > max {
			max = num
		}
	}
	return max
}

//goland:noinspection GoUnusedFunction
func fprintlnArr(w io.Writer, arr []int) {
	for _, val := range arr {
		fmt.Fprint(w, val, " ")
	}
	fmt.Fprintln(w)
}

func upperBoundSearch(a int, b int) int {
	l, r := 0, (a+b)/4
	for l < r {
		x := l + (r-l)/2
		if min(a, b) > x {
			l = x + 1
		} else {
			r = x
		}
	}

	return l
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		var a, b int
		fmt.Fscan(in, &a, &b)
		fmt.Fprintln(out, upperBoundSearch(a, b))
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

//goland:noinspection GoUnusedFunction
func min(a int, nums ...int) int {
	min := a

	for _, num := range nums {
		if num < min {
			min = num
		}
	}
	return min
}

//goland:noinspection GoUnusedFunction
func max(a int, nums ...int) int {
	max := a

	for _, num := range nums {
		if num > max {
			max = num
		}
	}
	return max
}

//goland:noinspection GoUnusedFunction
func FprintlnArr(w io.Writer, arr []int) {
	for _, val := range arr {
		fmt.Fprint(w, val, " ")
	}
	fmt.Fprintln(w)
}

func upperBoundSearch(a int, b int) int {
	l, r := 0, (a+b)/4
	for l < r {
		x := l + (r-l)/2
		if x >= 0 && min(a, b) > x {
			l = x + 1
		} else {
			r = x
		}
	}

	return l
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		var a, b int
		fmt.Fscan(in, &a, &b)
		fmt.Fprintln(out, upperBoundSearch(a, b))
	}
}

package main

import (
    "bufio"
    "fmt"
    "os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func min(a,b int) int{
    if a < b {
        return a
    }
    return b
}

func solve() {
    var a,b, ans int
    scanf("%d %d\n", &a, &b)

    if a > b {
        b, a = a,b
    }

    k := (b-a)/2
    k = min(min(k, a), b/3)
    ans = k+min(a-k,(b-3*k))/2
    printf("%d\n", ans)

}

func main() {

    defer writer.Flush()

    var tc int
    scanf("%d\n", &tc)
    for ;tc>0;tc-- {
        solve()
    }
}

package main

import (
	"fmt"
)
func main() {
	var n, cs, ma, max, min int;
	var list []int;
	fmt.Scan(&n);
	for i:=0;i<n;i++{
		fmt.Scan(&cs, &ma);
		max = int((cs + ma) / 4);
		min = mins(cs, ma);
		list = append(list, mins(max, min));
	}
	for _, ival := range list{
		fmt.Println(ival);
	}
	return;
}
func mins (a int, b int) int {
	if b < a {
		return b;
	}
	return a;
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func CF1611B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, A, B int
	for fmt.Fscan(in, &T); T > 0; T-- {
		fmt.Fscan(in, &A, &B)
		result := min((A+B)/4, min(A, B))
		fmt.Fprintln(out, result)
	}
}

func min(i, j int) int {
	if i < j {
		return i
	}
	return j
}

func main() {
	CF1611B(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"math"
	"os"
	"strconv"
)

func solve() {
	a := get64()
	b := get64()
	if a > b {
		a, b = b, a
	}

	f := func(g int64) int64 {
		a0 := a - 2*g
		b0 := b - 2*g
		rest := min64(a0, b0/3)
		return g + rest
	}

	l, r := L(0), a/2
	fl, fr := f(l), f(r)
	for r-l > 2 {
		n, m := (2*l+r)/3, (l+2*r)/3
		fn, fm := f(n), f(m)
		if fn <= fm {
			l = n
			fl = fn
			continue
		}
		r = m
		fr = fm
	}
	put64ln(max64(max64(fl, fr), f(l+1)))
}

const (
	once       = false
	maxBufSize = 10000000
)

var (
	splitFunc = bufio.ScanWords
)

func main() {
	in = bufio.NewScanner(bufio.NewReader(os.Stdin))
	in.Split(splitFunc)
	in.Buffer(make([]byte, maxBufSize), maxBufSize)

	out = bufio.NewWriter(os.Stdout)
	defer out.Flush()

	if once {
		solve()
		return
	}

	t := get()
	for t > 0 {
		solve()
		t--
	}
}

var (
	in  *bufio.Scanner
	out *bufio.Writer
)

func get() int {
	x, _ := strconv.Atoi(gets())
	return x
}

func geta(n int) []int {
	a := make([]int, n)
	for i := range a {
		a[i] = get()
	}
	return a
}

func geta1(n int) []int {
	a := make([]int, n)
	for i := range a {
		a[i] = get() - 1
	}
	return a
}

func get64() int64 {
	x, _ := strconv.ParseInt(gets(), 10, 64)
	return x
}

func get64a(n int) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = get64()
	}
	return a
}

func get64a1(n int) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = get64() - 1
	}
	return a
}

func getf() float64 {
	x, _ := strconv.ParseFloat(gets(), 64)
	return x
}

func getfa(n int) []float64 {
	a := make([]float64, n)
	for i := range a {
		a[i] = getf()
	}
	return a
}

func gets() string {
	scan()
	return in.Text()
}

func scanN(n int) {
	for n > 0 {
		scan()
		n--
	}
}

func scan() {
	in.Scan()
}

func putc(c rune) {
	out.WriteRune(c)
}

func line() {
	putc('\n')
}

func space() {
	putc(' ')
}

func put(x int) {
	out.WriteString(strconv.Itoa(x))
}

func putln(i int) {
	put(i)
	line()
}

func puta(a []int) {
	for _, v := range a {
		put(v)
		space()
	}
	line()
}

func put64(x int64) {
	out.WriteString(strconv.FormatInt(x, 10))
}

func put64ln(x int64) {
	put64(x)
	line()
}

func put64a(a []int64) {
	for _, v := range a {
		put64(v)
		space()
	}
	line()
}

func puts(s string) {
	out.WriteString(s)
}

func putsln(s string) {
	puts(s)
	line()
}

func yn(y bool) {
	if y {
		yes()
		return
	}
	no()
}

func yes() {
	puts("YES\n")
}

func no() {
	puts("NO\n")
}

func putf(x float64) {
	out.WriteString(strconv.FormatFloat(x, 'f', -1, 64))
}

func putfln(x float64) {
	putf(x)
	line()
}

func putfa(a []float64) {
	for _, v := range a {
		putf(v)
		space()
	}
	line()
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func abs64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func absf(x float64) float64 {
	return math.Abs(x)
}

func max(x int, y int) int {
	if x > y {
		return x
	}
	return y
}

func max64(x int64, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func maxf(x float64, y float64) float64 {
	return math.Max(x, y)
}

func min(x int, y int) int {
	if x < y {
		return x
	}
	return y
}

func min64(x int64, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func minf(x float64, y float64) float64 {
	return math.Min(x, y)
}

func L(i int) int64 {
	return int64(i)
}

func ints(n int, val int) (a []int) {
	a = make([]int, n)
	if val == 0 {
		return
	}
	for i := range a {
		a[i] = val
	}
	return
}

func int64s(n int, val int64) (a []int64) {
	a = make([]int64, n)
	if val == 0 {
		return
	}
	for i := range a {
		a[i] = val
	}
	return
}

func floats(n int, val float64) (a []float64) {
	a = make([]float64, n)
	if val == 0 {
		return
	}
	for i := range a {
		a[i] = val
	}
	return
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

type CF1611B struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1611B) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1611B) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1611B) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1611B) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1611B) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1611B
Date: 26/01/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1611/B
Problem: CF1611B
**/
func (in *CF1611B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		a, b := in.NextInt(), in.NextInt()
		teams := int(math.Floor(float64(a+b) / 4.0))
		ans := 0
		if a >= teams && b >= teams {
			ans = teams
		} else {
			ans = int(math.Min(float64(a), float64(b)))
		}
		fmt.Println(ans)
	}
}

func NewCF1611B(r *bufio.Reader) *CF1611B {
	return &CF1611B{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1611B(bufio.NewReader(os.Stdin)).Run()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)

	for t := 0; t < T; t++ {
		var m, p int64
		fmt.Fscan(in, &m, &p)

		fmt.Fprintln(out, min((m+p)/4, m, p))
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	rr = bufio.NewReader(os.Stdin)
	ww = bufio.NewWriter(os.Stdout)
)

var (
	T int
)

func solve(a, b int) int {
	d := b - a
	if d < 2 {
		return a / 2
	}
	d /= 2
	if d >= a {
		return a
	}
	return d + (a-d)/2
}

func main() {
	_, _ = fmt.Fscan(rr, &T)
	for iCase := 0; iCase < T; iCase++ {
		var a, b int
		_, _ = fmt.Fscan(rr, &a, &b)
		if a > b {
			a, b = b, a
		}
		_, _ = fmt.Fprintln(ww, solve(a, b))
	}
	_ = ww.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	reader = bufio.NewReader(os.Stdin)
	t      int
	a, b   int64
)

func solve(a, b int64) int64 {
	if a < b/3 {
		return a
	}
	if b < a/3 {
		return b
	}
	return (a + b) / 4
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &a, &b)
		fmt.Println(solve(a, b))
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var ntc, a, b int
	fmt.Fscan(in, &ntc)
	for t := 0; t < ntc; t++ {
		fmt.Fscan(in, &a, &b)
		ans := Min((a+b)/4, Min(a, b))
		fmt.Fprintf(out, "%d\n", ans)
		out.Flush()
	}
	out.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scan() string {
	for sc.Scan() {
		break
	}
	return sc.Text()
}

func scanInt() int {
	i, err := strconv.Atoi(scan())
	if err != nil {
		panic(err)
	}
	return i
}

func scanInt64() int64 {
	i, err := strconv.ParseInt(scan(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func isEven(c byte) bool {
	return c == '2' || c == '4' || c == '6' || c == '8'
}

func main() {
	sc.Split(bufio.ScanWords)
	t := scanInt()
	for i := 0; i < t; i++ {
		a, b := scanInt64(), scanInt64()
		if a > b {
			a, b = b, a
		}
		if b >= a * 3 {
			fmt.Println(a)
			continue
		}
		fmt.Println((a+b)/4)
	}
}

package main
import "fmt"

func countways(a, b int) int{
	if a > b{
		return countways(b, a)
	} else if a!=0 && b / a >= 3{
		return a
	} else{
		d := b - a
		count := int(d / 2)
		b -= 3*count
		a -= count
		count += int((a+b)/4)
		return count
	}
}

func main(){
	var N_INPS, a, b ,i int
	fmt.Scanf("%d\n",&N_INPS)
	var inps [][2]int
	for i=0; i<N_INPS;i++{
		fmt.Scanf("%d %d\n", &a, &b)
		inps = append(inps,[2]int{a,b})
	}
	for _, inp := range inps{
		fmt.Println(countways(inp[0], inp[1]))
	}
}

package main
import "fmt"

func countways(a, b int64) int64{
	if a > b{
		return countways(b, a)
	} else if b > 3*a {
		return a
	} else if a == b {
		return int64(a/2)
	} else{
	    fmt.Println("ok")
		d := b - a
		count := int64(d / 2)
		b -= 3*count
		a -= count
		count += int64((a+b)/4)
		return count
	}
}

func main(){
	var N_INPS, a, b ,i int64
	fmt.Scanf("%d\n",&N_INPS)
	var inps [][2]int64
	for i=0; i<N_INPS;i++{
		fmt.Scanf("%d %d\n", &a, &b)
		inps = append(inps,[2]int64{a,b})
	}
	for _, inp := range inps{
		fmt.Println(countways(inp[0], inp[1]))
	}
}

package main
import "fmt"

func countways(a, b int) int{
	if a > b{
		return countways(b, a)
	} else if b > 3*a{
		return a
	} else if a == b {
		return int(a/2)
	} else{
		d := b - a
		count := int(d / 2)
		b -= 3*count
		a -= count
		count += int((a+b)/4)
		return count
	}
}

func main(){
	var N_INPS, a, b int
	fmt.Scanf("%d\n",&N_INPS)
	var inps [][2]int
	for i:=0; i<N_INPS;i++{
		fmt.Scanf("%d %d\n", &a, &b)
		inps = append(inps,[2]int{a,b})
	}
	for _, inp := range inps{
		fmt.Println(countways(inp[0], inp[1]))
	}
}

package main
import "fmt"

func countways(a, b int) int{
	if a > b{
		return countways(b, a)
	} else if b > 3*a{
		return a
	} else{
		d := b - a
		count := int(d / 2)
		b -= 3*count
		a -= count
		count += int((a+b)/4)
		return count
	}
}

func main(){
	var N_INPS, a, b int
	fmt.Scanf("%d\n",&N_INPS)
	var inps [][2]int
	for i:=0; i<N_INPS;i++{
		fmt.Scanf("%d %d\n", &a, &b)
		inps = append(inps,[2]int{a,b})
	}
	for _, inp := range inps{
		fmt.Println(countways(inp[0], inp[1]))
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var a,b int
		fmt.Fscan(in,&a,&b)
		if max(max(a,b)/3,min(a,b)/2) == max(a,b)/3 {
			if max(a,b)/3 >= min(a,b) {
				fmt.Fprintln(out,min(a,b))
			} else {
				if max(a,b)%3 == 2 {
					if min(a,b) - max(a,b)/3 >= 2 {
						//return max(a,b)/3+1
						fmt.Fprintln(out,max(a,b)/3+1)
					} else {
						// return max(a,b)/3
						fmt.Fprintln(out,max(a,b)/3)
					}
				} else if max(a,b)%3 == 1 {
					if min(a,b) - max(a,b)/3 >= 3 {
						// return max(a,b)/3+1
						fmt.Fprintln(out,max(a,b)/3+1)
					} else {
						// return max(a,b)/3
						fmt.Fprintln(out,max(a,b)/3)
					}
				} else {
					fmt.Fprintln(out,max(a,b)/3)
					// return max(a,b)/3
				}
			}
		} else {
			if min(a,b)%2 == 0 {
				fmt.Fprintln(out,min(a,b)/2)
				// return min(a,b)/2
			} else {
				if max(a,b) - min(a,b) >= 3 {
					// return min(a,b)/2+1
					fmt.Fprintln(out,min(a,b)/2+1)
				} else {
					// return min(a,b)/2
					fmt.Fprintln(out,min(a,b)/2)
				}
			}
		}
	}
}
func min (x,y int) int {
	if x>y{
		return y
	} else {
		return x
	}
}
func max (x,y int) int {
	if x>y{
		return x
	} else {
		return y
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var a,b int
		fmt.Fscan(in,&a,&b)
		if a == b {
			fmt.Fprintln(out,a/2)
		} else if max(a,b) >= 3*min(a,b) {
			fmt.Fprintln(out,min(a,b))
		} else {
			if max(a,b)/3 >= min(a,b)/2 {
				if max(a,b)%3 == 0 {
					fmt.Fprintln(out,max(a,b)/3)
				} else if max(a,b)%3 == 1 {
					if min(a,b) >= max(a,b)/3+3 {
						fmt.Fprintln(out,max(a,b)/3+1)
					} else {
						fmt.Fprintln(out,max(a,b)/3)
					}
				} else if max(a,b)%3 == 2 {
					if max(a,b)/3 <= min(a,b)-2 {
						fmt.Fprintln(out,max(a,b)/3+1)
					} else {
						fmt.Fprintln(out,max(a,b)/3)
					}
				}
			} else {
				if min(a,b)%2 == 1 {
					if max(a,b) >= ((min(a,b)/2)*2)+3 {
						fmt.Fprintln(out,min(a,b)/2+1)
					} else {
						fmt.Fprintln(out,min(a,b)/2)
					}
				} else {
					fmt.Fprintln(out,min(a,b)/2)
				}
			}
		}
	}
}
func min (x,y int) int {
	if x>y{
		return y
	} else {
		return x
	}
}
func max (x,y int) int {
	if x>y{
		return x
	} else {
		return y
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var a,b int
		fmt.Fscan(in,&a,&b)
		if a == b {
			fmt.Fprintln(out,a/2)
		} else if max(a,b) >= 3*min(a,b) {
			fmt.Fprintln(out,min(a,b))
		} else {
			if max(a,b)/3 >= min(a,b)/2 {
				if max(a,b)%3 == 0 {
					fmt.Fprintln(out,max(a,b)/3)
				} else if max(a,b)%3 == 1 {
					if min(a,b) >= max(a,b)/3+3 {
						fmt.Fprintln(out,max(a,b)/3+1)
					} else {
						fmt.Fprintln(out,max(a,b)/3)
					}
				} else if max(a,b)%3 == 2 {
					if max(a,b)/3 <= min(a,b)-2 {
						fmt.Fprintln(out,max(a,b)/3+1)
					} else {
						fmt.Fprintln(out,max(a,b)/3)
					}
				}
			} else {
				fmt.Fprintln(out,min(a,b)/2)
			}
		}
	}
}
func min (x,y int) int {
	if x>y{
		return y
	} else {
		return x
	}
}
func max (x,y int) int {
	if x>y{
		return x
	} else {
		return y
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var a,b int
		fmt.Fscan(in,&a,&b)
		if a == b {
			fmt.Fprintln(out,a/2)
		} else if max(a,b) >= 3*min(a,b) {
			fmt.Fprintln(out,min(a,b))
		} else {
			if max(a,b)/3 >= min(a,b)/2 {
				if max(a,b)%3 == 2 {
					fmt.Fprintln(out,max(a,b)/3+1)
				} else {
					fmt.Fprintln(out,max(a,b)/3)
				}
			} else {
				if min(a,b)%2 == 1 {
					if max(a,b)-min(a,b) >= 3 {
						fmt.Fprintln(out,min(a,b)/2+1)
					} else {
						fmt.Fprintln(out,min(a,b)/2)
					}
				}
			}
		}
	}
}
func min (x,y int) int {
	if x>y{
		return y
	} else {
		return x
	}
}
func max (x,y int) int {
	if x>y{
		return x
	} else {
		return y
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var a,b int
		fmt.Fscan(in,&a,&b)
		if a == b {
			fmt.Fprintln(out,a/2)
			continue
		}
		if max(a,b) >= min(a,b)*3 {
			fmt.Fprintln(out,min(a,b))
			continue
		}
		if max(a,b)%3 == 2 {
			if min(a,b) - max(a,b)/3 >= 2 {
				fmt.Fprintln(out,max(a,b)/3+1)
			} else {
				fmt.Fprintln(out,max(a,b)/3)
			}
		} else {
			fmt.Fprintln(out,max(a,b)/3)
		}
	}
}
func min (x,y int) int {
	if x>y{
		return y
	} else {
		return x
	}
}
func max (x,y int) int {
	if x>y{
		return x
	} else {
		return y
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var a,b int
		fmt.Fscan(in,&a,&b)
		if max(a,b) - min(a,b) <= min(a,b) {
			fmt.Fprintln(out,min(a,b)/2)
		} else {

			if max(a,b)/3 < min(a,b) && min(a,b) - max(a,b)/3 == 2 {
				fmt.Fprintln(out,(max(a,b)/3)+1)
			} else {
				fmt.Fprintln(out,min(max(a,b)/3,min(a,b)))
			}
		}
	}
}
func min (x,y int) int {
	if x>y{
		return y
	} else {
		return x
	}
}
func max (x,y int) int {
	if x>y{
		return x
	} else {
		return y
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var a,b int
		fmt.Fscan(in,&a,&b)
		if max(a,b) - min(a,b) <= min(a,b) {
			fmt.Fprintln(out,min(a,b)/2)
		} else {

			if max(a,b)/3 < min(a,b) && max(a,b)/3 - min(a,b) == 2 {
				fmt.Fprintln(out,(max(a,b)/3)+1)
			} else {
				fmt.Fprintln(out,min(max(a,b)/3,min(a,b)))
			}
		}
	}
}
func min (x,y int) int {
	if x>y{
		return y
	} else {
		return x
	}
}
func max (x,y int) int {
	if x>y{
		return x
	} else {
		return y
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var a,b int
		fmt.Fscan(in,&a,&b)
		if max(a,b) - min(a,b) <= min(a,b) {
			fmt.Fprintln(out,min(a,b)/2)
		} else {
			fmt.Fprintln(out,min(max(a,b)/3,min(a,b)))
		}
	}
}
func min (x,y int) int {
	if x>y{
		return y
	} else {
		return x
	}
}
func max (x,y int) int {
	if x>y{
		return x
	} else {
		return y
	}
}

package main

import (
	"fmt"
)

func solve(){
	var a,b int
	fmt.Scan(&a,&b)
	if a < b{
		a,b = b,a
	}
	if a >= 3 * b{
		fmt.Println(b)
	}else{
		fmt.Println((a + b) / 4)
	}
}

func main(){
	n := 0
	fmt.Scan(&n)
	for i := 0;i < n;i++{
		solve()
	}
}

package main

import (
	"fmt"
)

func solve(){
	var a,b int
	fmt.Scan(&a,&b)
	if a < b{
		a,b = b,a
	}
	if a > 3 * b{
		fmt.Println(b)
	}else{
		fmt.Println((a + b) / 4)
	}
}

func main(){
	n := 0
	fmt.Scan(&n)
	for i := 0;i < n;i++{
		solve()
	}
}


Iahub recently has learned Bubble Sort, an algorithm that is used to sort a permutation with n elements a1, a2, ..., an in ascending order. He is bored of this so simple algorithm, so he invents his own graph. The graph (let's call it G) initially has n vertices and 0 edges. During Bubble Sort execution, edges appear as described in the following algorithm (pseudocode). procedure bubbleSortGraph()    build a graph G with n vertices and 0 edges    repeat        swapped = false        for i = 1 to n - 1 inclusive do:            if a[i] > a[i + 1] then                add an undirected edge in G between a[i] and a[i + 1]                swap( a[i], a[i + 1] )                swapped = true            end if        end for    until not swapped     /* repeat the algorithm as long as swapped value is true. */ end procedureFor a graph, an independent set is a set of vertices in a graph, no two of which are adjacent (so there are no edges between vertices of an independent set). A maximum independent set is an independent set which has maximum cardinality. Given the permutation, find the size of the maximum independent set of graph G, if we use such permutation as the premutation a in procedure bubbleSortGraph.

The first line of the input contains an integer n (2 ≤ n ≤ 105). The next line contains n distinct integers a1, a2, ..., an (1 ≤ ai ≤ n).

Output a single integer — the answer to the problem.

NoteConsider the first example. Bubble sort swaps elements 3 and 1. We add edge (1, 3). Permutation is now [1, 3, 2]. Then bubble sort swaps elements 3 and 2. We add edge (2, 3). Permutation is now sorted. We have a graph with 3 vertices and 2 edges (1, 3) and (2, 3). Its maximal independent set is [1, 2].

	package main
import(
	"os"
	"bufio"
	"strconv"
	"fmt"
)

var scanner *bufio.Scanner

func getI64() int64 {
	scanner.Scan()
	x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return x
}
func getI() int {
	return int(getI64())
}
func getF() float64 {
	scanner.Scan()
	x, _ := strconv.ParseFloat(scanner.Text(), 64)
	return x
}
func getS() string {
	scanner.Scan()
	return scanner.Text()
}

func lowerBound(en,k int) int {
	st := 0

	for st <= en{
		mid := (st + en) >> 1
		if DP[mid] < k {
			st = mid + 1
		}else{
			en = mid - 1
		}
	 }

	 return st
}
const MAXN = 100010
var DP [MAXN]int

func main(){

	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	n:= getI()

	sol := 0

	for i := 0 ; i < n ; i ++ {
		k := getI()
		x := lowerBound(sol,k)

		DP[x] = k

		if (x > sol){
			sol = x
		}
	}
	writer.WriteString(fmt.Sprintf("%v\n",sol))
}


Carousel Boutique is busy again! Rarity has decided to visit the pony ball and she surely needs a new dress, because going out in the same dress several times is a sign of bad manners. First of all, she needs a dress pattern, which she is going to cut out from the rectangular piece of the multicolored fabric.The piece of the multicolored fabric consists of $$$n \times m$$$ separate square scraps. Since Rarity likes dresses in style, a dress pattern must only include scraps sharing the same color. A dress pattern must be the square, and since Rarity is fond of rhombuses, the sides of a pattern must form a $$$45^{\circ}$$$ angle with sides of a piece of fabric (that way it will be resembling the traditional picture of a rhombus).Examples of proper dress patterns:  Examples of improper dress patterns:  The first one consists of multi-colored scraps, the second one goes beyond the bounds of the piece of fabric, the third one is not a square with sides forming a $$$45^{\circ}$$$ angle with sides of the piece of fabric.Rarity wonders how many ways to cut out a dress pattern that satisfies all the conditions that do exist. Please help her and satisfy her curiosity so she can continue working on her new masterpiece!

The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 2000$$$). Each of the next $$$n$$$ lines contains $$$m$$$ characters: lowercase English letters, the $$$j$$$-th of which corresponds to scrap in the current line and in the $$$j$$$-th column. Scraps having the same letter share the same color, scraps having different letters have different colors.

Print a single integer: the number of ways to cut out a dress pattern to satisfy all of Rarity's conditions.

NoteIn the first example, all the dress patterns of size $$$1$$$ and one of size $$$2$$$ are satisfactory.In the second example, only the dress patterns of size $$$1$$$ are satisfactory.

package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
)

var in *bufio.Reader
var out *bufio.Writer

func printf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, x, a...)
}

func scanf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fscanf(in, x, a...)
}

type priorityQueue [][2]int

func (pq priorityQueue) Len() int {
	return len(pq)
}

func (pq priorityQueue) Less(i, j int) bool {
	return pq[i][1] > pq[j][1]
}

func (pq priorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func (pq *priorityQueue) Push(x interface{}) {
	*pq = append(*pq, x.([2]int))
}

func (pq *priorityQueue) Pop() (res interface{}) {
	res = (*pq)[len(*pq)-1]
	*pq = (*pq)[:len(*pq)-1]
	return res
}

var err error

func next() (n string) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return ""
		}
	}
}

func nextInt() (n int) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func nextLong() (n int64) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func nextDouble() (n float64) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func Fill(a []int, v int) {
	for i := range a {
		a[i] = v
	}
}

func FillB(a []bool, v bool) {
	for i := range a {
		a[i] = v
	}
}

func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

var (
	dx [4]int = [4]int{-1, 0, 1, 0}
	dy [4]int = [4]int{0, 1, 0, -1}
)

func solve() {
	n, m := nextInt(), nextInt()
	arr := make([][]rune, n)
	for i := range arr {
		arr[i] = []rune(next())
	}
	dist := make([][]int64, n)
	for i := 0; i < n; i++ {
		dist[i] = make([]int64, m)
	}

	buff := make([][2]int, 2*n*m)

	res := int64(0)
	for c := 'a'; c <= 'z'; c++ {
		q := buff[0:0]

		for i := range dist {
			for j := range dist[i] {
				if arr[i][j] == c {
					has := false
					for k := 0; k < 4; k++ {
						x, y := i+dx[k], j+dy[k]
						if x < 0 || y < 0 || x >= n || y >= m || arr[x][y] != c {
							has = true
							break
						}
					}
					if has {
						res++
						dist[i][j] = 1
						q = append(q, [2]int{i, j})
					} else {
						dist[i][j] = -1
					}
				}
			}
		}

		for len(q) > 0 {
			x, y := q[0][0], q[0][1]
			d := dist[x][y]
			q = q[1:]
			for i := 0; i < 4; i++ {
				nx, ny := x+dx[i], y+dy[i]
				if nx < 0 || ny < 0 || nx >= n || ny >= m || arr[nx][ny] != c {
					continue
				}
				if dist[nx][ny] == -1 {
					res += d + 1
					dist[nx][ny] = d + 1
					q = append(q, [2]int{nx, ny})
				}
			}
		}
	}
	printf("%d\n", res)
}

func main() {
	in = bufio.NewReaderSize(os.Stdin, 8192)
	out = bufio.NewWriterSize(os.Stdout, 8192)
	if false {
		name := "in"
		file1, err := os.Open(name + ".in")
		if err != nil {
			log.Fatal(err)
		}
		// file2, err := os.Create(name + ".out")
		// if err != nil {
		// 	log.Fatal(err)
		// }
		in = bufio.NewReaderSize(file1, 8192)
		// out = bufio.NewWriterSize(file2, 8192)
	}
	defer out.Flush()

	// for t := nextInt(); t > 0; t-- {
	solve()
	// }
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	m, n := readTwoNums(reader)

	G := make([]string, m)

	for i := 0; i < m; i++ {
		G[i], _ = reader.ReadString('\n')
	}

	fmt.Println(solve(m, n, G))
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(m, n int, G []string) int {
	up := make([][]int, m)
	down := make([][]int, m)

	for i := 0; i < m; i++ {
		up[i] = make([]int, n)
		down[i] = make([]int, n)
	}
	for i := 0; i < m; i++ {
		for j := 0; j < n; j++ {
			if i > 0 && G[i-1][j] == G[i][j] {
				up[i][j] = up[i-1][j] + 1
			}
		}
	}
	for i := m - 1; i >= 0; i-- {
		for j := 0; j < n; j++ {
			if i < m-1 && G[i+1][j] == G[i][j] {
				down[i][j] = down[i+1][j] + 1
			}
		}
	}

	L := make([]int, n)
	R := make([]int, n)

	var ans int
	for i := 0; i < m; i++ {
		for j := 0; j < n; j++ {
			jj := j
			for j < n && G[i][j] == G[i][jj] {
				j++
			}
			j--
			L[jj] = jj
			for k := jj + 1; k <= j; k++ {
				L[k] = max(L[k-1], k-min(up[i][k], down[i][k]))
			}
			R[j] = j

			for k := j - 1; k >= jj; k-- {
				R[k] = min(R[k+1], k+min(up[i][k], down[i][k]))
			}

			for k := jj; k <= j; k++ {
				ans += min(k-L[k]+1, R[k]-k+1)
			}
		}
	}

	return ans
}

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

var reader *bufio.Reader
var writer *bufio.Writer

func solve(a []string) int {
	ans := 0
	rows, cols := len(a), len(a[0])
	var diags [2][][]int
	var lengths [][]int
	for i := range diags {
		diags[i] = make([][]int, rows)
		for r := range diags[i] {
			diags[i][r] = make([]int, cols)
			for c := range diags[i][r] {
				diags[i][r][c] = 1
			}
		}
	}
	lengths = make([][]int, rows)
	for i := range lengths {
		lengths[i] = make([]int, cols)
		for j := range lengths[i] {
			lengths[i][j] = 1
		}
	}

	for r := rows-1; r >= 0; r-- {
		for c := cols-1; c >= 0; c-- {
			color := a[r][c]
			leftColor, rightColor := safeGetByte(a, r+1, c-1), safeGetByte(a, r+1, c+1)
			if leftColor == color {
				diags[0][r][c] = diags[0][r+1][c-1] + 1
			}
			if rightColor == color {
				diags[1][r][c] = diags[1][r+1][c+1] + 1
			}

			if safeGetByte(a, r+1, c) == color {
				lengths[r][c] = getMin(diags[0][r][c], diags[1][r][c], lengths[r+1][c])
				l := lengths[r][c]
				if l == lengths[r+1][c] &&
					safeGetByte(a, r+l, c-l) == color &&
					safeGetByte(a, r+l, c+l) == color &&
					diags[1][r+l][c-l] >= l+1 &&
					diags[0][r+l][c+l] >= l+1 {
					lengths[r][c]++
				}
			}
			l := lengths[r][c]
			ans += l
		}
	}

	return ans
}

func safeGetByte(a []string, r, c int) byte {
	if r < 0 || r >= len(a) || c < 0 || c >= len(a[r]) {
		return ' '
	}
	return a[r][c]
}

func safeGetInt(a [][]int, r, c int) int {
	if r < 0 || r >= len(a) || c < 0 || c >= len(a[r]) {
		return 0
	}
	return a[r][c]
}

func getMin(arr ...int) int {
	if len(arr) == 0 { panic("length arr == 0") }

	var ans = arr[0]
	for _, v := range arr {
		if v < ans { ans = v }
	}
	return ans
}

func main() {
	//ioutil.WriteFile("input.txt", []byte(generateInput()), os.ModeExclusive)

	debug := 1
	filename := "input.txt"
	if debug != 0 && len(os.Args) > 1 && os.Args[1] == "debug" {
		file, _ := os.Open(filename)
		reader = bufio.NewReaderSize(file, 1024*1024)
	} else {
		reader = bufio.NewReaderSize(os.Stdin, 1024*1024)
	}
	writer = bufio.NewWriterSize(os.Stdout, 1024*1024)

	arr := readInts()
	a := make([]string, arr[0])
	for i := range a {
		a[i] = readLine()
	}
	ans := solve(a)
	fmt.Fprintln(writer, ans)

	writer.Flush()
}

func readInts() []int64 {
	line := readLine()
	fields := strings.Fields(line)
	res := make([]int64, len(fields))
	for i := range fields {
		v, _ := strconv.ParseInt(fields[i], 10, 64)
		res[i] = v
	}
	return res
}

func readInt() int64 {
	line := readLine()
	n, _ := strconv.ParseInt(line, 10, 32)
	return int64(n)
}

func readLine() string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

package main

import (
	"bufio"
	"fmt"
	"math/bits"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	grid := make([]string, n)
	var rng [11][][]uint32
	for i := 0; i < 11; i++ {
		rng[i] = makeGrid(n, m)
	}
	for i := 0; i < n; i++ {
		grid[i] = getNextString(scanner)
		for j := 0; j < m; j++ {
			rng[0][i][j] = 1 << uint(grid[i][j]-'a')
		}
	}
	for i := 1; i < 11; i++ {
		x := 1 << uint(i-1)
		for j := 0; j+x < n; j++ {
			for k := 0; k+x < m; k++ {
				if j-x < 0 {
					continue
				}
				if k-x < 0 {
					continue
				}
				if i == 1 {
					rng[i][j][k] = rng[0][j][k] | rng[i-1][j-x][k] | rng[i-1][j+x][k] | rng[i-1][j][k-x] | rng[i-1][j][k+x]
					continue
				}
				rng[i][j][k] = rng[0][j][k] | rng[i-1][j-x>>1][k] | rng[i-1][j+x>>1][k] | rng[i-1][j][k-x>>1] | rng[i-1][j][k+x>>1]
			}
		}
	}
	var ans int
	for j := 0; j < n; j++ {
		for k := 0; k < m; k++ {
			low := 0
			high := 2000
			for low+1 < high {
				mid := (low + high) >> 1
				if j-mid < 0 || j+mid >= n {
					high = mid
					continue
				}
				if k-mid < 0 || k+mid >= m {
					high = mid
					continue
				}
				i := 32 - bits.LeadingZeros32(uint32(mid))
				x := 1 << uint(i-1)
				c := bits.OnesCount32(rng[i][j][k] | rng[i][j+mid-x][k] | rng[i][j-mid+x][k] | rng[i][j][k+mid-x] | rng[i][j][k-mid+x])
				if c > 1 {
					high = mid
					continue
				}
				low = mid
			}
			ans += high
		}
	}
	fmt.Fprintln(writer, ans)
}
func makeGrid(h, w int) [][]uint32 {
	index := make([][]uint32, h, h)
	data := make([]uint32, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
)

var in *bufio.Reader
var out *bufio.Writer

func printf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, x, a...)
}

func scanf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fscanf(in, x, a...)
}

type priorityQueue [][2]int

func (pq priorityQueue) Len() int {
	return len(pq)
}

func (pq priorityQueue) Less(i, j int) bool {
	return pq[i][1] > pq[j][1]
}

func (pq priorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func (pq *priorityQueue) Push(x interface{}) {
	*pq = append(*pq, x.([2]int))
}

func (pq *priorityQueue) Pop() (res interface{}) {
	res = (*pq)[len(*pq)-1]
	*pq = (*pq)[:len(*pq)-1]
	return res
}

var err error

func next() (n string) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return ""
		}
	}
}

func nextInt() (n int) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func nextLong() (n int64) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func nextDouble() (n float64) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func Fill(a []int, v int) {
	for i := range a {
		a[i] = v
	}
}

func FillB(a []bool, v bool) {
	for i := range a {
		a[i] = v
	}
}

func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

var (
	dx [4]int = [4]int{-1, 0, 1, 0}
	dy [4]int = [4]int{0, 1, 0, -1}
)

func solve() {
	n, m := nextInt(), nextInt()
	arr := make([][]rune, n)
	for i := range arr {
		arr[i] = []rune(next())
	}

	res := 0
	for c := 'a'; c <= 'z'; c++ {
		dist := make([][]int, n)
		q := []int{}

		for i := range dist {
			dist[i] = make([]int, m)
			for j := range dist[i] {
				if arr[i][j] != c {
					dist[i][j] = 0
					q = append(q, i)
					q = append(q, j)
				} else if i == 0 || i == n-1 || j == 0 || j == m-1 {
					dist[i][j] = 1
					q = append(q, i)
					q = append(q, j)
					res++
				} else {
					dist[i][j] = -1
				}
			}
		}

		for len(q) > 0 {
			x, y := q[0], q[1]
			q = q[2:]
			for i := 0; i < 4; i++ {
				nx, ny := x+dx[i], y+dy[i]
				if nx < 0 || ny < 0 || nx >= n || ny >= m {
					continue
				}
				if dist[nx][ny] == -1 {
					res += dist[x][y] + 1
					dist[nx][ny] = dist[x][y] + 1
					q = append(q, nx)
					q = append(q, ny)
				}
			}
		}
	}
	printf("%d\n", res)
}

func main() {
	in = bufio.NewReaderSize(os.Stdin, 8192)
	out = bufio.NewWriterSize(os.Stdout, 8192)
	if false {
		name := "in"
		file1, err := os.Open(name + ".in")
		if err != nil {
			log.Fatal(err)
		}
		// file2, err := os.Create(name + ".out")
		// if err != nil {
		// 	log.Fatal(err)
		// }
		in = bufio.NewReaderSize(file1, 8192)
		// out = bufio.NewWriterSize(file2, 8192)
	}
	defer out.Flush()

	// for t := nextInt(); t > 0; t-- {
	solve()
	// }
}

package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
)

var in *bufio.Reader
var out *bufio.Writer

func printf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, x, a...)
}

func scanf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fscanf(in, x, a...)
}

type priorityQueue [][2]int

func (pq priorityQueue) Len() int {
	return len(pq)
}

func (pq priorityQueue) Less(i, j int) bool {
	return pq[i][1] > pq[j][1]
}

func (pq priorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}

func (pq *priorityQueue) Push(x interface{}) {
	*pq = append(*pq, x.([2]int))
}

func (pq *priorityQueue) Pop() (res interface{}) {
	res = (*pq)[len(*pq)-1]
	*pq = (*pq)[:len(*pq)-1]
	return res
}

var err error

func next() (n string) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return ""
		}
	}
}

func nextInt() (n int) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func nextLong() (n int64) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func nextDouble() (n float64) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func Fill(a []int, v int) {
	for i := range a {
		a[i] = v
	}
}

func FillB(a []bool, v bool) {
	for i := range a {
		a[i] = v
	}
}

func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

var (
	dx [4]int = [4]int{-1, 0, 1, 0}
	dy [4]int = [4]int{0, 1, 0, -1}
)

func solve() {
	n, m := nextInt(), nextInt()
	arr := make([][]rune, n)
	for i := range arr {
		arr[i] = []rune(next())
	}

	res := int64(0)
	for c := 'a'; c <= 'z'; c++ {
		dist := make([][]int64, n)
		q := []int{}

		for i := range dist {
			dist[i] = make([]int64, m)
			for j := range dist[i] {
				if arr[i][j] != c {
					dist[i][j] = 0
					q = append(q, i)
					q = append(q, j)
				} else if i == 0 || i == n-1 || j == 0 || j == m-1 {
					dist[i][j] = 1
					q = append(q, i)
					q = append(q, j)
					res++
				} else {
					dist[i][j] = -1
				}
			}
		}

		for len(q) > 0 {
			x, y := q[0], q[1]
			q = q[2:]
			for i := 0; i < 4; i++ {
				nx, ny := x+dx[i], y+dy[i]
				if nx < 0 || ny < 0 || nx >= n || ny >= m {
					continue
				}
				if dist[nx][ny] == -1 {
					res += dist[x][y] + 1
					dist[nx][ny] = dist[x][y] + 1
					q = append(q, nx)
					q = append(q, ny)
				}
			}
		}
	}
	printf("%d\n", res)
}

func main() {
	in = bufio.NewReaderSize(os.Stdin, 8192)
	out = bufio.NewWriterSize(os.Stdout, 8192)
	if false {
		name := "in"
		file1, err := os.Open(name + ".in")
		if err != nil {
			log.Fatal(err)
		}
		// file2, err := os.Create(name + ".out")
		// if err != nil {
		// 	log.Fatal(err)
		// }
		in = bufio.NewReaderSize(file1, 8192)
		// out = bufio.NewWriterSize(file2, 8192)
	}
	defer out.Flush()

	// for t := nextInt(); t > 0; t-- {
	solve()
	// }
}

package main

import (
	"bufio"
	"fmt"
	"math/bits"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	grid := make([]string, n)
	var rng [11][][]uint32
	for i := 0; i < 11; i++ {
		rng[i] = makeGrid(n, m)
	}
	for i := 0; i < n; i++ {
		grid[i] = getNextString(scanner)
		for j := 0; j < m; j++ {
			rng[0][i][j] = 1 << uint(grid[i][j]-'a')
		}
	}
	for i := 1; i < 11; i++ {
		x := 1 << uint(i-1)
		for j := 0; j+x < n; j++ {
			for k := 0; k+x < m; k++ {
				if j-x < 0 {
					continue
				}
				if k-x < 0 {
					continue
				}
				rng[i][j][k] = rng[0][j][k] | rng[i-1][j-x][k] | rng[i-1][j+x][k] | rng[i-1][j][k-x] | rng[i-1][j][k+x]
			}
		}
	}
	var ans int
	for j := 0; j < n; j++ {
		for k := 0; k < m; k++ {
			low := 0
			high := 2000
			for low+1 < high {
				mid := (low + high) >> 1
				if j-mid < 0 || j+mid >= n {
					high = mid
					continue
				}
				if k-mid < 0 || k+mid >= m {
					high = mid
					continue
				}
				i := 32 - bits.LeadingZeros32(uint32(mid))
				x := 1 << uint(i-1)
				c := bits.OnesCount32(rng[i][j][k] | rng[i][j+mid-x][k] | rng[i][j-mid+x][k] | rng[i][j][k+mid-x] | rng[i][j][k-mid+x])
				if c > 1 {
					high = mid
					continue
				}
				low = mid
			}
			ans += high
		}
	}
	fmt.Fprintln(writer, ans)
}
func makeGrid(h, w int) [][]uint32 {
	index := make([][]uint32, h, h)
	data := make([]uint32, h*w, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}


The elections in which three candidates participated have recently ended. The first candidate received $$$a$$$ votes, the second one received $$$b$$$ votes, the third one received $$$c$$$ votes. For each candidate, solve the following problem: how many votes should be added to this candidate so that he wins the election (i.e. the number of votes for this candidate was strictly greater than the number of votes for any other candidate)?Please note that for each candidate it is necessary to solve this problem independently, i.e. the added votes for any candidate do not affect the calculations when getting the answer for the other two candidates.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case consists of one line containing three integers $$$a$$$, $$$b$$$, and $$$c$$$ ($$$0 \le a,b,c \le 10^9$$$).

For each test case, output in a separate line three integers $$$A$$$, $$$B$$$, and $$$C$$$ ($$$A, B, C \ge 0$$$) separated by spaces — the answers to the problem for the first, second, and third candidate, respectively.

package main

import (
	"bufio"
	"fmt"
	math "math"
	"os"
	"strconv"
	"strings"
)

func solve(a, b, c float64) int {
	return int(math.Max(0, math.Max(c, b)+1-a))
}
func (sc *A) run() {
	T := sc.nextInt()
	for t := 0; t < T; t++ {
		arr := make([]float64, 3)
		for i := 0; i < len(arr); i++ {
			arr[i], _ = strconv.ParseFloat(sc.nextString(), 64)
		}
		fmt.Printf("%d %d %d\n", solve(arr[0], arr[1], arr[2]), solve(arr[1], arr[0], arr[2]), solve(arr[2], arr[0], arr[1]))
	}
}

func main() {
	file, err := os.Open("input.txt")
	var F *bufio.Reader
	if err == nil {
		F = bufio.NewReader(file)
		os.Stdin = file
	} else {
		F = bufio.NewReader(os.Stdin)
	}
	defer func(file *os.File) {
		_ = file.Close()
	}(file)
	NewA(F).run()
}

func NewA(r *bufio.Reader) *A {
	return &A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

type A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (sc *A) nextLine() string {
	line, err := sc.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	sc.split = []string{}
	sc.index = 0
	return line
}

func (sc *A) load() {
	if len(sc.split) <= sc.index {
		sc.split = strings.Split(sc.nextLine(), sc.separator)
		sc.index = 0
	}
}

func (sc *A) nextInt() int {
	sc.load()
	val, _ := strconv.Atoi(strings.TrimSpace(sc.split[sc.index]))
	sc.index++
	return val
}

func (sc *A) nextInt64() int64 {
	sc.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(sc.split[sc.index]), 10, 64)
	sc.index++
	return val
}

func (sc *A) nextString() string {
	sc.load()
	val := strings.TrimSpace(sc.split[sc.index])
	sc.index++
	return val
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func Max(arg ...int) int {
	m := arg[0]
	for _, v := range arg {
		if v > m {
			m = v
		}
	}
	return m
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		a, b, c := 0, 0, 0
		fmt.Fscan(f, &a, &b, &c)
		ma, mb, mc := Max(0, Max(b, c)-a+1), Max(0, Max(a, c)-b+1), Max(0, Max(a, b)-c+1)
		fmt.Fprintln(w, ma, mb, mc)
	}
	w.Flush()
}

func main() {
	solve()
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1593A(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)

	var T int
	a := [3]int{}
	for Fscan(in, &T); T > 0; T-- {
		mx, c := -1, 0
		for i := range a {
			Fscan(in, &a[i])
			if a[i] > mx {
				mx, c = a[i], 1
			} else if a[i] == mx {
				c++
			}
		}
		for _, v := range a {
			if v == mx {
				if c == 1 {
					Fprintln(out, 0)
				} else {
					Fprintln(out, 1)
				}
			} else {
				Fprintln(out, mx-v+1)
			}
		}
	}
}

func main() { CF1593A(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1593A(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)

	var T int
	a := [3]int{}
	for Fscan(in, &T); T > 0; T-- {
		mx, c := -1, 0
		for i := range a {
			Fscan(in, &a[i])
			if a[i] > mx {
				mx, c = a[i], 1
			} else if a[i] == mx {
				c++
			}
		}
		for _, v := range a {
			if v == mx {
				if c == 1 {
					Fprintln(out, 0)
				} else {
					Fprintln(out, 1)
				}
			} else {
				Fprintln(out, mx-v+1)
			}
		}
		Fprintln(out)
	}
}

func main() { CF1593A(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1593A(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)

	var T int
	a := [3]int{}
	for Fscan(in, &T); T > 0; T-- {
		mx, c := -1, 0
		for i := range a {
			Fscan(in, &a[i])
			if a[i] > mx {
				mx, c = a[i], 1
			} else if a[i] == mx {
				c++
			}
		}
		for _, v := range a {
			if v == mx {
				if c == 1 {
					Fprint(out, "0 ")
				} else {
					Fprint(out, "1 ")
				}
			} else {
				Fprint(out, mx-v+1, " ")
			}
		}
		Fprintln(out)
	}
}

func main() { CF1593A(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1593A(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T int
	a := [3]int{}
	for Fscan(in, &T); T > 0; T-- {
		mx, c := -1, 0
		for i := range a {
			Fscan(in, &a[i])
			if a[i] > mx {
				mx, c = a[i], 1
			} else if a[i] == mx {
				c++
			}
		}
		for _, v := range a {
			if v == mx {
				if c == 1 {
					Fprint(out, "0 ")
				} else {
					Fprint(out, "1 ")
				}
			} else {
				Fprint(out, mx-v+1, " ")
			}
		}
		Fprintln(out)
	}
}

func main() { CF1593A(os.Stdin, os.Stdout) }

package main

import (
	"fmt"
	"os"
	"strconv"
)

func main() {
	//输入输出部分
	cnt := 0
	fmt.Fscan(os.Stdin, &cnt)
	ans := make([][]int, cnt)
	for j :=0; j < cnt; j++ {
		ans[j] = make([]int, 3)
		for i := 0; i < 3; i++ {
			fmt.Fscan(os.Stdin, &ans[j][i])
		}
	}
	//算法部分
	for i, sl := range ans{
		flag := 0
		max := 0
		if sl[0] >= sl[1] && sl[0] >= sl[2] {
			max = sl[0]
		} else if sl[1] >= sl[0] && sl[1] >= sl[2] {
			max = sl[1]
		} else {
			max = sl[2]
		}
		if sl[0] == max {flag++}
		if sl[1] == max {flag++}
		if sl[2] == max {flag++}
		for j, v := range sl {
			if v != max {
				ans[i][j] = max -v + 1
			} else {
				if flag == 1 {
					ans[i][j] = 0
				} else {
					ans[i][j] = 1
				}
			}
		}
	}

	for _, sl := range ans {
		fmt.Println(strconv.Itoa(sl[0]) + " " + strconv.Itoa(sl[1]) + " " + strconv.Itoa(sl[2]))
	}
}

package main

import "fmt"

func main() {
	var T int
	fmt.Scan(&T)
	for i := 0; i < T; i++ {
		var a, b, c int
		fmt.Scan(&a, &b, &c)
		fmt.Println(ddd(a, b, c), ddd(b, a, c), ddd(c, a, b))
	}

}

func ddd(a, b, c int) int {
	if a > max(b, c) {
		return 0
	}
	return max(b, c) - a + 1
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	var (
		t   int
		a   int
		b   int
		c   int
		max int
	)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	t, _ = strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		scanner.Scan()
		sl := strings.Split(scanner.Text(), " ")
		a, _ = strconv.Atoi(sl[0])
		b, _ = strconv.Atoi(sl[1])
		c, _ = strconv.Atoi(sl[2])
		if a > b {
			max = a
		} else {
			max = b
		}
		if c > max {
			max = c
		}
		mc := 0
		if a == max {
			mc++
		}
		if b == max {
			mc++
		}
		if c == max {
			mc++
		}
		an, bn, cn := 0, 0, 0
		if max != a {
			an = max - a + 1
		}
		if max != b {
			bn = max - b + 1
		}
		if max != c {
			cn = max - c + 1
		}
		if max == a && mc > 1 {
			an++
		}
		if max == b && mc > 1 {
			bn++
		}
		if max == c && mc > 1 {
			cn++
		}
		fmt.Println(an, bn, cn)
	}
}

package main

import (
  "fmt"
  "bufio"
  "os"
)

func max(x int, y int) int {
  if x > y {
    return x
  }
  return y
}

func main() {
  reader := bufio.NewReader(os.Stdin)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  var t int
  fmt.Fscan(reader, &t)
  for ; t > 0; t-- {
    var a, b, c int
    fmt.Fscan(reader, &a, &b, &c)
    fmt.Fprintf(writer, "%d %d %d\n", max(0, max(b+1, c+1)-a), max(0, max(c+1, a+1)-b), max(0, max(a+1, b+1)-c))
  }
}

package main

import "fmt"

func max(x int, y int) int {
  if x > y {
    return x
  }
  return y
}

func main() {
  var t int
  fmt.Scanf("%d\n", &t)
  for ; t > 0; t-- {
    var a, b, c int
    fmt.Scanf("%d %d %d\n", &a, &b, &c)
    fmt.Printf("%d %d %d\n", max(0, max(b+1, c+1)-a), max(0, max(c+1, a+1)-b), max(0, max(a+1, b+1)-c))
  }
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func max(a int, rest ...int) int {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)

	for t := 0; t < T; t++ {
		a := make([]int, 3)
		fmt.Fscan(in, &a[0], &a[1], &a[2])

		m := max(a[0], a[1], a[2])
		m++

		winner := -1
		if a[0] > a[1] && a[0] > a[2] {
			winner = 0
		} else if a[1] > a[0] && a[1] > a[2] {
			winner = 1
		} else if a[2] > a[0] && a[2] > a[1] {
			winner = 2
		}

		for i := 0; i < len(a); i++ {
			d := m - a[i]
			if i == winner {
				d = 0
			}
			fmt.Fprintf(out, "%d ", d)
		}
		fmt.Fprintln(out)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	r = bufio.NewReader(os.Stdin)
	w = bufio.NewWriter(os.Stdout)

	T int
)

func main() {
	fmt.Fscan(r, &T)
	for ; T > 0; T-- {
		var a [3]int
		fmt.Fscan(r, &a[0], &a[1], &a[2])
		max, mul := 0, 0
		for i := 1; i < 3; i++ {
			if a[max] == a[i] {
				mul = 1
			} else if a[max] < a[i] {
				max = i
				mul = 0
			}
		}
		for i := range a {
			if mul == 0 && max == i {
				fmt.Fprintf(w, "%d ", 0)
			} else {
				fmt.Fprintf(w, "%d ", a[max] + 1 - a[i])
			}
		}
		fmt.Fprintln(w)
	}
	_ = w.Flush()
}

package main // ignore

import "fmt"

func max (a, b int) int {
    if a > b {
        return a
    } else {
        return b
    }
}

func solve () {
    var a, b, c int
    fmt.Scan(&a, &b, &c)

    ansa := max(max(b, c) - a, 0)
    ansb := max(max(a, c) - b, 0)
    ansc := max(max(a, b) - c, 0)

    if a + ansa == max(b, c) {ansa++}
    if b + ansb == max(a, c) {ansb++}
    if c + ansc == max(a, b) {ansc++}

    fmt.Println(ansa, ansb, ansc)
}

func main () {
    var t int
    fmt.Scan(&t)
    for ; t > 0; t-- {solve()}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var a, b, c int

func main() {

	r := bufio.NewReader(os.Stdin)

	var t int

	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {
		fmt.Fscan(r, &a, &b, &c)

		solve()

		fmt.Println()
	}
}

func solve() {
	var d1, d2 int
	if a - b <= 0 {
		d1 = b - a + 1
	}
	if a - c <= 0 {
		d2 = c - a + 1
	}
	fmt.Print(max(d1, d2))
	fmt.Print(" ")

	d1 = 0
	d2 = 0

	if b - a <= 0 {
		d1 = a - b + 1
	}
	if b - c <= 0 {
		d2 = c - b + 1
	}
	fmt.Print(max(d1, d2))
	fmt.Print(" ")

	d1 = 0
	d2 = 0

	if c - a <= 0 {
		d1 = a - c + 1
	}
	if c - b <= 0 {
		d2 = b - c + 1
	}
	fmt.Print(max(d1, d2))
	fmt.Print(" ")

}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

package main
import(
    "fmt"
)
func main(){
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var a,b,c,largest int
		fmt.Scan(&a,&b,&c)
		if a >= b {
			largest= a
		} else {
			largest= b
		}
		if c >= a && c>= b {
			largest= c
		}
		if a > b && a > c {
			fmt.Printf("%v ",0)
			b= (largest-b)+1
			fmt.Printf("%v ",b)
			c= (largest-c)+1
			fmt.Printf("%v",c)
		} else if b > a && b > c {
			a= (largest-a)+1
			fmt.Printf("%v ",a)
			fmt.Printf("%v ",0)
			c= (largest-c)+1
			fmt.Printf("%v",c)
		} else if c > a && c > b {
			a= (largest-a)+1
			fmt.Printf("%v ",a)
			b= (largest-b)+1
			fmt.Printf("%v ",b)
			fmt.Printf("%v",0)
		} else {
			a= (largest-a)+1
			b= (largest-b)+1
			c= (largest-c)+1
			fmt.Printf("%v %v %v",a,b,c)
		}
		fmt.Println()
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)

	for test := parseInt(getString(reader)); test > 0; test-- {
		abc := getIntln(reader)
		a, b, c := abc[0], abc[1], abc[2]
		if a == b && b == c && c == a {
			writer.WriteString("1 1 1\n")
		} else if a == b {
			if a > c {
				writer.WriteString(fmt.Sprintln(1, 1, (a + 1 - c)))
			} else {
				writer.WriteString(fmt.Sprintln((c + 1 - a), (c + 1 - b), 0))
			}
		} else if b == c {
			if c > a {
				writer.WriteString(fmt.Sprintln((c + 1 - a), 1, 1))
			} else {
				writer.WriteString(fmt.Sprintln(0, (a + 1 - b), (a + 1 - c)))
			}
		} else if a == c {
			if a > b {
				writer.WriteString(fmt.Sprintln(1, (a + 1 - b), 1))
			} else {
				writer.WriteString(fmt.Sprintln((b + 1 - a), 0, (b + 1 - c)))
			}
		} else {
			if a > b {
				if a > c {
					writer.WriteString(fmt.Sprintln(0, (a + 1 - b), (a + 1 - c)))
				} else {
					writer.WriteString(fmt.Sprintln((c + 1 - a), (c + 1 - b), 0))
				}
			} else {
				if b > c {
					writer.WriteString(fmt.Sprintln((b + 1 - a), 0, (b + 1 - c)))
				} else {
					writer.WriteString(fmt.Sprintln((c + 1 - a), (c + 1 - b), 0))
				}
			}
		}
	}
	writer.Flush()
}

func getString(in *bufio.Reader) string {
	res, _ := in.ReadString('\n')
	res = strings.ReplaceAll(res, "\n", "")
	res = strings.ReplaceAll(res, "\r", "")
	res = strings.TrimSpace(res)
	return res
}

func parseInt(str string) int {
	var res int
	size := len(str)
	for i := 0; i < size; i++ {
		digit := int(str[i] - '0')
		for j := (i + 1); j < size; j++ {
			digit = digit<<3 + digit<<1
		}
		res += digit
	}
	return res
}

func getIntln(in *bufio.Reader) []int {
	b := strings.Split(getString(in), " ")
	res := make([]int, len(b))
	for k, v := range b {
		res[k] = parseInt(v)
	}
	return res
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type CF1593A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1593A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1593A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1593A) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1593A) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1593A) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1593A
Date: 8/11/21
User: pepradere
URL: https://codeforces.com/problemset/problem/1593/A
Problem: CF1593A
**/
func (in *CF1593A) Run() {
	t := in.NextInt()
	for ; t > 0; t-- {
		a, b, c := in.NextInt64(), in.NextInt64(), in.NextInt64()

		if a > b && a > c {
			fmt.Print(0, " ")
		} else {
			max := max(b,c)+1
			fmt.Print(max-a, " ")
		}

		if b > a && b > c {
			fmt.Print(0, " ")
		} else {
			max := max(a,c)+1
			fmt.Print(max-b, " ")
		}

		if c > a && c > b {
			fmt.Print(0, " ")
		} else {
			max := max(a,b)+1
			fmt.Print(max-c, " ")
		}
		fmt.Println()
	}
}

func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func NewCF1593A(r *bufio.Reader) *CF1593A {
	return &CF1593A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1593A(bufio.NewReader(os.Stdin)).Run()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

//problem A

type Elections struct {
	a, b, c int64
}

func (e *Elections) max(x, y int64) int64 {
	if x < y {
		return y
	}
	return x
}

func (e *Elections) needVotes(a, b, c int64) int64 {
	votes := int64(0)
	if a <= b {
		votes = e.max(votes, b-a+1)
	}

	if a <= c {
		votes = e.max(votes, c-a+1)
	}

	return votes
}

func (e *Elections) AWin() int64 {
	return e.needVotes(e.a, e.b, e.c)
}

func (e *Elections) BWin() int64 {
	return e.needVotes(e.b, e.a, e.c)
}

func (e *Elections) CWin() int64 {
	return e.needVotes(e.c, e.a, e.b)
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	var t int
	var e Elections

	fmt.Fscanf(reader, "%d\n", &t)
	for ; t > 0; t-- {
		fmt.Fscanf(reader, "%d %d %d\n", &e.a, &e.b, &e.c)
		fmt.Printf("%d %d %d\n", e.AWin(), e.BWin(), e.CWin())
	}
}

package main

import "fmt"

func max(a, b int) int {
        if a > b {
                return a
        }
        return b
}

func help(a, b, c int) int {
        return max(max(b, c)-a+1, 0)
}

func work() {
        var a, b, c int
        fmt.Scan(&a, &b, &c)
        fmt.Printf(
                "%v %v %v\n",
                help(a, b, c),
                help(b, a, c),
                help(c, a, b),
        )
}

func main() {
        var t int
        fmt.Scan(&t)
        for i := 0; i < t; i++ {
                work()
        }
}

package main

import (
	"fmt"
	"os"
)

func main() {
	testCase := 0
	fmt.Scanf("%d", &testCase)

	inputs := [][]int{}
	for i := 0; i < testCase; i++ {
		input := make([]int, 3)
		fmt.Fscan(os.Stdin, packAddrs(input)...)

		inputs = append(inputs, input)
	}

	for _, v := range inputs {
		topVote := 0
		for _, w := range v {
			if topVote < w {
				topVote = w
			}
		}

		countTopVote := 0
		for _, w := range v {
			if topVote == w {
				countTopVote++
			}
		}

		output := []int{}
		if countTopVote == 1 {
			for _, w := range v {
				if w != topVote {
					output = append(output, topVote-w+1)
				} else {
					output = append(output, 0)
				}
			}
		} else {
			for _, w := range v {
				if w == topVote {
					output = append(output, 1)
				} else {
					output = append(output, topVote-w+1)
				}
			}
		}

		fmt.Printf("%d %d %d\n", output[0], output[1], output[2])
	}
}

func packAddrs(n []int) []interface{} {
	p := make([]interface{}, len(n))
	for i := range n {
		p[i] = &n[i]
	}
	return p
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func max(a, b int) int {
	if a < b {
		return b
	}

	return a
}

func solve(a, b, c int) int {
	return max(-1, max(b - a, c - a)) + 1
}

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var t, a, b, c int
	_, _ = fmt.Fscan(r, &t)

	for ; t > 0; t-- {
		_, _ = fmt.Fscan(r, &a, &b, &c)
		fmt.Printf("%d %d %d\n", solve(a, b, c), solve(b, a, c), solve(c, a, b))
	}
}

package main

import (
	"fmt"
)

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func findEach(a, b, c int) int {
	if a > max(b, c) {
		return 0
	}
	return max(b, c) - a + 1
}

func solve() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	fmt.Println(findEach(a, b, c), findEach(b, a, c), findEach(c, a, b))
}

func main() {
	var t int
	fmt.Scan(&t)

	for i := 0; i < t; i++ {
		solve()
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var t, a, b, c int
	_, _ = fmt.Fscan(r, &t)
	for ; t > 0; t-- {
		_, _ = fmt.Fscan(r, &a, &b, &c)
		fmt.Printf("%d %d %d\n", candidate(a, b, c), candidate(b, a, c), candidate(c, a, b))
	}
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func candidate(score, a, b int) int {
	if score > max(a, b) {
		return 0
	}
	return max(a, b) + 1 - score
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var ignore bool
	res := [][]int{}

	scanner := bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		line := scanner.Text()
		if !ignore {
			ignore = true
			continue
		}
		var a, b, c int
		fmt.Sscanf(line, "%d %d %d", &a, &b, &c)
		var ra, rb, rc = max(b, c) + 1 - a, max(a, c) + 1 - b, max(a, b) + 1 - c
		res = append(res, []int{ra, rb, rc})
	}

	for _, v := range res {
		for i, n := range v {
			if n < 0 {
				n = 0
			}
			if i > 0 {
				fmt.Print(" ")
			}
			fmt.Print(n)
		}
		fmt.Println()
	}

}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

package main

import (
	"bufio"
	"os"
	"fmt"
)

func Max(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func calc(a int, b int, c int) int {
	temp := Max(b, c)
	if temp >= a {
		return (temp + 1) - a
	}
	return 0
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(reader, &n)
	for i := 0; i < n; i++ {
		var a, b, c int
		fmt.Fscan(reader, &a)
		fmt.Fscan(reader, &b)
		fmt.Fscan(reader, &c)
		fmt.Print(calc(a, b, c), " ")
		fmt.Print(calc(b, a, c), " ")
		fmt.Println(calc(c, b, a))
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func Solve(a, b, c int) int {
	if a > b && a > c {
		return 0
	}
	return Max(b, c) + 1 - a
}

func main() {
	var ntc, a, b, c int
	fmt.Fscan(in, &ntc)
	for t := 0; t < ntc; t++ {
		fmt.Fscan(in, &a, &b, &c)
		fmt.Fprintf(out, "%d %d %d\n", Solve(a, b, c), Solve(b, a, c), Solve(c, a, b))
	}
	out.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

type Obj struct {
	V   int
	Mod int
	Cnt int
}

func main() {

	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var t int
	fmt.Fscan(in, &t)

	for i := 0; i < t; i++ {

		var a, b, c int
		fmt.Fscan(in, &a, &b, &c)

		m, mCnt := max(a, b, c)

		if a <= m {
			a = m - a
			if mCnt != 1 || a != 0 {
				a++
			}
		}
		if b <= m {
			b = m - b
			if mCnt != 1 || b != 0 {
				b++
			}
		}
		if c <= m {
			c = m - c
			if mCnt != 1 || c != 0 {
				c++
			}
		}
		fmt.Fprintln(out, a, b, c)
	}

}

func max(a, b, c int) (m int, cnt int) {
	if a > b {
		m = a
	} else {
		m = b
	}
	if m < c {
		m = c
	}

	if a == m {
		cnt++
	}
	if b == m {
		cnt++
	}
	if c == m {
		cnt++
	}
	return
}

package main

import (
	"bufio"
	. "fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	var t, a, b, c int
	Fscan(in, &t)
	for t > 0 {
		Fscan(in, &a, &b, &c)
		m := maxOfThree(a, b, c)

		sa := m - a
		sb := m - b
		sc := m - c

		if sa == 0 {
			if a == b || a == c {
				sa += 1
			}
		} else {
			sa += 1
		}

		if sb == 0 {
			if a == b || b == c {
				sb += 1
			}
		} else {
			sb += 1
		}

		if sc == 0 {
			if a == c || b == c {
				sc += 1
			}
		} else {
			sc += 1
		}

		Println(sa, sb, sc)
		t--
	}

}

func max(n, m int) int {
	if n > m {
		return n
	}
	return m
}

func maxOfThree(n, m, l int) int {
	result := max(n, m)
	result = max(result, l)
	return result
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"time"
)

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MINN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func MAXX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

func ChangeStringToDate(x string) (t time.Time, err error) {
	t, err = time.Parse("2006-01-02", x)
	return
}

func DiffrenceBetweenTwoDates(first, second time.Time) int64 {
	date := first
	date2 := second
	k := date.Unix() - date2.Unix()
	return k
}

func Union(a, b []int) []int {
	m := make(map[int]bool)

	for _, item := range a {
		m[item] = true
	}

	for _, item := range b {
		if _, ok := m[item]; !ok {
			a = append(a, item)
		}
	}
	return a
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var a, b, c int64
		fmt.Fscan(input, &a, &b, &c)
		greatest := MAX(MAX(a, b), c)
		var num int
		if a == greatest {
			num++
		}
		if b == greatest {
			num++
		}
		if c == greatest {
			num++
		}

		if a < greatest {
			fmt.Println(greatest - a + 1)
		} else {
			if num == 1 {
				fmt.Println(0)
			} else {
				fmt.Println(1)
			}
		}

		if b < greatest {
			fmt.Println(greatest - b + 1)
		} else {
			if num == 1 {
				fmt.Println(0)
			} else {
				fmt.Println(1)
			}
		}
		if c < greatest {
			fmt.Println(greatest - c + 1)
		} else {
			if num == 1 {
				fmt.Println(0)
			} else {
				fmt.Println(1)
			}
		}
	}

}

package main

import (
	"fmt"
)

func max(a []int) int {
	x := a[0]
	for _, k := range a {
		if x < k {
			x = k
		}
	}
	return x
}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for ; t > 0; t-- {
		var a, b, c int
		fmt.Scanf("%d %d %d\n", &a, &b, &c)
		fmt.Printf("%d %d %d\n", max([]int{0, b + 1 - a, c + 1 - a}), max([]int{0, a + 1 - b, c + 1 - b}), max([]int{0, a + 1 - c, b + 1 - c}))
	}
}

package main

import "fmt"

func f(a, b, c int) (int, int, int) {
	var r1, r2, r3 int
	m1 := max(b, c)
	if max(b, c) >= a {
		r1 = m1 - a + 1
	}

	m2 := max(a, c)
	if m2 >= b {
		r2 = m2 - b + 1
	}

	m3 := max(a, b)
	if m3 >= c {
		r3 = m3 - c + 1
	}

	return r1, r2, r3
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	var a, b, c, t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		fmt.Scan(&a, &b, &c)
		fmt.Println(f(a, b, c))
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReaderSize(os.Stdin, 1024*1024)

	var T int
	fmt.Fscanf(r, "%d\n", &T)
	for t := 0; t < T; t++ {
		var a, b, c int
		fmt.Fscanf(r, "%d %d %d\n", &a, &b, &c)

		cnt := make(map[int]int)
		cnt[a]++
		cnt[b]++
		cnt[c]++

		x := a
		if b > x {
			x = b
		}
		if c > x {
			x = c
		}

		na := x - a
		nb := x - b
		nc := x - c

		if a == x && cnt[x] != 1 {
			na++
		}
		if a != x {
			na++
		}
		if b == x && cnt[x] != 1 {
			nb++
		}
		if b != x {
			nb++
		}
		if c == x && cnt[x] != 1 {
			nc++
		}
		if c != x {
			nc++
		}
		fmt.Println(na, nb, nc)
	}
}

package main

import (
	"bufio"
	"fmt"
	math "math"
	"os"
	"strconv"
	"strings"
)

func solve(arr ...float64) int {
	return int(math.Max(0, math.Max(arr[0], arr[1])+1-arr[2]))
}
func (sc *A) run() {
	T := sc.nextInt()
	for t := 0; t < T; t++ {
		arr := make([]float64, 3)
		for i := 0; i < len(arr); i++ {
			arr[i], _ = strconv.ParseFloat(sc.nextString(), 64)
		}
		fmt.Printf("%d %d %d\n", solve(arr...), solve(arr...), solve(arr...))
	}
}

func main() {
	file, err := os.Open("input.txt")
	var F *bufio.Reader
	if err == nil {
		F = bufio.NewReader(file)
		os.Stdin = file
	} else {
		F = bufio.NewReader(os.Stdin)
	}
	defer func(file *os.File) {
		_ = file.Close()
	}(file)
	NewA(F).run()
}

func NewA(r *bufio.Reader) *A {
	return &A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

type A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (sc *A) nextLine() string {
	line, err := sc.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	sc.split = []string{}
	sc.index = 0
	return line
}

func (sc *A) load() {
	if len(sc.split) <= sc.index {
		sc.split = strings.Split(sc.nextLine(), sc.separator)
		sc.index = 0
	}
}

func (sc *A) nextInt() int {
	sc.load()
	val, _ := strconv.Atoi(strings.TrimSpace(sc.split[sc.index]))
	sc.index++
	return val
}

func (sc *A) nextInt64() int64 {
	sc.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(sc.split[sc.index]), 10, 64)
	sc.index++
	return val
}

func (sc *A) nextString() string {
	sc.load()
	val := strings.TrimSpace(sc.split[sc.index])
	sc.index++
	return val
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func (sc *A) run() {
	T := sc.nextInt()
	for t := 0; t < T; t++ {
		arr := make([]int, 3)
		max := 0
		c := 0
		for i := 0; i < len(arr); i++ {
			arr[i] = sc.nextInt()
			if max <= arr[i] {
				if max == arr[i] {
					c++
				}
				max = arr[i]
			}
		}
		for i := 0; i < len(arr); i++ {
			if c == 3 {
				fmt.Print(arr[i]+1, " ")
			} else if arr[i] == max {
				fmt.Print(0, " ")
			} else {
				fmt.Print(max-arr[i]+1, " ")
			}
		}
		fmt.Println()
	}
}

func main() {
	file, err := os.Open("input.txt")
	var F *bufio.Reader
	if err == nil {
		F = bufio.NewReader(file)
		os.Stdin = file
	} else {
		F = bufio.NewReader(os.Stdin)
	}
	defer func(file *os.File) {
		_ = file.Close()
	}(file)
	NewA(F).run()
}

func NewA(r *bufio.Reader) *A {
	return &A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

type A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (sc *A) nextLine() string {
	line, err := sc.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	sc.split = []string{}
	sc.index = 0
	return line
}

func (sc *A) load() {
	if len(sc.split) <= sc.index {
		sc.split = strings.Split(sc.nextLine(), sc.separator)
		sc.index = 0
	}
}

func (sc *A) nextInt() int {
	sc.load()
	val, _ := strconv.Atoi(strings.TrimSpace(sc.split[sc.index]))
	sc.index++
	return val
}

func (sc *A) nextInt64() int64 {
	sc.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(sc.split[sc.index]), 10, 64)
	sc.index++
	return val
}

func (sc *A) nextString() string {
	sc.load()
	val := strings.TrimSpace(sc.split[sc.index])
	sc.index++
	return val
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func (sc *A) run() {
	T := sc.nextInt()
	for t := 0; t < T; t++ {
		arr := make([]int, 3)
		max := 0
		c := 0
		for i := 0; i < len(arr); i++ {
			arr[i] = sc.nextInt()
			if max <= arr[i] {
				if max == arr[i] {
					c++
				}
				max = arr[i]
			}
		}
		for i := 0; i < len(arr); i++ {
			if arr[i] == max && c != 3 {
				fmt.Print(0, " ")
			} else if c == 3 {
				fmt.Print(arr[i]+1, " ")
			} else {
				fmt.Print(max-arr[i]+1, " ")
			}
		}
		fmt.Println()
	}
}

func main() {
	file, err := os.Open("input.txt")
	var F *bufio.Reader
	if err == nil {
		F = bufio.NewReader(file)
		os.Stdin = file
	} else {
		F = bufio.NewReader(os.Stdin)
	}
	defer func(file *os.File) {
		_ = file.Close()
	}(file)
	NewA(F).run()
}

func NewA(r *bufio.Reader) *A {
	return &A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

type A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (sc *A) nextLine() string {
	line, err := sc.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	sc.split = []string{}
	sc.index = 0
	return line
}

func (sc *A) load() {
	if len(sc.split) <= sc.index {
		sc.split = strings.Split(sc.nextLine(), sc.separator)
		sc.index = 0
	}
}

func (sc *A) nextInt() int {
	sc.load()
	val, _ := strconv.Atoi(strings.TrimSpace(sc.split[sc.index]))
	sc.index++
	return val
}

func (sc *A) nextInt64() int64 {
	sc.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(sc.split[sc.index]), 10, 64)
	sc.index++
	return val
}

func (sc *A) nextString() string {
	sc.load()
	val := strings.TrimSpace(sc.split[sc.index])
	sc.index++
	return val
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func (sc *A) run() {
	T := sc.nextInt()
	for t := 0; t < T; t++ {
		arr := make([]int, 3)
		max := 0
		for i := 0; i < len(arr); i++ {
			arr[i] = sc.nextInt()
			if max < arr[i] {
				max = arr[i]
			}
		}
		for i := 0; i < len(arr); i++ {
			if arr[i] == max {
				fmt.Print(0, " ")
			} else {
				fmt.Print(max-arr[i]+1, " ")
			}
		}
		fmt.Println()
	}
}

func main() {
	file, err := os.Open("input.txt")
	var F *bufio.Reader
	if err == nil {
		F = bufio.NewReader(file)
		os.Stdin = file
	} else {
		F = bufio.NewReader(os.Stdin)
	}
	defer func(file *os.File) {
		_ = file.Close()
	}(file)
	NewA(F).run()
}

func NewA(r *bufio.Reader) *A {
	return &A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

type A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (sc *A) nextLine() string {
	line, err := sc.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	sc.split = []string{}
	sc.index = 0
	return line
}

func (sc *A) load() {
	if len(sc.split) <= sc.index {
		sc.split = strings.Split(sc.nextLine(), sc.separator)
		sc.index = 0
	}
}

func (sc *A) nextInt() int {
	sc.load()
	val, _ := strconv.Atoi(strings.TrimSpace(sc.split[sc.index]))
	sc.index++
	return val
}

func (sc *A) nextInt64() int64 {
	sc.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(sc.split[sc.index]), 10, 64)
	sc.index++
	return val
}

func (sc *A) nextString() string {
	sc.load()
	val := strings.TrimSpace(sc.split[sc.index])
	sc.index++
	return val
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func Max(arg ...int) int {
	m := arg[0]
	for _, v := range arg {
		if v > m {
			m = v
		}
	}
	return m
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		a, b, c := 0, 0, 0
		fmt.Fscan(f, &a, &b, &c)
		mx := Max(a, b, c)
		ma, mb, mc := mx-a+1, mx-b+1, mx-c+1
		if mx == a && mx > 0 {
			ma = 0
		}
		if mx == b && mx > 0 {
			mb = 0
		}
		if mx == c && mx > 0 {
			mc = 0
		}
		if ma == mb && ma == 0 {
			ma, mb = 1, 1
		}
		if mb == mc && mc == 0 {
			mb, mc = 1, 1
		}
		if ma == mc && ma == 0 {
			ma, mc = 1, 1
		}
		if ma == mb && mb == mc && ma == 0 {
			ma, mb, mc = 1, 1, 1
		}
		fmt.Fprintln(w, ma, mb, mc)
	}
	w.Flush()
}

func main() {
	solve()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func Max(arg ...int) int {
	m := arg[0]
	for _, v := range arg {
		if v > m {
			m = v
		}
	}
	return m
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		a, b, c := 0, 0, 0
		fmt.Fscan(f, &a, &b, &c)
		mx := Max(a, b, c)
		ma, mb, mc := mx-a+1, mx-b+1, mx-c+1
		if mx == a && mx > 0 {
			ma = 0
		}
		if mx == b && mx > 0 {
			mb = 0
		}
		if mx == c && mx > 0 {
			mc = 0
		}
		fmt.Fprintln(w, ma, mb, mc)
	}
	w.Flush()
}

func main() {
	solve()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func Max(arg ...int) int {
	m := arg[0]
	for _, v := range arg {
		if v > m {
			m = v
		}
	}
	return m
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		a, b, c := 0, 0, 0
		fmt.Fscan(f, &a, &b, &c)
		mx := Max(a, b, c)
		ma, mb, mc := mx-a+1, mx-b+1, mx-c+1
		if mx == a {
			ma = 0
		}
		if mx == b {
			mb = 0
		}
		if mx == c {
			mc = 0
		}
		fmt.Fprintln(w, ma, mb, mc)
	}
	w.Flush()
}

func main() {
	solve()
}

package main

import (
	"fmt"
	"os"
	"strconv"
)

func main() {
	//输入输出部分
	cnt := 0
	fmt.Fscan(os.Stdin, &cnt)
	ans := make([][]int, cnt)
	for j :=0; j < cnt; j++ {
		ans[j] = make([]int, 3)
		for i := 0; i < 3; i++ {
			fmt.Fscan(os.Stdin, &ans[j][i])
		}
	}
	//算法部分
	for i, sl := range ans{
		flag := 0
		max := 0
		if sl[0] >= sl[1] && sl[1] >= sl[2] {
			max = sl[0]
		} else if sl[1] >= sl[0] && sl[1] >= sl[2] {
			max = sl[1]
		} else {
			max = sl[2]
		}
		if sl[0] == max {flag++}
		if sl[1] == max {flag++}
		if sl[2] == max {flag++}
		for j, v := range sl {
			if v != max {
				ans[i][j] = max -v + 1
			} else {
				if flag == 1 {
					ans[i][j] = 0
				} else {
					ans[i][j] = 1
				}
			}
		}
	}

	for _, sl := range ans {
		fmt.Println(strconv.Itoa(sl[0]) + " " + strconv.Itoa(sl[1]) + " " + strconv.Itoa(sl[2]))
	}
}

package main

import (
	"fmt"
	"os"
	"strconv"
)

func main() {
	//输入输出部分
	cnt := 0
	fmt.Fscan(os.Stdin, &cnt)
	ans := make([][]int, cnt)
	for j :=0; j < cnt; j++ {
		ans[j] = make([]int, 3)
		for i := 0; i < 3; i++ {
			fmt.Fscan(os.Stdin, &ans[j][i])
		}
	}
	//算法部分
	for i, sl := range ans{
		if sl[0] ==  sl[1] && sl[1] == sl[2] {
			ans[i][0] =1
			ans[i][1] = 1
			ans[i][2] = 1
			continue
		}
		max := 0
		if sl[0] >= sl[1] && sl[1] >= sl[2] {
			max = sl[0]
		} else if sl[1] >= sl[0] && sl[1] >= sl[2] {
			max = sl[1]
		} else {
			max = sl[2]
		}
		for j, v := range sl {
			if v != max {
				ans[i][j] = max -v + 1
			} else {
				ans[i][j] = 0
			}
		}
	}

	for _, sl := range ans {
		fmt.Println(strconv.Itoa(sl[0]) + " " + strconv.Itoa(sl[1]) + " " + strconv.Itoa(sl[2]))
	}
}

package main

import (
	"fmt"
	"os"
	"strconv"
)

func main() {
	//输入输出部分
	cnt := 0
	fmt.Fscan(os.Stdin, &cnt)
	ans := make([][]int, cnt)
	for j :=0; j < cnt; j++ {
		ans[j] = make([]int, 3)
		for i := 0; i < 3; i++ {
			fmt.Fscan(os.Stdin, &ans[j][i])
		}
	}
	//算法部分
	for i, sl := range ans{
		if sl[0] ==  sl[1] && sl[1] == sl[2] {
			ans[i][0] += 1
			ans[i][1] += 1
			ans[i][2] += 1
			continue
		}
		max := 0
		if sl[0] >= sl[1] && sl[1] >= sl[2] {
			max = sl[0]
		} else if sl[1] >= sl[0] && sl[1] >= sl[2] {
			max = sl[1]
		} else {
			max = sl[2]
		}
		for j, v := range sl {
			if v != max {
				ans[i][j] = max -v + 1
			} else {
				ans[i][j] = 0
			}
		}
	}

	for _, sl := range ans {
		fmt.Println(strconv.Itoa(sl[0]) + " " + strconv.Itoa(sl[1]) + " " + strconv.Itoa(sl[2]))
	}
}

package main

import "fmt"

func main() {
	var T int
	fmt.Scan(&T)
	for i := 0; i < T; i++ {
		var a, b, c int
		fmt.Scan(&a, &b, &c)
		fmt.Println(ddd(a, b, c), ddd(b, a, c), ddd(c, a, b))
	}

}

func ddd(a, b, c int) int {
	if a > max(b, c) {
		return 0
	}
	return max(a, b) - a + 1
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

package main

import "fmt"

func main() {
	var T int
	fmt.Scan(&T)
	for i := 0; i < T; i++ {
		var a, b, c int
		fmt.Scan(&a, &b, &c)
		dd := max(a, max(b, c))
		if a == b && a == c {
			fmt.Println(a+1, b+1, c+1)
		} else if dd-b == 0 {
			fmt.Println(dd-a+1, "0", dd-c+1)
		} else if dd-c == 0 {
			fmt.Println(dd-a+1, dd-b+1, "0")
		} else if dd-a == 0 {
			fmt.Println("0", dd-b+1, dd-c+1)

		}
	}

}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

package main

import "fmt"

func main() {
	var T int
	fmt.Scan(&T)
	for i := 0; i < T; i++ {
		var a, b, c int
		fmt.Scan(&a, &b, &c)
		dd := max(a, max(b, c))
		if a == b && a == c {
			fmt.Println(dd-a+1, dd-b+1, dd-c+1)
		} else if dd-b == 0 {
			fmt.Println(dd-a+1, "0", dd-c+1)
		} else if dd-c == 0 {
			fmt.Println(dd-a+1, dd-b+1, "0")
		} else if dd-a == 0 {
			fmt.Println("0", dd-b+1, dd-c+1)

		}
	}

}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	var (
		t   int
		a   int
		b   int
		c   int
		max int
	)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	t, _ = strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		scanner.Scan()
		sl := strings.Split(scanner.Text(), " ")
		a, _ = strconv.Atoi(sl[0])
		b, _ = strconv.Atoi(sl[1])
		c, _ = strconv.Atoi(sl[2])
		if a > b {
			max = a
		} else {
			max = b
		}
		if c > max {
			max = c
		}
		an, bn, cn := 0, 0, 0
		if max != a {
			an = max - a + 1
		}
		if max != b {
			bn = max - b + 1
		}
		if max != c {
			cn = max - c + 1
		}
		if a == 0 && b == 0 && c == 0 {
			fmt.Println(1, 1, 1)
		} else {
			fmt.Println(an, bn, cn)
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func max(a int, rest ...int) int {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)

	for t := 0; t < T; t++ {
		a := make([]int, 3)
		fmt.Fscan(in, &a[0], &a[1], &a[2])

		m := max(a[0], a[1], a[2])

		for i := 0; i < len(a); i++ {
			if a[i] != m {
				fmt.Fprintf(out, "%d ", m-a[i]+1)
			} else {
				fmt.Fprintf(out, "%d ", 0)
			}
		}
		fmt.Fprintln(out)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	r = bufio.NewReader(os.Stdin)
	w = bufio.NewWriter(os.Stdout)

	T int
)

func main() {
	fmt.Fscan(r, &T)
	for ; T > 0; T-- {
		var a [3]int
		fmt.Fscan(r, &a[0], &a[1], &a[2])
		max, mul := 0, 0
		for i := 1; i < 3; i++ {
			if a[max] == a[i] {
				mul = 1
			} else if a[max] < a[i] {
				max = i
				mul = 0
			}
		}
		for i := range a {
			if mul == 0 && max == i {
				fmt.Fprint(w, 0, "")
			} else {
				fmt.Fprint(w, a[max] + 1 - a[i], "")
			}
		}
		fmt.Fprintln(w)
	}
	_ = w.Flush()
}

package main // ignore

import "fmt"

func max (a, b int) int {
    if a > b {
        return a
    } else {
        return b
    }
}

func solve () {
    var a, b, c int
    fmt.Scan(&a, &b, &c)

    ansa := max(max(b, c) - a, 0) + 1
    ansb := max(max(a, c) - b, 0) + 1
    ansc := max(max(a, b) - c, 0) + 1

    // if a + ansa == max(b, c) {ansa++}
    // if b + ansb == max(a, c) {ansb++}
    // if c + ansc == max(a, b) {ansc++}

    fmt.Println(ansa, ansb, ansc)
}

func main () {
    var t int
    fmt.Scan(&t)
    for ; t > 0; t-- {solve()}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var a, b, c int

func main() {

	r := bufio.NewReader(os.Stdin)

	var t int

	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {
		fmt.Fscan(r, &a, &b, &c)

		solve()

		fmt.Println()
	}
}

func solve() {
	var d1, d2 int
	if a - b < 0 {
		d1 = b - a + 1
	}
	if a - c < 0 {
		d2 = c - a + 1
	}
	fmt.Print(max(d1, d2))
	fmt.Print(" ")

	d1 = 0
	d2 = 0

	if b - a < 0 {
		d1 = a - b + 1
	}
	if b - c < 0 {
		d2 = c - b + 1
	}
	fmt.Print(max(d1, d2))
	fmt.Print(" ")

	d1 = 0
	d2 = 0

	if c - a < 0 {
		d1 = a - c + 1
	}
	if c - b < 0 {
		d2 = b - c + 1
	}
	fmt.Print(max(d1, d2))
	fmt.Print(" ")

}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


You are given two $$$n \times m$$$ matrices containing integers. A sequence of integers is strictly increasing if each next number is greater than the previous one. A row is strictly increasing if all numbers from left to right are strictly increasing. A column is strictly increasing if all numbers from top to bottom are strictly increasing. A matrix is increasing if all rows are strictly increasing and all columns are strictly increasing. For example, the matrix $$$\begin{bmatrix} 9&10&11\\ 11&12&14\\ \end{bmatrix}$$$ is increasing because each individual row and column is strictly increasing. On the other hand, the matrix $$$\begin{bmatrix} 1&1\\ 2&3\\ \end{bmatrix}$$$ is not increasing because the first row is not strictly increasing.Let a position in the $$$i$$$-th row (from top) and $$$j$$$-th column (from left) in a matrix be denoted as $$$(i, j)$$$. In one operation, you can choose any two numbers $$$i$$$ and $$$j$$$ and swap the number located in $$$(i, j)$$$ in the first matrix with the number in $$$(i, j)$$$ in the second matrix. In other words, you can swap two numbers in different matrices if they are located in the corresponding positions.You would like to make both matrices increasing by performing some number of operations (possibly none). Determine if it is possible to do this. If it is, print "Possible", otherwise, print "Impossible".

The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n,m \leq 50$$$) — the dimensions of each matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$a_{i1}, a_{i2}, \ldots, a_{im}$$$ ($$$1 \leq a_{ij} \leq 10^9$$$) — the number located in position $$$(i, j)$$$ in the first matrix. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$b_{i1}, b_{i2}, \ldots, b_{im}$$$ ($$$1 \leq b_{ij} \leq 10^9$$$) — the number located in position $$$(i, j)$$$ in the second matrix.

Print a string "Impossible" or "Possible".

NoteThe first example, we can do an operation on the top left and bottom right cells of the matrices. The resulting matrices will be $$$\begin{bmatrix} 9&10\\ 11&12\\ \end{bmatrix}$$$ and $$$\begin{bmatrix} 2&4\\ 3&5\\ \end{bmatrix}$$$.In the second example, we don't need to do any operations.In the third example, no matter what we swap, we can't fix the first row to be strictly increasing in both matrices.

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n, m := 0, 0
	fmt.Fscanf(in, "%d %d\n", &n, &m)
	a := make([][]int, n)
	b := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
		b[i] = make([]int, m)
	}
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			fmt.Fscanf(in, "%d", &a[i][j])
		}
		fmt.Fscanf(in, "\n")
	}
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			fmt.Fscanf(in, "%d", &b[i][j])
		}
		fmt.Fscanf(in, "\n")
	}
	ans := true
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if i > 0 {
				if !(a[i][j] > a[i-1][j] && b[i][j] > b[i-1][j] || a[i][j] > b[i-1][j] && b[i][j] > a[i-1][j]) {
					ans = false
				}
			}
			if j > 0 {
				if !(a[i][j] > a[i][j-1] && b[i][j] > b[i][j-1] || a[i][j] > b[i][j-1] && b[i][j] > a[i][j-1]) {
					ans = false
				}
			}
		}
	}
	if ans {
		fmt.Fprintf(out, "Possible\n")
	} else {
		fmt.Fprintf(out, "Impossible\n")
	}
	return
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}