It was the third month of remote learning, Nastya got sick of staying at dormitory, so she decided to return to her hometown. In order to make her trip more entertaining, one of Nastya's friend presented her an integer array $$$a$$$. Several hours after starting her journey home Nastya remembered about the present. To entertain herself she decided to check, are there four different indices $$$x, y, z, w$$$ such that $$$a_x + a_y = a_z + a_w$$$.Her train has already arrived the destination, but she still hasn't found the answer. Can you help her unravel the mystery?

The first line contains the single integer $$$n$$$ ($$$4 \leq n \leq 200\,000$$$) — the size of the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq 2.5 \cdot 10^6$$$).

Print "YES" if there are such four indices, and "NO" otherwise. If such indices exist, print these indices $$$x$$$, $$$y$$$, $$$z$$$ and $$$w$$$ ($$$1 \le x, y, z, w \le n$$$). If there are multiple answers, print any of them.

NoteIn the first example $$$a_2 + a_3 = 1 + 5 = 2 + 4 = a_1 + a_6$$$. Note that there are other answer, for example, 2 3 4 6.In the second example, we can't choose four indices. The answer 1 2 2 3 is wrong, because indices should be different, despite that $$$a_1 + a_2 = 1 + 3 = 3 + 1 = a_2 + a_3$$$

package main

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

type setType struct {
	s1, s2 int
}

var ar []int

const maxTokenSize = 2500000 * 7

func main() {
	var size int

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, maxTokenSize), maxTokenSize)

	scanner.Scan()

	size, _ = strconv.Atoi(scanner.Text())

	var ar = make([]int, 0, size)
	var sums = make(map[int]setType, size)
	var val int

	scanner.Scan()

	inputs := strings.Split(scanner.Text(), " ")

	for _, v := range inputs {
		val, _ = strconv.Atoi(v)
		ar = append(ar, val)
	}

	for s1, v1 := range ar {
		for e1, v2 := range ar {
			if s1 >= e1 {
				continue
			}

			sum := v1 + v2
			if set, ok := sums[sum]; ok && s1 != set.s1 && s1 != set.s2 && e1 != set.s1 && e1 != set.s2 {
				fmt.Println("YES")
				fmt.Println(s1+1, e1+1, set.s1+1, set.s2+1)
				return
			} else if ok == false {
				sums[sum] = setType{s1: s1, s2: e1}
			}
		}
	}

	fmt.Println("NO")
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
// 	redirectInputToFile(reader, "input.txt")

	T := 1
	// scan(&T)
	for t := 0; t < T; t++ {
		solve()
	}
}

var set = [3e6]bool{}
var diff = [3e6][2]int{}

func solve() {
	var n int
	scan(&n)
	var a = make([][2]int, n)
	for i := range a {
		scan(&a[i][0])
		a[i][1] = i
	}
	sort.Slice(a, func(i, j int) bool { return a[i][0] < a[j][0] })
	for z := range a {
		for w := z + 1; w < len(a); w++ {
			d := a[w][0] - a[z][0]
			if set[d] {
				z, w := a[z][1], a[w][1]
				x, y := a[diff[d][0]][1], a[diff[d][1]][1]
				printf("YES\n%v %v %v %v", x+1, w+1, y+1, z+1)
				return
			}
		}
		for x := 0; x < z; x++ {
			d := a[z][0] - a[x][0]
			set[d] = true
			diff[d] = [2]int{x, z}
		}
	}
	printf("NO\n")
}

package main

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

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func main() {
	defer writer.Flush()
	//redirectInputToFile(reader, "input.txt")

	T := 1
	// scan(&T)
	for t := 0; t < T; t++ {
		solve()
	}
}

// --------------------------------------------------------------------- //

func solve() {
	var n int
	scan(&n)
	a := make([][2]int, n)
	for i := range a {
		scan(&a[i][0])
		a[i][1] = i
	}
	sort.Slice(a, func(i, j int) bool {
		return a[i][0] < a[j][0]
	})

	cnt := [3e6][2]int{}
	cnt[a[1][0]-a[0][0]] = [2]int{a[0][1], a[1][1]}

	for i := 2; i < len(a); i++ {
		for j := i + 1; j < len(a); j++ {
			d := a[j][0] - a[i][0]
			if cnt[d] != [2]int{} {
				printf("YES\n%d %d %d %d", a[j][1]+1, cnt[d][0]+1, a[i][1]+1, cnt[d][1]+1)
				return
			}
		}
		for j := 0; j < i; j++ {
			cnt[a[i][0]-a[j][0]] = [2]int{a[j][1], a[i][1]}
		}
	}

	printf("NO\n")
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1500A(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n int
	Fscan(in, &n)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	p := [5e6 + 1][2]int{}
	for i, v := range a {
		for j := i + 1; j < n; j++ {
			s := v + a[j]
			if p := p[s]; p[1] > 0 && i != p[0] && i != p[1] && j != p[0] && j != p[1] {
				Fprint(out, "YES\n", p[0]+1, p[1]+1, i+1, j+1)
				return
			}
			p[s] = [2]int{i, j}
		}
	}
	Fprint(out, "NO")
}
func main() { CF1500A(os.Stdin, os.Stdout) }

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	var n int
	Fscan(in, &n)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	p := [5e6+1][2]int{}
	for i, v := range a {
		for j := i + 1; j < n; j++ {
			s := v + a[j]
			if x, y := p[s][0], p[s][1]; y > 0 && i != x && i != y && j != x && j != y {
				Print("YES\n", x+1, y+1, i+1, j+1)
				return
			}
			p[s] = [2]int{i, j}
		}
	}
	Print("NO")
}

package main

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

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

	//tc := readNum(reader)
	n := readNum(reader)
	A := readNNums(reader, n)
	res := solve(A)
	//buf.WriteString(fmt.Sprintf("%d\n", res))
	if len(res) > 0 {
		fmt.Println("YES")
		fmt.Printf("%d %d %d %d\n", res[0], res[1], res[2], res[3])
	} else {
		fmt.Println("NO")
	}
}

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(A []int) []int {
	var a, b int
	for _, num := range A {
		if num > a {
			b = a
			a = num
		} else if num > b {
			b = num
		}
	}

	S := a + b
	x := make([]int, S+1)
	y := make([]int, S+1)
	for i := 0; i <= S; i++ {
		x[i] = -1
		y[i] = -1
	}

	for i := 0; i < len(A); i++ {
		for j := i + 1; j < len(A); j++ {
			sum := A[i] + A[j]
			if x[sum] >= 0 && x[sum] != i && y[sum] != j && y[sum] != i {
				return []int{x[sum] + 1, y[sum] + 1, i + 1, j + 1}
			}
			x[sum] = i
			y[sum] = j
		}
	}
	return nil
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

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

	// single test case
	var n int
	Fscan(in, &n)
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		Fscan(in, &a[i])
	}

	s := [5e6 + 1][2]int{}
	for i, ai := range a {
		for j := i + 1; j < n; j++ {
			sum := ai + a[j]
			if x, y := s[sum][0], s[sum][1]; y > 0 && i != x && i != y && j != x && j != y {
				Fprintln(out, "YES")
				Fprint(out, x+1, y+1, i+1, j+1)
				return
			}
			s[sum] = [2]int{i, j}
		}
	}
	Fprintln(out, "NO")
	// 입력 에러 방지
	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("읽지않은 데이터 발견：\n" + _s)
	}
}

// LETYLETYLETY
func main() { CF707A(os.Stdin, os.Stdout) }

// YTELYTELYTEL

package main

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

type setType struct {
	s1, s2 int
}

var ar []int

const maxTokenSize = 2500000 * 7

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

	var ar = make([]int, 0, size)
	var sums = make(map[int]setType, size)
	var val int

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, maxTokenSize), maxTokenSize)
	scanner.Scan()

	inputs := strings.Split(scanner.Text(), " ")

	for _, v := range inputs {
		val, _ = strconv.Atoi(v)
		ar = append(ar, val)
	}

	for s1, v1 := range ar {
		for e1, v2 := range ar {
			if s1 >= e1 {
				continue
			}

			sum := v1 + v2
			if set, ok := sums[sum]; ok && s1 != set.s1 && s1 != set.s2 && e1 != set.s1 && e1 != set.s2 {
				fmt.Println("YES")
				fmt.Println(s1+1, e1+1, set.s1+1, set.s2+1)
				return
			} else if ok == false {
				sums[sum] = setType{s1: s1, s2: e1}
			}
		}
	}

	fmt.Println("NO")
}

package main

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

type setType struct {
	s1, s2 int
}

var ar []int

const maxTokenSize int = 2500000 * 7

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

	var ar = make([]int, 0, size)
	var sums = make(map[int]setType, size)
	var val int

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, maxTokenSize), maxTokenSize)
	scanner.Scan()
	for _, v := range strings.Split(scanner.Text(), " ") {
		val, _ = strconv.Atoi(v)
		ar = append(ar, val)
	}

	for s1, v1 := range ar {
		for e1, v2 := range ar {
			if s1 >= e1 {
				continue
			}

			sum := v1 + v2
			if set, ok := sums[sum]; ok && s1 != set.s1 && s1 != set.s2 && e1 != set.s1 && e1 != set.s2 {
				fmt.Println("YES")
				fmt.Println(s1+1, e1+1, set.s1+1, set.s2+1)
				return
			} else if ok == false {
				sums[sum] = setType{s1: s1, s2: e1}
			}
		}
	}

	fmt.Println("NO")
}

package main

import (
	"fmt"
)

type setType struct {
	s1, s2 int
}

var ar []int

func main() {
	var size int
	fmt.Scan(size)

	var ar = make([]int, 0, size)
	var sums = make(map[int]setType, size)
	var val int

	for ; size > 0; size-- {
		fmt.Scan(&val)

		ar = append(ar, val)
	}

	for s1, v1 := range ar {
		for e1, v2 := range ar {
			if s1 == e1 {
				continue
			}

			sum := v1 + v2
			if set, ok := sums[sum]; ok && check(s1, e1, set.s1, set.s2) {
				fmt.Println("YES")
				fmt.Println(set.s1+1, set.s2+1, s1+1, e1+1)
				return
			} else if ok == false {
				sums[sum] = setType{s1: s1, s2: e1}
			}
		}
	}

	fmt.Println("NO")
}
func check(s1, e1, e2, s2 int) bool {
	return s1 != e1 && s1 != e2 && s1 != s2 && e1 != e2 && e1 != s2 && e2 != s2
}

package main

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

type setType struct {
	s1, s2 int
}

var ar []int

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	size, _ := strconv.Atoi(scanner.Text())

	ar = make([]int, 0, size)

	scanner.Scan()
	values := strings.Split(scanner.Text(), " ")

	for _, v := range values {
		k, _ := strconv.Atoi(v)
		ar = append(ar, k)
	}

	sums := make(map[int]setType, size)

	for s1, v1 := range ar {
		for e1, v2 := range ar {
			if s1 == e1 {
				continue
			}

			sum := v1 + v2
			if set, ok := sums[sum]; ok && check(s1, e1, set.s1, set.s2) {
				fmt.Println("YES")
				fmt.Println(set.s1+1, set.s2+1, s1+1, e1+1)
				return
			} else if ok == false {
				sums[sum] = setType{s1: s1, s2: e1}
			}
		}
	}

	fmt.Println("NO")
}
func check(s1, e1, e2, s2 int) bool {
	return s1 != e1 && s1 != e2 && s1 != s2 && e1 != e2 && e1 != s2 && e2 != s2
}

package main

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

type setType struct {
	s1, s2 int
}

var ar []int

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	size, _ := strconv.Atoi(scanner.Text())

	ar = make([]int, 0, size)

	scanner.Scan()
	values := strings.Split(scanner.Text(), " ")

	for _, v := range values {
		k, _ := strconv.Atoi(v)
		ar = append(ar, k)
	}

	sums := make(map[int]setType, size)

	for s1, v1 := range ar {
		for e1, v2 := range ar {
			if s1 == e1 {
				continue
			}

			sum := v1 + v2
			if set, ok := sums[sum]; ok && check(s1, e1, set.s1, set.s2) {
				fmt.Println("YES")
				fmt.Println(s1+1, e1+1, set.s1+1, set.s2+1)
				return
			} else {
				sums[sum] = setType{s1, e1}
			}
		}
	}

	fmt.Println("NO")
}
func check(s1, e1, e2, s2 int) bool {
	return s1 != e1 && s1 != e2 && s1 != s2 && e1 != e2 && e1 != s2 && e2 != s2
}

package main

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

type setType struct {
	s1, s2 int
}

var ar []int

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	size, _ := strconv.Atoi(scanner.Text())

	ar = make([]int, 0, size)

	scanner.Scan()
	values := strings.Split(scanner.Text(), " ")

	for _, v := range values {
		k, _ := strconv.Atoi(v)
		ar = append(ar, k)
	}

	sums := make(map[int]setType, size)

	for s1, v1 := range ar {
		for e1, v2 := range ar {

			sum := v1 + v2
			if set, ok := sums[sum]; ok && check(e1, s1, set.s1, set.s2) {
				fmt.Println("YES")
				fmt.Println(s1+1, e1+1, set.s1+1, set.s2+1)
				return
			} else {
				sums[sum] = setType{s1, e1}
			}
		}
	}

	fmt.Println("NO")
}
func check(s1, e1, e2, s2 int) bool {
	return s1 != e1 && s1 != e2 && s1 != s2 && e1 != e2 && e1 != s2 && e2 != s2
}

package main

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

type setType struct {
	s1, s2 int
}

var ar []int

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	size, _ := strconv.Atoi(scanner.Text())

	ar = make([]int, 0, size)

	scanner.Scan()
	values := strings.Split(scanner.Text(), " ")

	for _, v := range values {
		k, _ := strconv.Atoi(v)
		ar = append(ar, k)
	}

	sums := make(map[int]setType, size)

	for s1, v1 := range ar {
		for e1, v2 := range ar {
			if s1 >= e1 {
				continue
			}

			sum := v1 + v2
			if set, ok := sums[sum]; ok && check(e1, s1, set.s1, set.s2) {
				fmt.Println("YES")
				fmt.Println(s1+1, e1+1, set.s1+1, set.s2+1)
				return
			} else {
				sums[sum] = setType{s1, e1}
			}
		}
	}

	fmt.Println("NO")
}
func check(s1, e1, e2, s2 int) bool {
	return s1 != e1 && s1 != e2 && s1 != s2 && e1 != e2 && e1 != s2 && e2 != s2
}

package main

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

type setType struct {
	s1, s2 int
}

var ar []int

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	size, _ := strconv.Atoi(scanner.Text())

	ar = make([]int, 0, size)

	scanner.Scan()
	values := strings.Split(scanner.Text(), " ")

	for _, v := range values {
		k, _ := strconv.Atoi(v)
		ar = append(ar, k)
	}

	sums := make(map[int]setType, size)

	for s1, v1 := range ar {
		for e1, v2 := range ar {
			if s1 >= e1 {
				continue
			}

			sum := v1 + v2
			if set, ok := sums[sum]; ok {
				fmt.Println("YES")
				fmt.Println(s1+1, e1+1, set.s1+1, set.s2+1)
				return
			} else {
				sums[sum] = setType{s1, e1}
			}
		}
	}

	fmt.Println("NO")
}

package main

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

type setType struct {
	s1, s2 int
}

var ar []int

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	size, _ := strconv.Atoi(scanner.Text())

	ar = make([]int, 0, size)

	scanner.Scan()
	values := strings.Split(scanner.Text(), " ")

	for _, v := range values {
		k, _ := strconv.Atoi(v)
		ar = append(ar, k)
	}

	l := len(ar)
	sums := make(map[int]setType, size)

	for s1 := 0; s1 <= l-1; s1++ {
		for e1 := 0; e1 <= l-1; e1++ {
			if e1 == s1 {
				continue
			}

			sum := ar[s1] + ar[e1]
			if set, ok := sums[sum]; ok && check(s1, e1, set.s1, set.s2) {
				fmt.Println("YES")
				fmt.Println(s1+1, e1+1, set.s1+1, set.s2+1)
				return
			} else {
				sums[sum] = setType{s1, e1}
			}
		}
	}

	fmt.Println("NO")
}

func check(s1, e1, e2, s2 int) bool {
	return s1 != e1 && s1 != e2 && s1 != s2 && e1 != e2 && e1 != s2 && e2 != s2
}

package main

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

var inputs sortableMap

type entry struct {
	index int
	value int
}

type setType struct {
	s1, s2 int
}

type sortableMap []entry

var _ sort.Interface = sortableMap{}

func (s sortableMap) Len() int {
	return len(s)
}

func (s sortableMap) Less(i, j int) bool {
	return s[i].value < s[j].value
}

func (s sortableMap) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	size, _ := strconv.Atoi(scanner.Text())

	inputs = make(sortableMap, 0, size)

	scanner.Scan()
	values := strings.Split(scanner.Text(), " ")

	for i, v := range values {
		k, _ := strconv.Atoi(v)
		inputs = append(inputs, entry{index: i + 1, value: k})
	}

	l := len(inputs)
	sums := make(map[int]setType, 10)

	for s1 := 0; s1 <= l-1; s1++ {
		for e1 := 0; e1 <= l-1; e1++ {
			if e1 == s1 {
				continue
			}

			sum := inputs[s1].value + inputs[e1].value
			if set, ok := sums[sum]; ok && check(s1, e1, set.s1, set.s2) {
				fmt.Println("YES")
				fmt.Println(inputs[s1].index, inputs[e1].index, inputs[set.s1].index, inputs[set.s2].index)
				return
			} else {
				sums[sum] = setType{s1, e1}
			}
		}
	}

	fmt.Println("NO")
}

func check(s1, e1, e2, s2 int) bool {
	return s1 != e1 && s1 != e2 && s1 != s2 && e1 != e2 && e1 != s2 && e2 != s2
}

package main

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

var inputs sortableMap

type entry struct {
	index int
	value int
}

type sortableMap []entry

var _ sort.Interface = sortableMap{}

func (s sortableMap) Len() int {
	return len(s)
}

func (s sortableMap) Less(i, j int) bool {
	return s[i].value < s[j].value
}

func (s sortableMap) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	size, _ := strconv.Atoi(scanner.Text())

	inputs = make(sortableMap, 0, size)

	scanner.Scan()
	values := strings.Split(scanner.Text(), " ")

	for i, v := range values {
		k, _ := strconv.Atoi(v)
		inputs = append(inputs, entry{index: i + 1, value: k})
	}

	sort.Sort(inputs)

	l := len(inputs)

	for s1 := 0; s1 <= l-1; s1 = s1 + 2 {
		for e1 := s1; e1 <= l-1; e1++ {
			if s1 == e1 {
				continue
			}
			for s2 := e1; s2 <= l-1; s2++ {
				if s2 == e1 {
					continue
				}

				f := inputs[s1].value + inputs[e1].value - inputs[s2].value
				if f <= 0 {
					continue
				}

				etmp := sort.Search(len(inputs), func(i int) bool {
					return inputs[i].value >= f
				})

				if etmp != l && check(s1, e1, s2, etmp) && inputs[etmp].value == f {
					fmt.Println("YES")
					fmt.Println(inputs[s1].index, inputs[e1].index, inputs[s2].index, inputs[etmp].index)
					return
				}
			}
		}
	}

	fmt.Println("NO")
}

func check(s1, e1, e2, s2 int) bool {
	return s1 != e1 && s1 != e2 && s1 != s2 && e1 != e2 && e1 != s2 && e2 != s2
}

package main

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

var inputs sortableMap

type entry struct {
	index int
	value int
}

type sortableMap []entry

var _ sort.Interface = sortableMap{}

func (s sortableMap) Len() int {
	return len(s)
}

func (s sortableMap) Less(i, j int) bool {
	return s[i].value < s[j].value
}

func (s sortableMap) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	size, _ := strconv.Atoi(scanner.Text())

	inputs = make(sortableMap, 0, size)

	scanner.Scan()
	values := strings.Split(scanner.Text(), " ")

	for i, v := range values {
		k, _ := strconv.Atoi(v)
		inputs = append(inputs, entry{index: i + 1, value: k})
	}

	sort.Sort(inputs)

	l := len(inputs)

	for s1 := 0; s1 <= l-1; s1++ {
		for e1 := 0; e1 <= l-1; e1++ {
			if s1 >= e1 {
				continue
			}
			for s2 := 0; s2 <= l-1; s2++ {
				if e1 >= s2 {
					continue
				}
				for e2 := 0; e2 <= l-1; e2++ {
					if s2 >= e2 {
						continue
					}

					f := inputs[s1].value + inputs[e1].value - inputs[s2].value
					if f <= 0 {
						continue
					}

					etmp := sort.Search(len(inputs), func(i int) bool {
						return inputs[i].value >= f
					})

					if etmp != l && check(s1, e1, s2, etmp) && inputs[etmp].value == f {
						fmt.Println("YES")
						fmt.Println(inputs[s1].index, inputs[e1].index, inputs[s2].index, inputs[etmp].index)
						return
					}
				}
			}
		}
	}

	fmt.Println("NO")
}

func check(s1, e1, e2, s2 int) bool {
	return s1 != e1 && s1 != e2 && s1 != s2 && e1 != e2 && e1 != s2 && e2 != s2
}

package main

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

var inputs sortableMap

type entry struct {
	index int
	value int
}

type sortableMap []entry

var _ sort.Interface = sortableMap{}

func (s sortableMap) Len() int {
	return len(s)
}

func (s sortableMap) Less(i, j int) bool {
	return s[i].value < s[j].value
}

func (s sortableMap) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	size, _ := strconv.Atoi(scanner.Text())

	inputs = make(sortableMap, 0, size)

	scanner.Scan()
	values := strings.Split(scanner.Text(), " ")

	for i, v := range values {
		k, _ := strconv.Atoi(v)
		inputs = append(inputs, entry{index: i, value: k})
	}

	sort.Sort(inputs)

	l := len(inputs)

	for s1 := 0; s1 <= l-1; s1++ {
		for e1 := 0; e1 <= l-1; e1++ {
			for s2 := 0; s2 <= l-1; s2++ {
				for e2 := 0; e2 <= l-1; e2++ {
					f := inputs[s1].value + inputs[e1].value - inputs[s2].value
					if f <= 0 {
						continue
					}

					etmp := sort.Search(len(inputs), func(i int) bool {
						return inputs[i].value >= f
					})

					if etmp != l && check(s1, e1, s2, etmp) && inputs[etmp].value == f {
						fmt.Println("YES")
						fmt.Println(s1, e1, s2, etmp)
						return
					}
				}
			}
		}
	}

	fmt.Println("NO")
}

func check(s1, e1, e2, s2 int) bool {
	return s1 != e1 && s1 != e2 && s1 != s2 && e1 != e2 && e1 != s2 && e2 != s2
}

package main

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

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func main() {
	defer writer.Flush()
	//redirectInputToFile(reader, "input.txt")

	T := 1
	// scan(&T)
	for t := 0; t < T; t++ {
		solve()
	}
}

// --------------------------------------------------------------------- //

func solve() {
	var n int
	scan(&n)
	a := make([][2]int, n)
	for i := range a {
		scan(&a[i][0])
		a[i][1] = i
	}
	sort.Slice(a, func(i, j int) bool {
		return a[i][0] < a[j][0]
	})

	cnt := make(map[int][]int)
	for i := range a {
		for j := i + 1; j < len(a); j++ {
			diff := a[j][0] - a[i][0]
			if x, ok := cnt[diff]; ok {
				printf("YES\n%d %d ", a[i][1]+1, a[j][1]+1)
				for _, i := range x {
					printf("%d ", i+1)
				}
				return
			}
		}
		for j := 0; j < i; j++ {
			diff := a[i][0] - a[j][0]
			cnt[diff] = []int{a[i][1], a[j][1]}
		}
	}

	printf("NO\n")
}

package main

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

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func main() {
	defer writer.Flush()
	//redirectInputToFile(reader, "input.txt")

	T := 1
	// scan(&T)
	for t := 0; t < T; t++ {
		solve()
	}
}

// --------------------------------------------------------------------- //

func solve() {
	var n int
	scan(&n)
	a := make([][2]int, n)
	for i := range a {
		scan(&a[i][0])
		a[i][1] = i
	}
	sort.Slice(a, func(i, j int) bool {
		return a[i][0] < a[j][0]
	})

	cnt := make(map[int][]int)
	for i := range a {
		for j := i + 1; j < len(a); j++ {
			diff := a[j][0] - a[i][0]
			if x, ok := cnt[diff]; ok {
				printf("YES\n%d %d ", a[i][1]+1, a[j][1]+1)
				for _, i := range x {
					printf("%d ", i+1)
				}
				return
			}
		}
		for j := 0; j < i; j++ {
			diff := a[i][0] - a[j][0]
			cnt[diff] = append(cnt[diff], a[i][1], a[j][1])
		}
	}

	printf("NO\n")
}

package main

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

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func main() {
	defer writer.Flush()
	//redirectInputToFile(reader, "input.txt")

	T := 1
	// scan(&T)
	for t := 0; t < T; t++ {
		solve()
	}
}

// --------------------------------------------------------------------- //

func solve() {
	var n int
	scan(&n)
	a := make([]int, n)
	for i := range a {
		scan(&a[i])
	}

	cnt := make(map[int][]int)
	for i := range a {
		for j := i + 1; j < len(a); j++ {
			sum := a[i] + a[j]
			if x, ok := cnt[sum]; ok {
				printf("YES\n%d %d ", i+1, j+1)
				for _, i := range x {
					printf("%d ", i+1)
				}
				return
			}
		}
		for j := 0; j < i; j++ {
			cnt[a[i]+a[j]] = append(cnt[a[i]+a[j]], i, j)
		}
	}

	printf("NO\n")
}


Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" contains a typo). Besides, a couple of identical letters immediately followed by another couple of identical letters is a typo too (for example, words "helloo" and "wwaatt" contain typos).Write a code that deletes the minimum number of letters from a word, correcting described typos in the word. You are allowed to delete letters from both ends and from the middle of the word.

The single line of the input contains word s, its length is from 1 to 200000 characters. The given word s consists of lowercase English letters.

Print such word t that it doesn't contain any typos described in the problem statement and is obtained from s by deleting the least number of letters. If there are multiple solutions, print any of them.

NoteThe second valid answer to the test from the statement is "heloo".

package main

import "fmt"
import "os"
import "bufio"

func main(){
	var c rune
	var a rune = 1
	var aa rune = 2
	var aaa rune = 3
	w := bufio.NewWriter(os.Stdout)
	for string(c) != "\n" {
		fmt.Scanf("%c", &c)
		if !(aaa == aa && a == c) && !(c == a && a == aa) {
			w.WriteString(string(c))
			aaa = aa
			aa = a
			a = c
		}
	}
	w.Flush()
}

package main

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

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

var (
	st  string
	s   []byte
	ans []byte
	//s  string
)

func main() {

	defer out.Flush()
	in.Split(bufio.ScanWords)

	fmt.Scan(&st)

	a := []byte(st)

	ln := len(a)

	if ln < 2 {
		fmt.Print(st)
		out.Flush()
		os.Exit(0)
	}
	s = append(s, a[0], a[1])

	for i := 2; i < ln; i++ {
		if (st[i] != st[i-1]) || (st[i] != st[i-2]) {
			//s = s + st[i]
			s = append(s, a[i])
		}
	}

	ln = len(s)

	//fmt.Println(s)
	if ln < 4 {
		fmt.Print(string(s))
	} else {

		ans = append(ans, s[0], s[1], s[2])

		for i := 3; i < ln; i++ {
			if (s[i] != ans[len(ans)-1]) || (ans[len(ans)-2] != ans[len(ans)-3]) {
				ans = append(ans, s[i])
			}
			//fmt.Println(s[i-3], " ", s[i-2], " ", s[i-1], " ", s[i])
			//fmt.Println(string(ans))
		}
	}

	fmt.Print(string(ans))
}

package main

import (
	"fmt"
)

func main() {
	const N int = 200000
	var counter = [N]int{}
	var typo string
	fmt.Scan(&typo)
	length := len(typo)
	tail := 0
	for i := 0; i < length; {
		j := i
		for ; j < length && typo[i] == typo[j]; j++ {
		}
		counter[tail] = j - i
		i = j
		tail++
	}
	for counter_iter, index := 0, 0; counter_iter < tail; {
		temp_iter := counter_iter
		for ; temp_iter < tail && counter[temp_iter] > 1; temp_iter++ {
		}
		for bit := 0; counter_iter < tail && counter_iter <= temp_iter; counter_iter++ {
			if (bit&1) == 0 && counter[counter_iter] > 1 {
				fmt.Printf("%c%c", typo[index], typo[index])
			} else {
				fmt.Printf("%c", typo[index])
			}
			index += counter[counter_iter]
			bit ^= 1
		}
	}
	fmt.Println()
}

package main

import "fmt"
import "os"
import "bufio"

func main(){
	var c rune
	var a rune = 1
	var aa rune = 2
	var aaa rune = 3
	w := bufio.NewWriter(os.Stdin)
	for string(c) != "\n" {
		fmt.Scanf("%c", &c)
		if !(aaa == aa && a == c) && !(c == a && a == aa) {
			w.WriteString(string(c))
			aaa = aa
			aa = a
			a = c
		}
	}
	w.Flush()
}

package main

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

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

var (
	st string
	//s  string
)

func main() {

	defer out.Flush()
	in.Split(bufio.ScanWords)

	fmt.Scan(&st)

	a := []byte(st)

	ln := len(a)
	s := a[:2]

	for i := 2; i < ln; i++ {
		if (st[i] != st[i-1]) || (st[i] != st[i-2]) {
			//s = s + st[i]
			s = append(s, a[i])
		}
	}

	ln = len(s)
	ans := s

	if ln < 4 {
		fmt.Print(string(ans))
	} else {

		ans = s[:3]

		for i := 3; i < ln; i++ {
			if (s[i] != s[i-1]) || (s[i-2] != s[i-3]) {
				ans = append(ans, s[i])
			}
		}
	}

	fmt.Print(string(ans))
}

package main

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

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

var (
	st string
	//s  string
)

func main() {

	defer out.Flush()
	in.Split(bufio.ScanWords)

	fmt.Scan(&st)

	a := []byte(st)

	ln := len(a)
	s := a[:2]

	for i := 2; i < ln; i++ {
		if (st[i] != st[i-1]) || (st[i] != st[i-2]) {
			//s = s + st[i]
			s = append(s, a[i])
		}
	}

	ln = len(s)
	ans := s

	if ln < 4 {
		fmt.Print(string(ans))
	} else {

		ans = s[:4]

		for i := 4; i < ln; i++ {
			if (s[i] != s[i-1]) || (s[i-2] != s[i-3]) {
				ans = append(ans, s[i])
			}
		}
	}

	fmt.Print(string(ans))
}


There are many sunflowers in the Garden of the Sun.Garden of the Sun is a rectangular table with $$$n$$$ rows and $$$m$$$ columns, where the cells of the table are farmlands. All of the cells grow a sunflower on it. Unfortunately, one night, the lightning stroke some (possibly zero) cells, and sunflowers on those cells were burned into ashes. In other words, those cells struck by the lightning became empty. Magically, any two empty cells have no common points (neither edges nor corners).Now the owner wants to remove some (possibly zero) sunflowers to reach the following two goals:    When you are on an empty cell, you can walk to any other empty cell. In other words, those empty cells are connected.   There is exactly one simple path between any two empty cells. In other words, there is no cycle among the empty cells. You can walk from an empty cell to another if they share a common edge.Could you please give the owner a solution that meets all her requirements?Note that you are not allowed to plant sunflowers. You don't need to minimize the number of sunflowers you remove. It can be shown that the answer always exists.

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. The description of the test cases follows. The first line contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n,m \le 500$$$) — the number of rows and columns.  Each of the next $$$n$$$ lines contains $$$m$$$ characters. Each character is either 'X' or '.', representing an empty cell and a cell that grows a sunflower, respectively. It is guaranteed that the sum of $$$n \cdot m$$$ for all test cases does not exceed $$$250\,000$$$.

For each test case, print $$$n$$$ lines. Each should contain $$$m$$$ characters, representing one row of the table. Each character should be either 'X' or '.', representing an empty cell and a cell with a sunflower, respectively. If there are multiple answers, you can print any. It can be shown that the answer always exists.

XXX
..X
XXX
XXXX
.X.X
.X..
.XXX
.X...
.XXXX
.X...
.X...
XXXXX
XXXXXXXXXX
..
..

NoteLet's use $$$(x,y)$$$ to describe the cell on $$$x$$$-th row and $$$y$$$-th column.In the following pictures white, yellow, and blue cells stand for the cells that grow a sunflower, the cells lightning stroke, and the cells sunflower on which are removed, respectively.In the first test case, one possible solution is to remove sunflowers on $$$(1,2)$$$, $$$(2,3)$$$ and $$$(3 ,2)$$$. Another acceptable solution is to remove sunflowers on $$$(1,2)$$$, $$$(2,2)$$$ and $$$(3,2)$$$. This output is considered wrong because there are 2 simple paths between any pair of cells (there is a cycle). For example, there are 2 simple paths between $$$(1,1)$$$ and $$$(3,3)$$$.  $$$(1,1)\to (1,2)\to (1,3)\to (2,3)\to (3,3)$$$  $$$(1,1)\to (2,1)\to (3,1)\to (3,2)\to (3,3)$$$ This output is considered wrong because you can't walk from $$$(1,1)$$$ to $$$(3,3)$$$.

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	var T, n, m int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &m)
		a := make([][]byte, n)
		for i := range a {
			Fscan(in, &a[i])
			if i%3 == (3-n%3)/3 {
				a[i] = bytes.Repeat([]byte{'X'}, m)
				j := 0
				if m > 1 && (i > 0 && a[i-1][1] == 'X' || i > 1 && a[i-2][1] == 'X') {
					j = 1
				}
				if i > 0 {
					a[i-1][j] = 'X'
				}
				if i > 1 {
					a[i-2][j] = 'X'
				}
			}
		}
		for _, r := range a {
			Fprintf(out, "%s\n", r)
		}
	}
	out.Flush()
}

package main

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

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

	var T, n, m int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &m)
		a := make([][]byte, n)
		for i := range a {
			Fscan(in, &a[i])
			if i%3 == (3-n%3)/3 {
				a[i] = bytes.Repeat([]byte{'X'}, m)
				j := 0
				if m > 1 && (i > 0 && a[i-1][1] == 'X' || i > 1 && a[i-2][1] == 'X') {
					j = 1
				}
				if i > 0 {
					a[i-1][j] = 'X'
				}
				if i > 1 {
					a[i-2][j] = 'X'
				}
			}
		}
		for _, r := range a {
			Fprintln(out, string(r))
		}
	}
}

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

package main

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

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

	var T, n, m int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &m)
		r := (3 - n%3) / 3
		a := make([][]byte, n)
		for i := range a {
			Fscan(in, &a[i])
			if i%3 == r {
				a[i] = bytes.Repeat([]byte{'X'}, m)
				p := 1
				if m == 1 || i > 0 && a[i-1][0] == 'X' || i > 1 && a[i-2][0] == 'X' {
					p = 0
				}
				if i > 0 {
					a[i-1][p] = 'X'
				}
				if i > 1 {
					a[i-2][p] = 'X'
				}
			}
		}
		for _, r := range a {
			Fprintln(out, string(r))
		}
	}
}

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


You have $$$r$$$ red and $$$b$$$ blue beans. You'd like to distribute them among several (maybe, one) packets in such a way that each packet:   has at least one red bean (or the number of red beans $$$r_i \ge 1$$$);  has at least one blue bean (or the number of blue beans $$$b_i \ge 1$$$);  the number of red and blue beans should differ in no more than $$$d$$$ (or $$$|r_i - b_i| \le d$$$) Can you distribute all beans?

The first line contains the single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first and only line of each test case contains three integers $$$r$$$, $$$b$$$, and $$$d$$$ ($$$1 \le r, b \le 10^9$$$; $$$0 \le d \le 10^9$$$) — the number of red and blue beans and the maximum absolute difference in each packet.

For each test case, if you can distribute all beans, print YES. Otherwise, print NO. You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES are all recognized as positive answer).

NoteIn the first test case, you can form one packet with $$$1$$$ red and $$$1$$$ blue bean. The absolute difference $$$|1 - 1| = 0 \le d$$$.In the second test case, you can form two packets: $$$1$$$ red and $$$4$$$ blue beans in the first packet and $$$1$$$ red and $$$3$$$ blue beans in the second one.In the third test case, since $$$b = 1$$$, you can form only one packet with $$$6$$$ red and $$$1$$$ blue beans. The absolute difference $$$|6 - 1| = 5 > d$$$.In the fourth test case, since $$$d = 0$$$ so each packet should contain the same number of red and blue beans, but $$$r \neq 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 main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)
	for ; t > 0; t-- {
		var r, b, d int64
		scanf("%d %d %d\n", &r, &b, &d)

		// var res string
		if d > 0 {
			if r*(d+1) >= b && r <= b || b*(d+1) >= r && b <= r {
				printf("YES\n")
			} else {
				printf("NO\n")
			}
		} else if r != b {
			printf("NO\n")
		} else {
			printf("YES\n")
		}
	}
}

package main

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

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

func (in *CF1519A) 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 *CF1519A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1519A
Date: 19/10/21
User: pepradere
URL: https://codeforces.com/problemset/problem/1519/A
Problem: CF1519A
**/
func (in *CF1519A) Run() {
	t := in.NextInt()

	for ; t > 0; t-- {
		r, b, d := in.NextInt(), in.NextInt(), in.NextInt()
		min := Min(r, b)
		max := Max(r, b)
		pack := int(math.Ceil(float64(max) /float64( min)))
		if max - min <= d || int(math.Abs(float64(pack-1))) <= d  {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

	}

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

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

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

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

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,c int
		fmt.Fscan(in,&a,&b,&c)
		if max(a,b) > (c+1)*min(a,b) {
			fmt.Fprintln(out,"NO")
		} else {
			fmt.Fprintln(out,"YES")
		}
	}
}

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"
	"math"
)

func main() {
	var (
		t               int16
		r, b, d, mn, mx int64
	)
	fmt.Scanln(&t)
	for t > 0 {
		fmt.Scanf("%d %d %d\n", &r, &b, &d)
		d += 1
		mn = int64(math.Min(float64(r), float64(b)))
		mx = int64(math.Max(float64(r), float64(b)))
		if mn*d >= mx {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
		t--
	}
}

package main

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

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

func solve(r, b, d int64) string {
	if r < b {
		return solve(b, r, d)
	}
	if d == 0 {
		if r == b {
			return "YES"
		}
		return "NO"
	}
	if r > (d+1)*b {
		return "NO"
	}
	return "YES"
}

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

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var r, b, d int64
		fmt.Scan(&r, &b, &d)

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

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

		if (d + 1) * min(r, b) >= max(r, b) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func run(or io.Reader, ow io.Writer) {
	in := bufio.NewReader(or)
	out := bufio.NewWriter(ow)
	defer out.Flush()

	solve := func() {
		var r, b, d int64
		fmt.Fscan(in, &r, &b, &d)
		if r > b {
			r, b = b, r
		}
		if r*d >= b-r {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}

	T := 1
	fmt.Fscan(in, &T)
	for o := 0; o < T; o++ {
		solve()
	}

}

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

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

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

	solve := func(Case int) {
		var v, w, d int64
		Fscan(in, &v, &w, &d)
		if v > w {
			v, w = w, v
		}
		dd := w-v
		if d*v<dd {
			Fprintln(out, "NO")
		} else {
			Fprintln(out, "YES")
		}
	}

	var T int
	Fscan(in, &T)
	for Case := 1; Case <= T; Case++ {
		solve(Case)
	}

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

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

package main

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

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

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

	var T int64
	for fmt.Fscan(_r, &T); T > 0; T-- {
		var r, b, d int64
		fmt.Fscan(_r, &r, &b, &d)
		m := min(r, b)
		switch m {
		case r:
			if r*(d+1) < b {
				fmt.Fprintln(_w, "NO")
			} else {
				fmt.Fprintln(_w, "YES")
			}
		case b:
			if b*(d+1) < r {
				fmt.Fprintln(_w, "NO")
			} else {
				fmt.Fprintln(_w, "YES")
			}
		}
	}

}

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

package main

import (
	"fmt"
)

func solve() {
	var r, b, d int64
	fmt.Scan(&r, &b, &d)
	var min, max int64
	if r > b {
		max, min = r, b
	} else {
		max, min = b, r
	}
	if min*(d+1) >= max {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

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

var fields []string

func init() {
	f, err := os.Open("in.txt")

	if err == nil {
		defer f.Close()
	} else {
		f = os.Stdin
	}

	bytes, err := ioutil.ReadAll(bufio.NewReader(f))

	if err != nil {
		panic(err)
	}

	fields = strings.Fields(string(bytes))
}

func ScanString() string {
	for {
		field := fields[0]
		fields = fields[1:]

		if field != "" {
			return field
		}
	}
}

func ScanInt() int {
	n, err := strconv.Atoi(ScanString())

	if err != nil {
		panic(err)
	}

	return n
}

func ScanInt64() int64 {
	n, err := strconv.ParseInt(ScanString(), 10, 64)

	if err != nil {
		panic(err)
	}

	return n
}

func main() {
	outputs := map[bool]string{false: "NO", true: "YES"}

	for t := ScanInt(); t > 0; t-- {
		r, b, d := ScanInt(), ScanInt(), ScanInt()
		res := r == b

		if d > 0 {
			diff := r - b

			if diff < 0 {
				diff = -diff
			}

			minPackets := diff / d

			if diff%d > 0 {
				minPackets++
			}

			res = r >= minPackets && b >= minPackets
		}

		fmt.Println(outputs[res])
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	var n, m, d float64
	fmt.Scanf("%d", &t)
	for i := 0; i < t; i++ {
		fmt.Scan(&n)
		fmt.Scan(&m)
		fmt.Scan(&d)
		if n <= m {
			n, m = m, n
		}
		if float64(n/m) <= d+1 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

var (
    in = bufio.NewReader(os.Stdin)
)

func main() {
    var T int
    for Fscan(in, &T); T > 0; T-- {
        var r, b, d int
        Fscan(in, &r, &b, &d)

        if r > b {
            r, b = b, r
        }

        maxNum := b/r
        if b%r != 0 {
            maxNum++
        }

        if maxNum - 1 <= d {
            Println("YES")
        } else {
            Println("NO")
        }
    }
}

package main

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

// 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 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 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 {
	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
		}
	}

}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)
	for o := 0; o < t; o++ {
		var r, b, d int64
		fmt.Fscan(input, &r)
		fmt.Fscan(input, &b)

		fmt.Fscan(input, &d)
		if d == 0 {
			if r == b {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		} else {
			if r == b {
				fmt.Println("YES")
			}
			if r > b {
				diiff := r - b
				need := int64((diiff + d - 1) / d)
				if b >= need {
					fmt.Println("YES")
				} else {
					fmt.Println("NO")
				}
			}
			if r < b {
				diiff := b - r
				need := int64((diiff + d - 1) / d)
				if r >= need {
					fmt.Println("YES")
				} else {
					fmt.Println("NO")
				}
			}
		}

	}
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for cas := 0; cas < t; cas += 1 {
		var r, b, d int
		fmt.Scan(&r)
		fmt.Scan(&b)
		fmt.Scan(&d)
		if r > b {
			r, b = b, r
		}
		if (b+r-1)/r-1 <= d {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var r, b, d int
		_, _ = fmt.Fscan(in, &r, &b, &d)

		var h, l int
		if r >= b {
			h = r
			l = b
		} else {
			h = b
			l = r
		}

		if (h-1)/l <= d {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

package main

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

var (
	in = bufio.NewReader(os.Stdin)
)

func solve() {
	var r, b, d float64
	fmt.Fscan(in, &r, &b, &d)
	var left float64 = 0
	if r > b {
		left = math.Ceil(float64(r / b))
	} else {
		left = math.Ceil(float64(b / r))
	}
	left -= 1
	if left > d {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}

}

func main() {
	var test int
	fmt.Scanln(&test)
	for i := 0; i < test; i++ {
		solve()
	}
}

package main

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

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

	var t, r, b, d int
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
		fmt.Fscan(in, &r, &b, &d)
		if r > b {
			r, b = b, r
		}
		if float64(b-r)/float64(r) > float64(d) {
			fmt.Println("NO")
			continue
		}
		fmt.Println("YES")
	}
}

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 main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)
	for ; t > 0; t-- {
		var r, b, d int
		scanf("%d %d %d\n", &r, &b, &d)

		// var res string
		if d > 0 {
			if r*(d+1) >= b && r <= b || b*(d+1) >= r && b <= r {
				printf("YES\n")
			} else {
				printf("NO\n")
			}
		} else if r != b {
			printf("NO\n")
		} else {
			printf("YES\n")
		}
	}
}

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 main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)
	for ; t > 0; t-- {
		var r, b, d int
		scanf("%d %d %d\n", &r, &b, &d)

		// var res string
		if d > 0 {
			if r*(d+1) >= b && r <= b || b*(d+1) >= r && b <= r {
				printf("YES\n")
			} else {
				printf("NO\n")
			}
		} else {
			if r != b {
				printf("NO\n")
			} else {
				printf("YES\n")
			}
		}
	}
}

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 main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)
	for ; t > 0; t-- {
		var r, b, d int
		scanf("%d %d %d\n", &r, &b, &d)

		// var res string
		if d > 0 {
			if r*(d) >= b && r <= b || b*(d+1) >= r && b <= r {
				printf("YES\n")
			} else {
				printf("NO\n")
			}
		} else {
			if r != b {
				printf("NO\n")
			} else {
				printf("YES\n")
			}
		}
	}
}

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 main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)
	for ; t > 0; t-- {
		var r, b, d int
		scanf("%d %d %d\n", &r, &b, &d)

		// var res string
		if d > 0 {
			if r*(d+1) >= b && r < b || b*(d+1) >= r && b < r {
				printf("YES\n")
			} else {
				printf("NO\n")
			}
		} else {
			if r != b {
				printf("NO\n")
			} else {
				printf("YES\n")
			}
		}
	}
}

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

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 main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)
	for ; t > 0; t-- {
		var r, b, d int
		scanf("%d %d %d\n", &r, &b, &d)

		// var res string
		if d > 0 {
			if r*(d+1) >= b && r < b || b*d >= r && b < r {
				printf("YES\n")
			} else {
				printf("NO\n")
			}
		} else {
			if r != b {
				printf("NO\n")
			} else {
				printf("YES\n")
			}
		}
	}
}

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

package main

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

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

func (in *CF1519A) 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 *CF1519A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1519A
Date: 19/10/21
User: pepradere
URL: https://codeforces.com/problemset/problem/1519/A
Problem: CF1519A
**/
func (in *CF1519A) Run() {
	t := in.NextInt()

	for ; t > 0; t-- {
		r, b, d := in.NextInt(), in.NextInt(), in.NextInt()
		min := Min(r, b)
		max := Max(r, b)
		pack := max / min
		if max - min <= d || int(math.Abs(float64(pack+(max%min)-min))) <= d  {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

	}

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

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

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

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

package main

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

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

func (in *CF1519A) 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 *CF1519A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1519A
Date: 19/10/21
User: pepradere
URL: https://codeforces.com/problemset/problem/1519/A
Problem: CF1519A
**/
func (in *CF1519A) Run() {
	t := in.NextInt()

	for ; t > 0; t-- {
		r, b, d := in.NextInt(), in.NextInt(), in.NextInt()
		min := Min(r, b)
		max := Max(r, b)
		pack := max / min
		if int(math.Abs(float64(pack+(max%min)-min))) <= d  {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}

	}

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

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

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

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

package main

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

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

func (in *CF1519A) 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 *CF1519A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1519A
Date: 19/10/21
User: pepradere
URL: https://codeforces.com/problemset/problem/1519/A
Problem: CF1519A
**/
func (in *CF1519A) Run() {
	t := in.NextInt()

	for ; t > 0; t-- {
		r, b, d := in.NextInt(), in.NextInt(), in.NextInt()
		min := Min(r, b)
		max := Max(r, b)
		pack := max / min
		if int(math.Abs(float64(pack-min))) > d {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}

	}

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

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

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

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

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,c int
		fmt.Fscan(in,&a,&b,&c)
		if abs(a-b) <= c {
			fmt.Fprintln(out,"YES")
		} else {
			if ((max(a,b)/min(a,b))+(max(a,b)%min(a,b)))-1 > c {
				fmt.Fprintln(out,"NO")
			} else {
				fmt.Fprintln(out,"YES")
			}
		}
	}
}

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
	}
}
func abs(x int) int {
	var result int
	if x > 0 {
		result = x
	} else {
		if x < 0 {
			result = x*-1
		}
	}
	return result
}

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,c int
		fmt.Fscan(in,&a,&b,&c)
		if ((max(a,b)/min(a,b))+(max(a,b)%min(a,b)))-1 > c {
			fmt.Fprintln(out,"NO")
		} else {
			fmt.Fprintln(out,"YES")
		}
	}
}

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"
	"math"
)

func main() {
	var (
		t               int16
		r, b, d, mn, mx int32
	)
	fmt.Scanln(&t)
	for t > 0 {
		fmt.Scanf("%d %d %d\n", &r, &b, &d)
		d += 1
		mn = int32(math.Min(float64(r), float64(b)))
		mx = int32(math.Max(float64(r), float64(b)))
		if mn*d >= mx {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
		t--
	}
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var t, r, b, d int
	fmt.Scanln(&t)
	for t > 0 {
		fmt.Scanf("%d %d %d\n", &r, &b, &d)
		d += 1
		if int(math.Min(float64(r), float64(b)))*d >= int(math.Max(float64(r), float64(b))) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
		t--
	}
}

package main

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

var (
	reader     = bufio.NewReader(os.Stdin)
	t, r, b, d int
)

func solve(r, b, d int) string {
	if r < b {
		return solve(b, r, d)
	}
	if d == 0 {
		if r == b {
			return "YES"
		}
		return "NO"
	}
	if r > (d+1)*b {
		return "NO"
	}
	return "YES"
}

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

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var r, b, d int
		fmt.Scan(&r, &b, &d)

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

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

		if (d + 1) * min(r, b) >= max(r, b) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func run(or io.Reader, ow io.Writer) {
	in := bufio.NewReader(or)
	out := bufio.NewWriter(ow)
	defer out.Flush()

	solve := func() {
		var r, b, d int64
		fmt.Fscan(in, &r, &b, &d)
		if r > b {
			r, b = b, r
		}
		if r*d <=b-r {
			fmt.Fprintln(out,"YES")
		}else {
			fmt.Fprintln(out,"NO")
		}
	}

	T := 1
	fmt.Fscan(in, &T)
	for o := 0; o < T; o++ {
		solve()
	}

}

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

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

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

	solve := func(Case int) {
		var v, w, d int
		Fscan(in, &v, &w, &d)
		if v > w {
			v, w = w, v
		}
		dd := w-v
		if d*v<dd {
			Fprintln(out, "NO")
		} else {
			Fprintln(out, "YES")
		}
	}

	var T int
	Fscan(in, &T)
	for Case := 1; Case <= T; Case++ {
		solve(Case)
	}

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

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


There are two types of burgers in your restaurant — hamburgers and chicken burgers! To assemble a hamburger you need two buns and a beef patty. To assemble a chicken burger you need two buns and a chicken cutlet. You have $$$b$$$ buns, $$$p$$$ beef patties and $$$f$$$ chicken cutlets in your restaurant. You can sell one hamburger for $$$h$$$ dollars and one chicken burger for $$$c$$$ dollars. Calculate the maximum profit you can achieve.You have to answer $$$t$$$ independent queries.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) – the number of queries. The first line of each query contains three integers $$$b$$$, $$$p$$$ and $$$f$$$ ($$$1 \le b, ~p, ~f \le 100$$$) — the number of buns, beef patties and chicken cutlets in your restaurant. The second line of each query contains two integers $$$h$$$ and $$$c$$$ ($$$1 \le h, ~c \le 100$$$) — the hamburger and chicken burger prices in your restaurant.

NoteIn first query you have to sell two hamburgers and three chicken burgers. Your income is $$$2 \cdot 5 + 3 \cdot 10 = 40$$$.In second query you have to ell one hamburgers and two chicken burgers. Your income is $$$1 \cdot 10 + 2 \cdot 12 = 34$$$.In third query you can not create any type of burgers because because you have only one bun. So your income is zero.

// To execute Go code, please declare a func main() in a package "main"

package main

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

func getNumsFromOneLine(ir *bufio.Reader) []int {
  stream, _ := ir.ReadString('\n')
  // Trims the stream and then splits
  trimmedStream := strings.TrimSpace(stream)
  splitArr := strings.Split(trimmedStream, " ")
  // convert strings to integers and store them in a slice
  nums := make([]int, len(splitArr))
  for index, val := range splitArr {
    nums[index], _ = strconv.Atoi(val)
  }
  return nums
}

func main() {
  ir := bufio.NewReader(os.Stdin)
  t := getNumsFromOneLine(ir)[0]
  for i := 0; i < t; i++ {
    bfc := getNumsFromOneLine(ir)
    b, f, c := bfc[0], bfc[1], bfc[2]
    hc := getNumsFromOneLine(ir)
    h, cc := hc[0], hc[1]
    res := 0
    if h >= cc {
      if f * 2 <= b {
        res += h * f
        b -= f * 2
        if c * 2 <= b {
          res += cc * c
        } else {
          res += b / 2 * cc
        }
      } else {
        res += b / 2 * h
      }
    } else {
      if c * 2 <= b {
        res += cc * c
        b -= c * 2
        if f * 2 <= b {
          res += h * f
        } else {
          res += b / 2 * h
        }
      } else {
        res += b / 2 * cc
      }
    }
    fmt.Println(res)
  }

}

package main

import (
	"bufio"
	"os"
	"runtime"
	"strconv"
)

/* solution */

func solve() {

	t := readInt()

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

}

func solveOne() {

	b, p, f, h, c := readInt(), readInt(), readInt(), readInt(), readInt()
	b = b / 2

	if h < c {
		h, c = c, h
		p, f = f, p
	}

	ans := 0

	if p < b {
		ans += p * h
		b -= p
	} else {
		ans += b * h
		b = 0
	}

	if f < b {
		ans += f * c
	} else {
		ans += b * c
	}

	printInt(ans)

}

/* stubs */

func main() {

	var f *os.File
	if runtime.GOROOT() == "C:\\Soft\\Go" {
		f, _ = os.Open("input.txt")
		defer f.Close()
	} else {
		f = os.Stdin
	}

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

	reader = bufio.NewScanner(f)
	reader.Split(bufio.ScanWords)

	solve()

}

var reader *bufio.Scanner
var writer *bufio.Writer

func readInt() int {
	reader.Scan()
	ret, _ := strconv.Atoi(reader.Text())
	return ret
}

func print(s string) {
	writer.WriteString(s)
	writer.WriteString("\n")
}

func printInt(i int) {
	print(strconv.Itoa(i))
}

package main

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

type data struct {
	price int
	stock int
}

func main() {
	var t, bun, beef, chick, bp, cp int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &bun, &beef, &chick, &bp, &cp)
		bun = bun / 2
		goods := make([]data, 0)
		goods = append(goods, data{bp, beef})
		goods = append(goods, data{cp, chick})
		sort.Slice(goods, func(i, j int) bool {
			return goods[i].price > goods[j].price
		})
		profit := 0
		for i := 0; i < len(goods); i++ {
			if bun > goods[i].stock {
				bun -= goods[i].stock
				profit += goods[i].stock * goods[i].price
			} else {
				profit += goods[i].price * bun
				bun = 0
			}
		}
		fmt.Println(profit)
	}
}

func swap(a, b, c, d int) (int, int, int, int) {
	if a > b {
		return a, b, c, d
	} else {
		return b, a, d, c
	}
}

// A. There Are Two Types Of Burgers
/*
There are two types of burgers in your restaurant — hamburgers and chicken burgers! To assemble a hamburger you need two buns and a beef patty. To assemble a chicken burger you need two buns and a chicken cutlet.

You have 𝑏 buns, 𝑝 beef patties and 𝑓 chicken cutlets in your restaurant. You can sell one hamburger for ℎ dollars and one chicken burger for 𝑐 dollars. Calculate the maximum profit you can achieve.

You have to answer 𝑡 independent queries.

Input
The first line contains one integer 𝑡 (1≤𝑡≤100) – the number of queries.

The first line of each query contains three integers 𝑏, 𝑝 and 𝑓 (1≤𝑏, 𝑝, 𝑓≤100) — the number of buns, beef patties and chicken cutlets in your restaurant.

The second line of each query contains two integers ℎ and 𝑐 (1≤ℎ, 𝑐≤100) — the hamburger and chicken burger prices in your restaurant.

Output
For each query print one integer — the maximum profit you can achieve.

Example
Input
3
15 2 3
5 10
7 5 2
10 12
1 100 100
100 100

Output
40
34
0

Note
In first query you have to sell two hamburgers and three chicken burgers. Your income is 2⋅5+3⋅10=40.

In second query you have to ell one hamburgers and two chicken burgers. Your income is 1⋅10+2⋅12=34.

In third query you can not create any type of burgers because because you have only one bun. So your income is zero.
*/
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	input1, _ := reader.ReadString('\n')
	n, _ := strconv.Atoi(strings.TrimSpace(input1))

	for ; n > 0; n-- {
		input2, _ := reader.ReadString('\n')
		arr1 := strings.Split(strings.TrimSpace(input2), " ")
		b, _ := strconv.Atoi(arr1[0])
		p, _ := strconv.Atoi(arr1[1])
		f, _ := strconv.Atoi(arr1[2])

		input3, _ := reader.ReadString('\n')
		arr2 := strings.Split(strings.TrimSpace(input3), " ")
		h, _ := strconv.Atoi(arr2[0])
		c, _ := strconv.Atoi(arr2[1])

		profit := 0

		s := b / 2
		if s > 0 {
			if h > c {
				c, h = h, c
				f, p = p, f
			}

			if f > s {
				profit += s * c
				s = 0
			} else {
				profit += f * c
				s -= f
			}
			if p > s {
				profit += s * h
				s = 0
			} else {
				profit += p * h
				s -= p
			}
		}
		fmt.Println(profit)
	}
}

package main

import (
	"fmt"
)

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

func maxMoney(b, p, f, h, c int) (cnt int) {
	b /= 2
	if h < c {
		h, c = c, h
		p, f = f, p
	}
	cnt += min(b, p) * h
	b -= min(b, p)
	cnt += min(b, f) * c
	return cnt
}

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

package main

import "fmt"

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

func getMaxProfit(b, p, f, h, c int64) int64 {
	if h < c {
		h, c = c, h
		p, f = f, p
	}
	expenCnt := Min(b/2, p)
	profit := expenCnt * h
	restCnt := Min((b-expenCnt*2)/2, f)
	profit += restCnt * c
	return profit
}

func main() {
	var t int
	var b, p, f, h, c int64
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		fmt.Scanf("%d %d %d\n", &b, &p, &f)
		fmt.Scanf("%d %d\n", &h, &c)
		fmt.Println(getMaxProfit(b, p, f, h, c))
	}
}

//HOWDY! IT'S ME! A HARD BLACKISH DICK MOVE!
package main

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

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := PrintlnInts(X...)

/*******************************************************************/
func main() {
	for t := ReadInt(); t > 0; t-- {
		b, p, f := ReadInt3()
		h, c := ReadInt2()
		if h < c {
			p, f = f, p
			h, c = c, h
		}
		humburger := min(b/2, p)
		ans := h * humburger
		b -= 2 * humburger
		chicken := min(b/2, f)
		ans += c * chicken
		fmt.Println(ans)
	}

}

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

func min(args ...int) int {
	if len(args) == 0 {
		panic("empty!")
	}
	min := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] < min {
			min = args[i]
		}
	}
	return min
}

func max(args ...int) int {
	if len(args) == 0 {
		panic("empty!")
	}
	max := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] > max {
			max = args[i]
		}
	}
	return max
}

func _gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return _gcd(b, a%b)
}

func gcd(args ...int) int {
	if len(args) == 0 {
		panic("empty!")
	}
	gcd := args[0]
	for i := 1; i < len(args); i++ {
		gcd = _gcd(gcd, args[i])
	}
	return gcd
}

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9))
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return readInt()
}
func ReadInt2() (int, int) {
	return readInt(), readInt()
}
func ReadInt3() (int, int, int) {
	return readInt(), readInt(), readInt()
}
func ReadInt4() (int, int, int, int) {
	return readInt(), readInt(), readInt(), readInt()
}

func readInt64() int64 {
	return readIntNbits(64)
}

func readInt() int {
	return int(readIntNbits(32))
}

func readIntNbits(n int) int64 {
	i, err := strconv.ParseInt(ReadString(), 0, n)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

// PrintIntsLine returns integers string delimited by a space.
func PrintlnInts(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

package main

import (
	"fmt"
)

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

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

func main () {
	var t int

	fmt.Scanf("%d\n", &t)

	var b, p, f, h, c, sum, mx int
	for i := 0; i < t; i++ {
		fmt.Scanf("%d %d %d\n", &b, &p, &f)
		fmt.Scanf("%d %d\n", &h, &c)

		b /= 2
		mx = max (h, c)

		if mx == c {
			if b > f {
				sum = c * f
				sum += min((b - f), p) * h
			} else {
				sum = c * b
			}
		} else {
			if b > p {
				sum = h * p
				sum += min((b - p), f) * c
			} else {
				sum = h * b
			}
		}

		fmt.Println(sum)
	}
}

package main

import "fmt"

func main() {
	var T int
	fmt.Scanln(&T)

	for t := 1; t <= T; t++ {
		var bread, beef, chicken int
		var hamPrice, chickenPrice int

		fmt.Scanln(&bread, &beef, &chicken)
		fmt.Scanln(&hamPrice, &chickenPrice)

		var sum int
		if hamPrice > chickenPrice {
			if bread < 2*beef {
				sum += hamPrice * (bread / 2)
			} else {
				sum += hamPrice * beef
				bread -= beef * 2

				if bread < 2*chicken {
					sum += chickenPrice * (bread / 2)
				} else {
					sum += chickenPrice * chicken
				}
			}
		} else {
			if bread < 2*chicken {
				sum += chickenPrice * (bread / 2)
			} else {
				sum += chickenPrice * chicken
				bread -= chicken * 2

				if bread < 2*beef {
					sum += hamPrice * (bread / 2)
				} else {
					sum += hamPrice * beef
				}
			}
		}

		fmt.Println(sum)
	}
}

package main

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

func main() {
	b, p, f, h, c := 0, 0, 0, 0, 0
	scan := bufio.NewScanner(os.Stdin)
	scan.Scan()
	for scan.Scan() {
		fmt.Sscanf(scan.Text(), "%d %d %d", &b, &p, &f)
		scan.Scan()
		fmt.Sscanf(scan.Text(), "%d %d", &h, &c)
		ca, cb := 0, 0
		pa, pb, ma, mb := 0, 0, 0, 0
		if h > c {
			pa, pb, ma, mb = h, c, p, f
		} else {
			pa, pb, ma, mb = c, h, f, p
		}
		if b > ma*2 {
			ca = ma
			b -= ma * 2
			cb = min(b/2, mb)
		} else {
			ca = b / 2
			cb = 0
		}
		fmt.Println(ca*pa + cb*pb)
	}
}

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

package main

import "fmt"

func main() {
	var t int
	fmt.Scanln(&t)
	for i:= 0; i< t;i++  {
		var p, b, f, h, c int
		fmt.Scanln(&p, &b, &f)
		fmt.Scanln(&h, &c)
		var ans int
		var proM, proP, secM, secP int
		if h > c{
			proM = b
			secM = f
			proP = h
			secP = c
		} else{
			proM = f
			secM = b
			proP = c
			secP = h
		}
			if p > 2 *proM{
				p -= 2*proM
				ans += proM * proP
				if p > 2 * secM{
					ans += secM *secP
				} else{
					ans += secP* (p/2)
				}
			} else{
				ans += proP * (p/2)
			}
		fmt.Println(ans)
		}
}

package main

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

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

func main() {

	//ancestor
	//stdin, err := os.Open("file.in")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdin.Close()
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)

	//stdout, err := os.Create("file.out")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdout.Close()
	stdout := os.Stdout
	writer := bufio.NewWriterSize(stdout, 1024*1024)

	var t int
	fmt.Fscanf(reader, "%d\n", &t)

	for i := 0; i < t; i++ {
		var b, p, f, h, c, r int
		fmt.Fscanf(reader, "%d %d %d\n%d %d\n", &b, &p, &f, &h, &c)
		b /= 2
		if h > c {
			r += min(b, p) * h
			b -= min(b, p)
			r += min(b, f) * c
		} else {
			r += min(b, f) * c
			b -= min(b, f)
			r += min(b, p) * h
		}
		fmt.Fprintf(writer, "%d\n", r)
	}

	writer.Flush()
}

// Author: sighduck
// URL: https://codeforces.com/contest/1207/problem/A

package main

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

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

func Solve(b, p, f, h, c int) int {
	if c >= h {
		chickenBurgersSold := min(b/2, f)
		b -= chickenBurgersSold * 2
		beefBurgersSold := min(b/2, p)
		return chickenBurgersSold*c + beefBurgersSold*h
	}
	beefBurgersSold := min(b/2, p)
	b -= beefBurgersSold * 2
	chickenBurgersSold := min(b/2, f)
	return chickenBurgersSold*c + beefBurgersSold*h
}

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

	var t int
	fmt.Fscanf(reader, "%d\n", &t)
	for i := 0; i < t; i++ {
		var b, p, f int
		fmt.Fscanf(reader, "%d %d %d\n", &b, &p, &f)
		var h, c int
		fmt.Fscanf(reader, "%d %d\n", &h, &c)
		fmt.Fprintf(writer, "%d\n", Solve(b, p, f, h, c))
	}
}

package main

import "fmt"

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

func main() {
	var t int
	fmt.Scan(&t)
	for t > 0 {
		var b, p, f, h, c int
		fmt.Scan(&b, &p, &f, &h, &c)
		res := 0
		if h > c {
			amount := Min(b / 2, p)
			res += h * amount
			b -= 2 * amount
			p -= amount
			res += c * Min(b / 2, f)
		} else {
			amount := Min(b / 2, f)
			res += c * amount
			b -= 2 * amount
			f -= amount
			res += h * Min(b / 2, p)
		}
		fmt.Println(res)
		t--
	}
}

package main

import "fmt"

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

func solve() {
	var b, p, f int
	fmt.Scanf("%d %d %d\n", &b, &p, &f)
	var h, c int
	fmt.Scanf("%d %d\n", &h, &c)
	ans := 0
	for i := 0; i <= p; i++ {
		for j := 0; j <= f; j++ {
			if 2 * i + 2 * j > b {
				continue
			}
			cost := i * h + j * c
			if cost > ans {
				ans = cost
			}
		}
	}
	fmt.Println(ans)
}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		solve()
	}
}

package main

import "fmt"

func solve() {
	var b, p, f int
	fmt.Scanf("%d %d %d\n", &b, &p, &f)
	var h, c int
	fmt.Scanf("%d %d\n", &h, &c)
	ans := 0
	for i := 0; i <= p; i++ {
		for j := 0; j <= f; j++ {
			if 2 * i + 2 * j > b {
				continue
			}
			cost := i * h + j * c
			if cost > ans {
				ans = cost
			}
		}
	}
	fmt.Println(ans)
}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		solve()
	}
}

package main

import "fmt"

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

func getMaxProfit(b, p, f, h, c int64) int64 {
	if h < c {
		h, c = c, h
		p, f = f, p
	}
	expenCnt := Min(b/2, p)
	profit := expenCnt * h
	restCnt := Min((b-expenCnt*2)/2, f)
	profit += restCnt * c
	return profit
}

func main() {
	var t int
	var b, p, f, h, c int64
	fmt.Scanf("%d", &t)
	for i := 0; i < t; i++ {
		fmt.Scanf("%d %d %d", &b, &p, &f)
		fmt.Scanf("%d %d", &h, &c)
		fmt.Println(getMaxProfit(b, p, f, h, c))
	}
}

// Author: sighduck
// URL: https://codeforces.com/contest/1207/problem/A

package main

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

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

func Solve(b, p, f, h, c int) int {
	if c >= h {
		chickenBurgersSold := min(b/2, f)
		b -= chickenBurgersSold * 2
		beefBurgersSold := min(b/2, p)
		return chickenBurgersSold*c + beefBurgersSold*h
	}
	beefBurgersSold := min(b/2, p)
	b -= beefBurgersSold * 2
	chickenBurgersSold := min(b/2, f)
	return chickenBurgersSold*c + beefBurgersSold*h
}

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

	var t int
	for i := 0; i < t; i++ {
		var b, p, f int
		fmt.Fscanf(reader, "%d %d %d\n", &b, &p, &f)
		var h, c int
		fmt.Fscanf(reader, "%d %d\n", &h, &c)
		fmt.Fprintf(writer, "%d\n", Solve(b, p, f, h, c))
	}
}


"The Chamber of Secrets has been opened again" — this news has spread all around Hogwarts and some of the students have been petrified due to seeing the basilisk. Dumbledore got fired and now Harry is trying to enter the Chamber of Secrets. These aren't good news for Lord Voldemort. The problem is, he doesn't want anybody to be able to enter the chamber. The Dark Lord is going to be busy sucking life out of Ginny.The Chamber of Secrets is an n × m rectangular grid in which some of the cells are columns. A light ray (and a basilisk's gaze) passes through the columns without changing its direction. But with some spell we can make a column magic to reflect the light ray (or the gaze) in all four directions when it receives the ray. This is shown in the figure below.   The left light ray passes through a regular column, and the right ray — through the magic column.  The basilisk is located at the right side of the lower right cell of the grid and is looking to the left (in the direction of the lower left cell). According to the legend, anyone who meets a basilisk's gaze directly dies immediately. But if someone meets a basilisk's gaze through a column, this person will get petrified. We know that the door to the Chamber is located on the left side of the upper left corner of the grid and anyone who wants to enter will look in the direction of its movement (in the direction of the upper right cell) from that position.   This figure illustrates the first sample test.  Given the dimensions of the chamber and the location of regular columns, Lord Voldemort has asked you to find the minimum number of columns that we need to make magic so that anyone who wants to enter the chamber would be petrified or just declare that it's impossible to secure the chamber.

The first line of the input contains two integer numbers n and m (2 ≤ n, m ≤ 1000). Each of the next n lines contains m characters. Each character is either "." or "#" and represents one cell of the Chamber grid. It's "." if the corresponding cell is empty and "#" if it's a regular column.

Print the minimum number of columns to make magic or -1 if it's impossible to do.

NoteThe figure above shows the first sample test. In the first sample we should make both columns magic. The dragon figure represents the basilisk and the binoculars represent the person who will enter the Chamber of secrets. The black star shows the place where the person will be petrified. Yellow lines represent basilisk gaze moving through columns.

package main

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

type dPair struct{ x, y, dir int }
type deque struct{ l, r []dPair }

func (q *deque) empty() bool   { return len(q.l) == 0 && len(q.r) == 0 }
func (q *deque) pushL(v dPair) { q.l = append(q.l, v) }
func (q *deque) pushR(v dPair) { q.r = append(q.r, v) }
func (q *deque) popL() (v dPair) {
	if len(q.l) > 0 {
		q.l, v = q.l[:len(q.l)-1], q.l[len(q.l)-1]
	} else {
		v, q.r = q.r[0], q.r[1:]
	}
	return
}

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

	dir4 := [...][2]int{{1, 0}, {0, 1}, {-1, 0}, {0, -1}}
	var n, m int
	Fscan(in, &n, &m)
	mat := make([][]byte, n)
	for i := range mat {
		Fscan(in, &mat[i])
	}
	const mx, inf = 1000, 1e9
	dist := [mx][mx][4]int{}
	for i, di := range dist {
		for j, dij := range di {
			for k := range dij {
				dist[i][j][k] = inf
			}
		}
	}
	dist[n-1][m-1][3] = 0
	q := &deque{}
	q.pushL(dPair{n - 1, m - 1, 3})
	for !q.empty() {
		p := q.popL()
		x, y, dir := p.x, p.y, p.dir
		d := dist[x][y][dir]
		if xx, yy := x+dir4[dir][0], y+dir4[dir][1]; xx >= 0 && xx < n && yy >= 0 && yy < m && d < dist[xx][yy][dir] {
			dist[xx][yy][dir] = d
			q.pushL(dPair{xx, yy, dir})
		}
		if mat[x][y] == '#' {
			for i := 0; i < 4; i++ {
				if i != dir && d+1 < dist[x][y][i] {
					dist[x][y][i] = d + 1
					q.pushR(dPair{x, y, i})
				}
			}
		}
	}
	if dist[0][0][3] == inf {
		dist[0][0][3] = -1
	}
	Fprint(out, dist[0][0][3])
}

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

package main

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

type dPair struct{ x, y, dir int }
type deque struct{ l, r []dPair }

func (q *deque) empty() bool   { return len(q.l) == 0 && len(q.r) == 0 }
func (q *deque) pushL(v dPair) { q.l = append(q.l, v) }
func (q *deque) pushR(v dPair) { q.r = append(q.r, v) }
func (q *deque) popL() (v dPair) {
	if len(q.l) > 0 {
		q.l, v = q.l[:len(q.l)-1], q.l[len(q.l)-1]
	} else {
		v, q.r = q.r[0], q.r[1:]
	}
	return
}

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

	dir4 := [...][2]int{{1, 0}, {0, 1}, {-1, 0}, {0, -1}}
	var n, m int
	Fscan(in, &n, &m)
	mat := make([][]byte, n)
	for i := range mat {
		Fscan(in, &mat[i])
	}
	const mx, inf = 1000, 1e9
	dist := [mx][mx][4]int{}
	for i, di := range dist {
		for j, dij := range di {
			for k := range dij {
				dist[i][j][k] = inf
			}
		}
	}
	dist[n-1][m-1][3] = 0
	vis := [mx][mx][4]bool{}
	q := &deque{}
	q.pushL(dPair{n - 1, m - 1, 3})
	for !q.empty() {
		p := q.popL()
		x, y, dir := p.x, p.y, p.dir
		if vis[x][y][dir] {
			continue
		}
		vis[x][y][dir] = true
		d := dist[x][y][dir]
		if xx, yy := x+dir4[dir][0], y+dir4[dir][1]; xx >= 0 && xx < n && yy >= 0 && yy < m && d < dist[xx][yy][dir] {
			dist[xx][yy][dir] = d
			q.pushL(dPair{xx, yy, dir})
		}
		if mat[x][y] == '#' {
			for i := 0; i < 4; i++ {
				if i != dir && d+1 < dist[x][y][i] {
					dist[x][y][i] = d + 1
					q.pushR(dPair{x, y, i})
				}
			}
		}
	}
	if dist[0][0][3] == inf {
		dist[0][0][3] = -1
	}
	Fprint(out, dist[0][0][3])
}

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

package main

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

var (
	f [1001][1001][4]bool
	s [1001][1001]byte
	dir = [...][2]int32{ {0,-1}, {-1,0}, {0,1}, {1,0} }
	n, m int32
	g = int32(1)
)

var reader SReader

func main() {
    reader.Init()
	n = reader.ReadInt()
	m = reader.ReadInt()
	for i := int32(1); i <= n; i++ {
		str := reader.ReadStr()
		copy(s[i][1:], str[0:])
	}
	// for i := int32(1); i <= n; i++ {
	// 	fmt.Println("s1: ", s[i][1:m+1])
	// }

	//test()
	fmt.Println(bfs())
}

func test() {
	var q Queue
	q.Push(&node{x:0,y:0})
	q.Push(&node{x:1,y:1})
	for !q.Empty() {
		v := q.Pop()
		fmt.Println(v)
	}
}

func bfs() int32 {
	var q Queue
	q.Push(&node{n, m+1, 0, 0})
	for !q.Empty() {
		v := q.Pop()
		// fmt.Printf("start from (%v, %v, %v, %v)\n", v.x, v.y, v.d, v.k)
		x, y := v.x, v.y // current
		for { // forwar on the dir until outside or '#'
			x, y = x + dir[v.d][0], y + dir[v.d][1] // next
			// fmt.Printf("  evaluate (%v, %v): ", x, y)
			if x == 1 && y == 0 { // found
				// fmt.Println("found")
				return v.k
			}
			if x < 1 || y < 1 || x > n || y > m {
				// fmt.Println("outside")
				break;
			}
			if f[x][y][v.d] {
				// fmt.Println("reached before")
				break
			}

			if s[x][y] == '#' {
				// fmt.Println("column")
				for i := 0; i < len(dir); i++ {
					if int32(i) == v.d { continue } // the same dir
					if f[x][y][i] { continue }
					f[x][y][i] = true
					q.Push(&node{x, y, int32(i), v.k+1})
					// fmt.Printf("    (%v, %v, %v, %v) push in queue\n", x, y, i, v.k+1)
				}
				continue
			}

			// fmt.Println("regular")
		} // for

	}

	return -1
}

// reader
type SReader struct {
    file *os.File
    scanner *bufio.Scanner
}

func (this *SReader) Init() {
    this.file = os.Stdin
    this.scanner = bufio.NewScanner(this.file)
    this.scanner.Split(bufio.ScanWords)
}

func (this *SReader) ReadInt() int32 {
    this.scanner.Scan()
    n, err:= strconv.ParseInt(this.scanner.Text(), 10, 0)
    if err != nil {
        panic(err)
    }
    return int32(n)
}

func (this *SReader) ReadStr() string {
    this.scanner.Scan()
    return this.scanner.Text()
}

type node struct {
	x, y, d, k int32
}

type Queue struct {
	q []*node // elements
}

func (this *Queue) Push(v *node) { // should consider pointer
	this.q = append(this.q, v)
}

func (this *Queue) Pop() *node {
	if len(this.q) == 0 {
		panic("")
	}
	v := this.q[0]
	this.q = this.q[1:]
	return v
}

func (this *Queue) Empty() bool {
	return len(this.q) == 0
}

package main

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

var (
	f [1001][1001][4]bool
	s [1001][1001]byte
	dir = [...][2]int32{ {0,-1}, {-1,0}, {0,1}, {1,0} }
	n, m int32
	g = int32(1)
)

var reader SReader

func main() {
    reader.Init()
	n = reader.ReadInt()
	m = reader.ReadInt()
	for i := int32(1); i <= n; i++ {
		str := reader.ReadStr()
		copy(s[i][1:], str[0:])
	}
	// for i := int32(1); i <= n; i++ {
	// 	fmt.Println("s1: ", s[i][1:m+1])
	// }

	//test()
	fmt.Println(bfs())
}

func test() {
	var q Queue
	q.Push(&node{x:0,y:0})
	q.Push(&node{x:1,y:1})
	for !q.Empty() {
		v := q.Pop()
		fmt.Println(v)
	}
}

func bfs() int32 {
	var q Queue
	q.Push(&node{n, m+1, 0, 0})
	for !q.Empty() {
		v := q.Pop()
		// fmt.Printf("start from (%v, %v, %v, %v)\n", v.x, v.y, v.d, v.k)
		x, y := v.x, v.y // current
		for { // forwar on the dir until outside or '#'
			x, y = x + dir[v.d][0], y + dir[v.d][1] // next
			// fmt.Printf("  evaluate (%v, %v): ", x, y)
			if x == 1 && y == 0 { // found
				// fmt.Println("found")
				return v.k
			}
			if x < 1 || y < 1 || x > n || y > m {
				// fmt.Println("outside")
				break;
			}
			if f[x][y][v.d] {
				// fmt.Println("reached before")
				break
			}

			if s[x][y] == '#' {
				// fmt.Println("column")
				for i := 0; i < len(dir); i++ {
					if int32(i) == v.d { continue } // the same dir
					x2 := x + dir[i][0]
					y2 := y + dir[i][1]
					if x2 < 1 || y2 < 1 || x2 > n || y2 > m {
						continue;
					}
					if f[x2][y2][i] { continue }
					f[x2][y2][i] = true
					q.Push(&node{x2, y2, int32(i), v.k+1})
					// fmt.Printf("    (%v, %v, %v, %v) push in queue\n", x2, y2, i, v.k+1)
				}
				continue
			}

			// fmt.Println("regular")
		} // for

	}

	return -1
}

// reader
type SReader struct {
    file *os.File
    scanner *bufio.Scanner
}

func (this *SReader) Init() {
    this.file = os.Stdin
    this.scanner = bufio.NewScanner(this.file)
    this.scanner.Split(bufio.ScanWords)
}

func (this *SReader) ReadInt() int32 {
    this.scanner.Scan()
    n, err:= strconv.ParseInt(this.scanner.Text(), 10, 0)
    if err != nil {
        panic(err)
    }
    return int32(n)
}

func (this *SReader) ReadStr() string {
    this.scanner.Scan()
    return this.scanner.Text()
}

type node struct {
	x, y, d, k int32
}

type Queue struct {
	q []*node // elements
}

func (this *Queue) Push(v *node) { // should consider pointer
	this.q = append(this.q, v)
}

func (this *Queue) Pop() *node {
	if len(this.q) == 0 {
		panic("")
	}
	v := this.q[0]
	this.q = this.q[1:]
	return v
}

func (this *Queue) Empty() bool {
	return len(this.q) == 0
}