package main

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

func main() {
	sc:=bufio.NewScanner(os.Stdin)
	sc.Scan()
	ns,_:=strconv.Atoi(sc.Text())

	for i:=0; i < ns; i++{
		sc.Scan()
		d, _ :=strconv.Atoi(strings.Split(sc.Text(), " ")[1])
		l, _ :=strconv.Atoi(strings.Split(sc.Text(), " ")[0])
		a := make([]int, l)
		sc.Scan()
		for j,el := range strings.Split(sc.Text()," "){
			a[j],_ = strconv.Atoi(el)
		}
		fmt.Printf("%s\n",fn(a, d))
	}
}

func fn(a []int, d int) string{
	min1 := a[0]
	min2 := a[1]
	max:= a[0]
	if a[0] < a[1]{
		max= a[1]
	}
	for i:=2; i < len(a); i++{
		if a[i] > max{
			max=a[i]
		}
		if a[i] < min1{
			if min1 < min2{
				min2 = min1
			}
			min1 = a[i]
		} else {
			if a[i] < min2 {
				min2 = a[i]
			}
		}
	}
	if max <= d || (min1+min2) <= d{return "YES"}
	return "NO"
}

package main

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

func main() {
	var t, n, d, a int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)

	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n, &d)
		m1 := 1000
		m2 := 1000
		ans := true
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a)
			m1, m2 = getMin(m1, m2, a)
			if a > d {
				ans = false
			}
		}
		if ans || m1+m2 <= d {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

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

package main

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

func sorting(arr []int32, left int32, right int32) []int32 {
	if left > right {
		return []int32{}
	}
	if left == right {
		return []int32{arr[left]}
	}
	mid := (left + right) / 2
	arrLeft := sorting(arr, left, mid)
	arrRight := sorting(arr, mid+1, right)
	sizeLeft := len(arrLeft)
	sizeRight := len(arrRight)
	startLeft := 0
	startRight := 0
	sorted := []int32{}
	for startLeft < sizeLeft && startRight < sizeRight {
		if arrLeft[startLeft] < arrRight[startRight] {
			sorted = append(sorted, arrLeft[startLeft])
			startLeft++
		} else {
			sorted = append(sorted, arrRight[startRight])
			startRight++
		}
	}
	for startLeft < sizeLeft {
		sorted = append(sorted, arrLeft[startLeft])
		startLeft++
	}
	for startRight < sizeRight {
		sorted = append(sorted, arrRight[startRight])
		startRight++
	}
	return sorted
}

func isValid(d int32, arr []int32) bool {
	for _, value := range arr {
		if value > d {
			return false
		}
	}
	return true
}

func solve(n int32, d int32, arr []int32) string {
	sorted := sorting(arr, 0, n-1)
	if isValid(d, arr) || sorted[0]+sorted[1] <= d {
		return "YES"
	} else {
		return "NO"
	}
}

func arrayScanf(in *bufio.Reader, n int32) []int32 {
	m := int32(0)
	arr := []int32{}
	for i := int32(0); i < n; i++ {
		if i > 0 {
			fmt.Fscanf(in, " ")
		}
		fmt.Fscanf(in, "%d", &m)
		arr = append(arr, m)
	}
	fmt.Fscanf(in, "\n")
	return arr
}

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

	tt := int32(0)
	fmt.Fscanf(in, "%d\n", &tt)
	for tt > 0 {
		n := int32(0)
		d := int32(0)

		fmt.Fscanf(in, "%d %d\n", &n, &d)
		arr := arrayScanf(in, n)

		fmt.Fprintf(out, "%s\n", solve(n, d, arr))
		out.Flush()
		tt--
	}
}

package main

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

var bytes []byte

func nextByte() byte {
	b := bytes[0]
	bytes = bytes[1:]
	return b
}

func scanInt64() int64 {
	var negative bool
	var result int64

	b := nextByte()

	for ; b < '0' || b > '9'; b = nextByte() {
		if b == '-' {
			negative = true
		}
	}

	for ; '0' <= b && b <= '9'; b = nextByte() {
		result = (result << 3) + (result << 1) + int64(b-'0')
	}

	if negative {
		return -result
	} else {
		return result
	}
}

func scanInt() int {
	return int(scanInt64())
}

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

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

	bytes, _ = ioutil.ReadAll(bufio.NewReader(f))
}

func main() {
	for t := scanInt(); t > 0; t-- {
		n, d := scanInt(), scanInt()
		a := make([]int, n)

		for i := 0; i < n; i++ {
			a[i] = scanInt()
		}

		sort.Ints(a)

		switch {
		case a[n-1] <= d:
			fmt.Println("YES")
		case n == 1:
			fmt.Println("NO")
		case a[0]+a[1] <= d:
			fmt.Println("YES")
		default:
			fmt.Println("NO")
		}
	}
}

package main

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

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

func main() {
	t := 0
	fmt.Fscan(in, &t)
	for t > 0 {
		t--
		n, d := 0, 0
		fmt.Fscan(in, &n, &d)
		var a []int
		mx := 0
		for i := 0; i < n; i++ {
			x := 0
			fmt.Fscan(in, &x)
			if x > mx {
				mx = x
			}
			a = append(a, x)
		}
		sort.Ints(a)
		if a[0]+a[1] <= d || mx <= d {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
	out.Flush()
}

package main

import (
	"fmt"
	"sort"
	"bufio"
	"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() {
	defer writer.Flush()
	t, n, d := 0, 0, 0
	scanf("%d\n", &t)
	for test := 0; test < t; test++ {
		scanf("%d %d\n", &n, &d)
		arr := make([]int, n)
		for i := 0; i < n; i++ {
			if i + 1 == n {
				scanf("%d\n", &arr[i])
			} else {
				scanf("%d ", &arr[i])
			}
		}
		sort.Ints(arr)
		for i := 2; i < n; i++ {
			if arr[0] + arr[1] < arr[i] {
				arr[i] = arr[0] + arr[1]
			}
		}
		if arr[n - 1] <= d {
			printf("YES\n")
		} else {
			printf("NO\n")
		}
	}
}

package main

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

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 solve() {
	var n, d int
	scanf("%d %d\n", &n, &d)
	v := make([]int, n)
	for i := 0; i < n; i++ {
		if i+1 == n {
			scanf("%d\n", &v[i])
		} else {
			scanf("%d ", &v[i])
		}
	}
	sort.Ints(v)
	ans := "NO\n"
	if v[0] + v[1] <= d || v[len(v) - 1] <= d {
		ans = "YES\n"
	}
	printf(ans)
}

func main() {
	defer writer.Flush()
	var t int
	scanf("%d\n", &t)
	for ; t > 0; t-- {
		solve()
	}
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		min, min1, c := 101, 101, 0
		scanner.Scan()
		tsl := strings.Split(scanner.Text(), " ")
		d, _ := strconv.Atoi(tsl[1])
		scanner.Scan()
		tsl = strings.Split(scanner.Text(), " ")
		for j := 0; j < len(tsl); j++ {
			temp, _ := strconv.Atoi(tsl[j])
			if temp > d {
				c++
			}
			if temp < min {
				min1 = min
				min = temp
			} else if temp < min1 {
				min1 = temp
			}
		}
		if min+min1 > d && c > 0 {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}
}

package main

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

var x = -1

func min(A []int, n int) int {
	var res, y int
	if x != 0 {
		res = A[0]
		y = 0
	} else {
		res = A[n-1]
		y = n - 1
	}
	for i := 0; i < n; i++ {
		if A[i] < res && i != x {
			res = A[i]
			y = i
		}
	}
	x = y
	return res
}

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

	for test := parseInt(getString(reader)); test > 0; test-- {
		nd := getIntln(reader)
		n, d := nd[0], nd[1]
		A := getIntln(reader)
		allLess := true
		x = -1
		for _, v := range A {
			if v > d {
				allLess = false
				break
			}
		}
		if allLess {
			writer.WriteString("YES\n")
		} else {
			a := min(A, n)
			b := min(A, n)
			if a+b <= d {
				writer.WriteString("YES\n")
			} else {
				writer.WriteString("NO\n")
			}
		}
	}
	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"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	cases := getI()
	for ; cases > 0; cases-- {
		n, d := getI(), getI()
		a := getInts(n)
		sortInts(a)

		if a[n-1] <= d {
			out("YES")
			continue
		}

		if a[0]+a[1] <= d {
			out("YES")
		} else {
			out("NO")
		}
	}
}

// !------- HELPERS -------!

func out(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(wr, f, a...)
}

func getI() int64 {
	s := getS()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int64) []int64 {
	ret := make([]int64, N)
	for i := range ret {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	if !sc.Scan() {
		panic(sc.Err())
	}
	return sc.Text()
}

func sortInts(data []int64) {
	sort.Slice(data, func(i, j int) bool { return data[i] < data[j] })
}

func joinInts(s []int64) string {
	return strings.Trim(fmt.Sprintf("%v", s), "[]")
}

func forEach(n int64, fn func(int64)) {
	for i := int64(0); i < n; i++ {
		fn(i)
	}
}

// min, max, asub, abs
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

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

// min for n entry
func nmin(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

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

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

package main

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

var (
	t      int
	input  io.Reader = bufio.NewReader(os.Stdin)
	output           = bufio.NewWriter(os.Stdout)
)

func solve() {
	var n, d int
	fmt.Fscan(input, &n, &d)

	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &arr[i])
	}

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

	if arr[0] > d || arr[1] > d {
		fmt.Fprintln(output, "NO")
		return
	}

	q := arr[0] + arr[1]

	for i := 2; i < n; i++ {
		if arr[i] > d && q > d {
			fmt.Fprintln(output, "NO")
			return
		}
	}

	fmt.Fprintln(output, "YES")
}

func main() {
	fmt.Fscan(input, &t)

	for t > 0 {
		t--
		solve()
	}

	defer output.Flush()
}

package main

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

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	t   int
	n   int
	d   int
)

func main() {

	defer out.Flush()

	fmt.Fscan(in, &t)

	for ; t > 0; t-- {

		fmt.Fscan(in, &n, &d)
		a := make([]int, n)

		flag := true

		for i := range a {

			fmt.Fscan(in, &a[i])

			if a[i] > d {
				flag = false
			}

		}

		if flag {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, solve(n, d, a))
		}

	}

}

func solve(n int, d int, a []int) string {

	sort.Ints(a)

	min := a[0] + a[1]

	if min <= d {
		return "YES"
	}

	return "NO"

}

package main

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

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

func main() {
	defer writer.Flush()

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

	for i := 0; i < t; i++ {
		var n, d int
		fmt.Fscan(reader, &n, &d)

		alreadyLess := true
		a := make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Fscan(reader, &a[j])
			if a[j] > d {
				alreadyLess = false
			}
		}

		if alreadyLess {
			fmt.Fprintln(writer, "YES")
			continue
		}

		sort.Ints(a)
		if a[0]+a[1] <= d {
			fmt.Fprintln(writer, "YES")
		} else {
			fmt.Fprintln(writer, "NO")
		}

	}
}

package main

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

// 2 3 2 5 4
// 2 2 3 4 5
// 1 2 3 5 6
// 1 2 3 5 3
var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func main() {
	n := ReadInt()
	for i := 0; i < n; i++ {
		size := ReadInt()
		d := ReadInt()
		elements := ReadIntSliceln(size)
		fmt.Println(process(elements, d))
	}
}

const (
	YES = "YES"
	NO  = "NO"
)

func process(a []int, d int) string {
	if len(a) == 1 {
		if a[0] <= d {
			return YES
		}
		return NO
	}
	sort.Ints(a)
	minPossible := true
	if a[0]+a[1] > d {
		minPossible = false
	}
	for i := 0; i < len(a); i++ {
		if a[i] > d && !minPossible {
			return NO
		}
	}
	return YES
}

// ReadInt Read a single integer followed by a space
func ReadInt() (v int) {
	fmt.Fscan(reader, &v)
	return v
}

// ReadIntSliceln reads a line of integers into a slice.
func ReadIntSliceln(size int) []int {
	a := make([]int, size)
	for i := range a {
		fmt.Fscan(reader, &a[i])
	}
	//fmt.Scanf("\n")
	return a
}

package main

import (
	"bufio"
	"fmt"
	"os"
    "sort"
)
var (
    input = bufio.NewReader(os.Stdin)
    output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assertion!")}
}

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
// TODO***
// - read the statement carefully
// - get solution before coding
// - check the boundaries (int/int64)
func main() {
    var t int
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
    output.Flush()
}

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

func solve() {
    var (
        n, d int
    )
    fmt.Fscan(input, &n, &d)
    a := make([]int, n)
    mm := 0
    for i := 0; i < n; i++ {
        fmt.Fscan(input, &a[i])
        mm = max(mm, a[i])
    }
    sort.Ints(a)
    if a[0] + a[1] <= d || mm <= d {
        fmt.Fprintln(output, "Yes")
    } else {
        fmt.Fprintln(output, "No")
    }
}

/*
URL:
https://codeforces.com/contest/1473/problem/A
*/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
)

var (
	println = fmt.Println

	tc   int
	n, d int
	A    []int
)

func main() {
	defer stdout.Flush()

	tc = readi()
	for i := 0; i < tc; i++ {
		n, d = readi2()
		A = readis(n)

		solve()
	}
}

func solve() {
	ok := true
	for i := 0; i < n; i++ {
		if A[i] > d {
			ok = false
			break
		}
	}
	if ok {
		printf("YES\n")
		return
	}

	sort.Sort(sort.IntSlice(A))

	s := A[0] + A[1]

	if s <= d {
		printf("YES\n")
	} else {
		printf("NO\n")
	}
}

/*******************************************************************/

/********** common constants **********/

const (
	MOD = 1000000000 + 7
	// MOD          = 998244353
	ALPH_N  = 26
	INF_I64 = math.MaxInt64
	INF_B60 = 1 << 60
	INF_I32 = math.MaxInt32
	INF_B30 = 1 << 30
	NIL     = -1
	EPS     = 1e-10
)

/********** bufio setting **********/

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	reads = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

// mod can calculate a right residual whether value is positive or negative.
func mod(val, m int) int {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// chmin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func chmin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// chmax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func chmax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// sum returns multiple integers sum.
func sum(integers ...int) int {
	var s int
	s = 0

	for _, i := range integers {
		s += i
	}

	return s
}

// abs is integer version of math.Abs
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// pow is integer version of math.Pow
// pow calculate a power by Binary Power (二分累乗法(O(log e))).
func pow(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := pow(a, halfE)
		return half * half
	}

	return a * pow(a, e-1)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

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

//str := reads()
//i := readi()
//X := readis(n)
//S := readrs()
//a := readf()
//A := readfs(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*********** Input ***********/

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

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

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

// readi returns an integer.
func readi() int {
	return int(_readInt64())
}
func readi2() (int, int) {
	return int(_readInt64()), int(_readInt64())
}
func readi3() (int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64())
}
func readi4() (int, int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64()), int(_readInt64())
}

// readll returns as integer as int64.
func readll() int64 {
	return _readInt64()
}
func readll2() (int64, int64) {
	return _readInt64(), _readInt64()
}
func readll3() (int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64()
}
func readll4() (int64, int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64(), _readInt64()
}

func _readInt64() int64 {
	i, err := strconv.ParseInt(reads(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

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

// readlls returns as int64 slice that has n integers.
func readlls(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = readll()
	}
	return b
}

// readf returns an float64.
func readf() float64 {
	return float64(_readFloat64())
}

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

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

// readrs returns a rune slice.
func readrs() []rune {
	return []rune(reads())
}

/*********** Output ***********/

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(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)
}

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

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

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

	return string(res)
}

// Printf is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func printf(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

/*********** Debugging ***********/

// debugf is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func debugf(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

package main

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

var (
	writer  = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
)

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1e6), 1e6)
}

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func sbytes() []byte {
	scanner.Scan()
	return scanner.Bytes()
}

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		d := sint64()
		a := make([]int64, n)
		for i := range a {
			a[i] = sint64()
		}
		printf("%s\n", sol(a, d))
	}
}

func sol(a []int64, d int64) string {
	sort.Slice(a, func(il, ir int) bool {
		return a[il] < a[ir]
	})
	if allLess(a, d) {
		return "YES"
	}
	if a[0]+a[1] <= d {
		return "YES"
	}
	return "NO"
}

func allLess(a []int64, d int64) bool {
	for _, n := range a {
		if n > d {
			return false
		}
	}
	return true
}

package main

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

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

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)

	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var n int
		var d int
		fmt.Fscan(input, &n)
		fmt.Fscan(input, &d)

		ARRAY := make([]int, n)
		for k := 0; k < n; k++ {
			fmt.Fscan(input, &ARRAY[k])
		}

		sort.Ints(ARRAY)

		if ARRAY[0]+ARRAY[1] > d && ARRAY[len(ARRAY)-1] > d {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}

	}
}

package main

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

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

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

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

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

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

/**
 Run solve the problem CF1473A
 Date: 2/04/21
 User: pepradere
 URL: https://codeforces.com/problemset/problem/1473/A
 Problem: CF1473A
**/
func (in *CF1473A) Run() {
	T := in.NextInt()
	for ; T > 0; T-- {
		N := in.NextInt()
		D := in.NextInt()
		var arr [100]int
		var ws bool = false
		i := 0
		for ; N > 0; N-- {
			value := in.NextInt()
			if value > D {
				ws = true
			}
			arr[i] = value
			i++
		}

		if !ws {
			fmt.Println("YES")
		} else {
			sort.Ints(arr[:i])
			if arr[0]+arr[1] <= D {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}
	}

}

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

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

package main

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

type CFRead struct {
	sc *bufio.Reader
	split []string
	index int
}
func (read *CFRead) GetLine() string {
	line, err := read.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:" , line, " err: ", err)
	}
	read.split = []string{}
	return line
}

func (read *CFRead) NextInt() int {
	if len(read.split) <= read.index {
		read.split = strings.Split(read.GetLine()," ")
		read.index = 0
	}
	val, _ := strconv.Atoi(strings.TrimSpace(read.split[read.index]))
	read.index++
	return val
}

func NewCFRead(r *bufio.Reader ) *CFRead {
	return &CFRead{
		sc: r,
		split: []string{},
		index: 0,
	}
}

func main() {

	rd := NewCFRead(bufio.NewReader(os.Stdin))

	T := rd.NextInt()
	for ; T > 0; T-- {
		N := rd.NextInt()
		D := rd.NextInt()
		var arr [100]int
		var ws bool = false
		i := 0
		for ; N > 0; N-- {
			value := rd.NextInt()
			if value > D {
				ws = true
			}
			arr[i] = value
			i++
		}

		if !ws {
			fmt.Println("YES")
		} else {
			sort.Ints(arr[:i])
			if arr[0]+arr[1] <= D {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}

	}
}

package main

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

func main() {

	//fmt.Println(2000)
	//for j := 0; j < 2000; j++ {
	//	fmt.Println("100 99")
	//	for i := 100; i > 0; i-- {
	//		fmt.Print(i , " ")
	//	}

	//6
	//3 1
	//1 1 1
	//3 2
	//1 1 1
	//3 3
	//1 1 1
	//3 4
	//1 1 1
	//3 5
	//1 1 1
	//3 1
	//2 1 1
	//	fmt.Println()
	//}
	//
	//return
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	line := strings.TrimSpace(text)
	T, _ := strconv.Atoi(line)
	for ; T > 0; T-- {
		var N, D = 0, 0
		text, _ = reader.ReadString('\n')
		line = text[:len(text)-1]
		lines := strings.Split(line, " ")
		N, _ = strconv.Atoi(strings.TrimSpace(lines[0]))
		D, _ = strconv.Atoi(strings.TrimSpace(lines[1]))
		var arr [100]int
		var ws bool = false
		text, _ = reader.ReadString('\n')
		line = text[:len(text)-1]
		lines = strings.Split(line, " ")
		i := 0
		for ; N > 0; N-- {
			value, _ := strconv.Atoi(strings.TrimSpace(lines[i]))
			if value > D {
				ws = true
			}
			arr[i] = value
			i++
			//arr = append(arr, value)
		}

		if !ws {
			fmt.Println("YES")
		} else {
			sort.Ints(arr[:i])
			//fmt.Println("Arr " , arr)
			if arr[0]+arr[1] <= D {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}

	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	var t int
	var in = bufio.NewReader(os.Stdin)
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n,d int
		fmt.Fscan(in,&n,&d)
		var lowest,second_lowest int = 999999999,9999999999
		var highest int = 0
		for j:=0;j<n;j++{
			var x int
			fmt.Fscan(in,&x)
			if x >= highest {
				highest = x
			}
			if x <= lowest {
				second_lowest = lowest
				lowest = x
			}
			if x > lowest && x < second_lowest {
				second_lowest = x
			}
		}
		if d >= highest || lowest+second_lowest <= d {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {

	//fmt.Println(2000)
	//for j := 0; j < 2000; j++ {
	//	fmt.Println("100 99")
	//	for i := 100; i > 0; i-- {
	//		fmt.Print(i , " ")
	//	}

	//6
	//3 1
	//1 1 1
	//3 2
	//1 1 1
	//3 3
	//1 1 1
	//3 4
	//1 1 1
	//3 5
	//1 1 1
	//3 1
	//2 1 1
	//	fmt.Println()
	//}
	//
	//return
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	line := strings.TrimSpace(text)
	T, _ := strconv.Atoi(line)
	for ; T > 0; T-- {
		var N, D = 0, 0
		text, _ = reader.ReadString('\n')
		line = text[:len(text)-1]
		lines := strings.Split(line, " ")
		N, _ = strconv.Atoi(strings.TrimSpace(lines[0]))
		D, _ = strconv.Atoi(strings.TrimSpace(lines[1]))
		fmt.Println("Id 3 " , N , " / " , D)
		var arr [100]int
		var ws bool = false
		text, _ = reader.ReadString('\n')
		line = text[:len(text)-1]
		fmt.Println("3 " ,line)
		lines = strings.Split(line, " ")
		i := 0
		for ; N > 0; N-- {
			value, _ := strconv.Atoi(strings.TrimSpace(lines[i]))
			fmt.Println("super id 4 :" , value)
			if value > D {
				ws = true
			}
			arr[i] = value
			i++
			//arr = append(arr, value)
		}

		if !ws {
			fmt.Println("YES")
		} else {
			sort.Ints(arr[:i])
			//fmt.Println("Arr " , arr)
			if arr[0]+arr[1] <= D {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}

	}
}

package main

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

func main() {

	//fmt.Println(2000)
	//for j := 0; j < 2000; j++ {
	//	fmt.Println("100 99")
	//	for i := 100; i > 0; i-- {
	//		fmt.Print(i , " ")
	//	}

	//6
	//3 1
	//1 1 1
	//3 2
	//1 1 1
	//3 3
	//1 1 1
	//3 4
	//1 1 1
	//3 5
	//1 1 1
	//3 1
	//2 1 1
	//	fmt.Println()
	//}
	//
	//return
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	line := strings.TrimSpace(text)
	T, _ := strconv.Atoi(line)
	for ; T > 0; T-- {
		var N, D = 0, 0
		text, _ = reader.ReadString('\n')
		line = text[:len(text)-1]
		lines := strings.Split(line, " ")
		N, _ = strconv.Atoi(strings.TrimSpace(lines[0]))
		D, _ = strconv.Atoi(strings.TrimSpace(lines[1]))
		fmt.Println("Id 3 " , N , " / " , D)
		var arr [100]int
		var ws bool = false
		text, _ = reader.ReadString('\n')
		line = text[:len(text)-1]
		fmt.Println("3 " ,line)
		lines = strings.Split(line, " ")
		i := 0
		for ; N > 0; N-- {
			value, _ := strconv.Atoi(lines[i])
			fmt.Println("super id 4 :" , value)
			if value > D {
				ws = true
			}
			arr[i] = value
			i++
			//arr = append(arr, value)
		}

		if !ws {
			fmt.Println("YES")
		} else {
			sort.Ints(arr[:i])
			//fmt.Println("Arr " , arr)
			if arr[0]+arr[1] <= D {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}

	}
}

package main

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

func main() {

	//fmt.Println(2000)
	//for j := 0; j < 2000; j++ {
	//	fmt.Println("100 99")
	//	for i := 100; i > 0; i-- {
	//		fmt.Print(i , " ")
	//	}

	//6
	//3 1
	//1 1 1
	//3 2
	//1 1 1
	//3 3
	//1 1 1
	//3 4
	//1 1 1
	//3 5
	//1 1 1
	//3 1
	//2 1 1
	//	fmt.Println()
	//}
	//
	//return
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	line := strings.TrimSpace(text)
	T, _ := strconv.Atoi(line)
	fmt.Println("1 " ,T)

	for ; T > 0; T-- {
		var N, D = 0, 0
		text, _ = reader.ReadString('\n')
		line = text[:len(text)-1]
		lines := strings.Split(line, " ")
		fmt.Println("2 " ,line)
		N, _ = strconv.Atoi(strings.TrimSpace(lines[0]))
		D, _ = strconv.Atoi(strings.TrimSpace(lines[1]))

		var arr [100]int
		var ws bool = false
		text, _ = reader.ReadString('\n')
		line = text[:len(text)-1]
		fmt.Println("3 " ,line)
		lines = strings.Split(line, " ")
		i := 0
		for ; N > 0; N-- {
			value, _ := strconv.Atoi(lines[i])

			if value > D {
				ws = true
			}
			arr[i] = value
			i++
			//arr = append(arr, value)
		}

		if !ws {
			fmt.Println("YES")
		} else {
			sort.Ints(arr[:i])
			//fmt.Println("Arr " , arr)
			if arr[0]+arr[1] <= D {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}

	}
}

package main

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

func main() {

	//fmt.Println(2000)
	//for j := 0; j < 2000; j++ {
	//	fmt.Println("100 99")
	//	for i := 100; i > 0; i-- {
	//		fmt.Print(i , " ")
	//	}

	//6
	//3 1
	//1 1 1
	//3 2
	//1 1 1
	//3 3
	//1 1 1
	//3 4
	//1 1 1
	//3 5
	//1 1 1
	//3 1
	//2 1 1
	//	fmt.Println()
	//}
	//
	//return
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	fmt.Println("Text ", text)
	line := text[:len(text)-1]

	T, _ := strconv.Atoi(line)
	fmt.Println("1 " ,T)

	for ; T > 0; T-- {
		var N, D = 0, 0
		text, _ = reader.ReadString('\n')
		line = text[:len(text)-1]
		lines := strings.Split(line, " ")
		fmt.Println("2 " ,line)
		N, _ = strconv.Atoi(lines[0])
		D, _ = strconv.Atoi(lines[1])

		var arr [100]int
		var ws bool = false
		text, _ = reader.ReadString('\n')
		line = text[:len(text)-1]
		fmt.Println("3 " ,line)
		lines = strings.Split(line, " ")
		i := 0
		for ; N > 0; N-- {
			value, _ := strconv.Atoi(lines[i])

			if value > D {
				ws = true
			}
			arr[i] = value
			i++
			//arr = append(arr, value)
		}

		if !ws {
			fmt.Println("YES")
		} else {
			sort.Ints(arr[:i])
			//fmt.Println("Arr " , arr)
			if arr[0]+arr[1] <= D {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}

	}
}

package main

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

func main() {

	//fmt.Println(2000)
	//for j := 0; j < 2000; j++ {
	//	fmt.Println("100 99")
	//	for i := 100; i > 0; i-- {
	//		fmt.Print(i , " ")
	//	}

	//6
	//3 1
	//1 1 1
	//3 2
	//1 1 1
	//3 3
	//1 1 1
	//3 4
	//1 1 1
	//3 5
	//1 1 1
	//3 1
	//2 1 1
	//	fmt.Println()
	//}
	//
	//return
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	line := text[:len(text)-1]

	T, _ := strconv.Atoi(line)
	fmt.Println("1 " ,T)

	for ; T > 0; T-- {
		var N, D = 0, 0
		text, _ = reader.ReadString('\n')
		line = text[:len(text)-1]
		lines := strings.Split(line, " ")
		fmt.Println("2 " ,line)
		N, _ = strconv.Atoi(lines[0])
		D, _ = strconv.Atoi(lines[1])

		var arr [100]int
		var ws bool = false
		text, _ = reader.ReadString('\n')
		line = text[:len(text)-1]
		fmt.Println("3 " ,line)
		lines = strings.Split(line, " ")
		i := 0
		for ; N > 0; N-- {
			value, _ := strconv.Atoi(lines[i])

			if value > D {
				ws = true
			}
			arr[i] = value
			i++
			//arr = append(arr, value)
		}

		if !ws {
			fmt.Println("YES")
		} else {
			sort.Ints(arr[:i])
			//fmt.Println("Arr " , arr)
			if arr[0]+arr[1] <= D {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}

	}
}

package main

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

func main() {

	//fmt.Println(2000)
	//for j := 0; j < 2000; j++ {
	//	fmt.Println("100 99")
	//	for i := 100; i > 0; i-- {
	//		fmt.Print(i , " ")
	//	}

	//6
	//3 1
	//1 1 1
	//3 2
	//1 1 1
	//3 3
	//1 1 1
	//3 4
	//1 1 1
	//3 5
	//1 1 1
	//3 1
	//2 1 1
	//	fmt.Println()
	//}
	//
	//return
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	line := text[:len(text)-1]

	T, _ := strconv.Atoi(line)

	for ; T > 0; T-- {
		var N, D = 0, 0
		text, _ = reader.ReadString('\n')
		line = text[:len(text)-1]
		lines := strings.Split(line, " ")

		N, _ = strconv.Atoi(lines[0])
		D, _ = strconv.Atoi(lines[1])

		var arr [100]int
		var ws bool = false
		text, _ = reader.ReadString('\n')
		line = text[:len(text)-1]
		lines = strings.Split(line, " ")
		i := 0
		for ; N > 0; N-- {
			value,  _ := strconv.Atoi(lines[i])

			if value > D {
				ws = true
			}
			arr[i] = value
			i++
			//arr = append(arr, value)
		}

		if !ws {
			fmt.Println("YES")
		} else {
			sort.Ints(arr[:i])
			//fmt.Println("Arr " , arr)
			if arr[0]+arr[1] <= D {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}

	}
}

package main

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

func main() {

	//fmt.Println(2000)
	//for j := 0; j < 2000; j++ {
	//	fmt.Println("100 99")
	//	for i := 100; i > 0; i-- {
	//		fmt.Print(i , " ")
	//	}

	//6
	//3 1
	//1 1 1
	//3 2
	//1 1 1
	//3 3
	//1 1 1
	//3 4
	//1 1 1
	//3 5
	//1 1 1
	//3 1
	//2 1 1
	//	fmt.Println()
	//}
	//
	//return
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	line := text[:len(text)-1]

	T, _ := strconv.Atoi(line)

	for ; T > 0; T-- {
		var N, D = 0, 0
		text, _ = reader.ReadString('\n')
		line = text[:len(text)-1]
		lines := strings.Split(line, " ")

		N, _ = strconv.Atoi(lines[0])
		D, _ = strconv.Atoi(lines[1])

		var arr [100]int
		var ws bool = false
		text, _ = reader.ReadString('\n')
		line = text[:len(text)-1]
		lines = strings.Split(line, " ")
		i := 0
		for ; N > 0; N-- {
			value, _ := strconv.Atoi(lines[i])

			if value > D {
				ws = true
			}
			arr[i] = value
			i++
			//arr = append(arr, value)
		}

		if !ws {
			fmt.Println("YES",arr[0])
		} else {
			sort.Ints(arr[:i])
			//fmt.Println("Arr " , arr)
			if arr[0]+arr[1] <= D {
				fmt.Println("YES",arr[0])
			} else {
				fmt.Println("NO",arr[0])
			}
		}

	}
}

package main

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

func main() {

	//fmt.Println(2000)
	//for j := 0; j < 2000; j++ {
	//	fmt.Println("100 99")
	//	for i := 100; i > 0; i-- {
	//		fmt.Print(i , " ")
	//	}

	//6
	//3 1
	//1 1 1
	//3 2
	//1 1 1
	//3 3
	//1 1 1
	//3 4
	//1 1 1
	//3 5
	//1 1 1
	//3 1
	//2 1 1
	//	fmt.Println()
	//}
	//
	//return
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	line := text[:len(text)-1]

	T, _ := strconv.Atoi(line)

	for ; T > 0; T-- {
		var N, D = 0, 0
		text, _ = reader.ReadString('\n')
		line = text[:len(text)-1]
		lines := strings.Split(line, " ")

		N, _ = strconv.Atoi(lines[0])
		D, _ = strconv.Atoi(lines[1])

		var arr [100]int
		var ws bool = false
		text, _ = reader.ReadString('\n')
		line = text[:len(text)-1]
		lines = strings.Split(line, " ")
		i := 0
		for ; N > 0; N-- {
			value, _ := strconv.Atoi(lines[i])

			if value > D {
				ws = true
			}
			arr[i] = value
			i++
			//arr = append(arr, value)
		}

		if !ws {
			fmt.Println(arr[0],"YES")
		} else {
			sort.Ints(arr[:i])
			//fmt.Println("Arr " , arr)
			if arr[0]+arr[1] <= D {
				fmt.Println(arr[0],"YES")
			} else {
				fmt.Println(arr[0],"NO")
			}
		}

	}
}

package main

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

func main() {

	//fmt.Println(2000)
	//for j := 0; j < 2000; j++ {
	//	fmt.Println("100 99")
	//	for i := 100; i > 0; i-- {
	//		fmt.Print(i , " ")
	//	}

	//6
	//3 1
	//1 1 1
	//3 2
	//1 1 1
	//3 3
	//1 1 1
	//3 4
	//1 1 1
	//3 5
	//1 1 1
	//3 1
	//2 1 1
	//	fmt.Println()
	//}
	//
	//return
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	line := text[:len(text)-1]

	T, _ := strconv.Atoi(line)

	for ; T > 0; T-- {
		var N, D = 0, 0
		text, _ = reader.ReadString('\n')
		line = text[:len(text)-1]
		lines := strings.Split(line, " ")

		N, _ = strconv.Atoi(lines[0])
		D, _ = strconv.Atoi(lines[1])

		var arr [100]int
		var ws bool = false
		text, _ = reader.ReadString('\n')
		line = text[:len(text)-1]
		lines = strings.Split(line, " ")
		i := 0
		for ; N > 0; N-- {
			value, _ := strconv.Atoi(lines[i])

			if value > D {
				ws = true
			}
			arr[i] = value
			i++
			//arr = append(arr, value)
		}

		if !ws {
			fmt.Println(arr[:i],"YES")
		} else {
			sort.Ints(arr[:i])
			//fmt.Println("Arr " , arr)
			if arr[0]+arr[1] <= D {
				fmt.Println(arr[:i],"YES")
			} else {
				fmt.Println(arr[:i],"NO")
			}
		}

	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {

	//fmt.Println(2000)
	//for j := 0; j < 2000; j++ {
	//	fmt.Println("100 99")
	//	for i := 100; i > 0; i-- {
	//		fmt.Print(i , " ")
	//	}

//6
//3 1
//1 1 1
//3 2
//1 1 1
//3 3
//1 1 1
//3 4
//1 1 1
//3 5
//1 1 1
//3 1
//2 1 1
	//	fmt.Println()
	//}
	//
	//return
	var T = 0
	fmt.Scanf("%d\n",&T)

	for ; T > 0; T-- {
		var N, D = 0, 0
		fmt.Scanf("%d %d\n",&N, &D)
		var arr [100]int
		var ws bool = false
		i := 0
		for ; N > 0; N-- {
			var value = 0
			fmt.Scan(&value)
			if value > D {
				ws = true
			}
			arr[i] = value
			i++
			//arr = append(arr, value)
		}

		if !ws {
			fmt.Println("YES")
		} else {
			sort.Ints(arr[:i])
			//fmt.Println("Arr " , arr)
			if arr[0]+arr[1] <= D {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}

	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {

	//fmt.Println(2000)
	//for j := 0; j < 2000; j++ {
	//	fmt.Println("100 99")
	//	for i := 100; i > 0; i-- {
	//		fmt.Print(i , " ")
	//	}

//6
//3 1
//1 1 1
//3 2
//1 1 1
//3 3
//1 1 1
//3 4
//1 1 1
//3 5
//1 1 1
//3 1
//2 1 1
	//	fmt.Println()
	//}
	//
	//return
	var T = 0
	fmt.Scanf("%d\n",&T)

	for ; T > 0; T-- {
		var N, D = 0, 0
		fmt.Scanf("%d %d\n",&N, &D)
		var arr [100]int
		var ws bool = false
		i := 0
		for ; N > 0; N-- {
			var value = 0
			fmt.Scanf("%d",&value)
			if value > D {
				ws = true
			}
			arr[i] = value
			i++
			//arr = append(arr, value)
		}

		if !ws {
			fmt.Println("YES")
		} else {
			sort.Ints(arr[:i])
			//fmt.Println("Arr " , arr)
			if arr[0]+arr[1] <= D {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}

	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {

	//fmt.Println(2000)
	//for j := 0; j < 2000; j++ {
	//	fmt.Println("100 99")
	//	for i := 100; i > 0; i-- {
	//		fmt.Print(i , " ")
	//	}
	//	fmt.Println()
	//}
	//
	//return
	var T = 0
	fmt.Scanf("%d\n",&T)

	for ; T > 0; T-- {
		var N, D = 0, 0
		fmt.Scanf("%d %d\n",&N, &D)
		var arr [100]int
		var ws bool = false
		i := 0
		for ; N > 0; N-- {
			var value = 0
			fmt.Scanf("%d",&value)
			if value > D {
				ws = true
			}
			arr[i] = value
			i++
			//arr = append(arr, value)
		}

		if !ws {
			fmt.Println("YES")
		} else {
			sort.Ints(arr[:i])
			//fmt.Println("Arr " , arr)
			if arr[0]+arr[1] <= D {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}

	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {

	//fmt.Println(2000)
	//for j := 0; j < 2000; j++ {
	//	fmt.Println("100 99")
	//	for i := 100; i > 0; i-- {
	//		fmt.Print(i , " ")
	//	}
	//	fmt.Println()
	//}
	//
	//return
	var T = 0
	fmt.Scanf("%d", &T)

	for ; T > 0; T-- {
		var N, D = 0, 0
		fmt.Scanf("%d %d", &N, &D)
		var arr [100]int
		var ws bool = false
		i := 0
		for ; N > 0; N-- {
			var value = 0
			fmt.Scanf("%d", &value)
			if value > D {
				ws = true
			}
			arr[i] = value
			i++
			//arr = append(arr, value)
		}

		if !ws {
			fmt.Println("YES")
		} else {
			sort.Ints(arr[:i])
			//fmt.Println("Arr " , arr)
			if arr[0]+arr[1] <= D {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}

	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {

	//fmt.Println(2000)
	//for j := 0; j < 2000; j++ {
	//	fmt.Println("100 99")
	//	for i := 100; i > 0; i-- {
	//		fmt.Print(i , " ")
	//	}
	//	fmt.Println()
	//}
	//
	//return
	var T = 0
	fmt.Scanf("%d", &T)

	for ; T > 0; T-- {
		var N, D = 0, 0
		fmt.Scanf("%d %d", &N, &D)
		var arr [100]int
		var ws bool = false
		i := 0
		for ; N > 0; N-- {
			var value = 0
			fmt.Scanf("%d", &value)
			if value > D {
				ws = true
			}
			arr[i] = value
			i++
			//arr = append(arr, value)
		}

		if !ws {
			fmt.Println("YES")
		} else {
			sort.Ints(arr[:i])
			if arr[0]+arr[1] <= D {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}

	}
}

package main
import(
    "fmt"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var n,d int
		fmt.Scan(&n,&d)
		var lowest,second_lowest int = 999999999,9999999999
		var highest int = 0
		for j:=0;j<n;j++{
			var x int
			fmt.Scan(&x)
			if x >= highest {
				highest = x
			}
			if x <= lowest {
				second_lowest = lowest
				lowest = x
			}
		}
		if d >= highest || lowest+second_lowest <= d {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main
import(
    "fmt"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var n,d int
		fmt.Scan(&n,&d)
		var lowest,second_lowest int = 999999999,9999999999
		var highest int = 0
		for j:=0;j<n;j++{
			var x int
			fmt.Scan(&x)
			if x >= highest {
				highest = x
			}
			if x <= lowest {
				second_lowest = lowest
				lowest = x
			}
		}
		if d >= highest {
			fmt.Println("YES")
		} else if lowest+second_lowest > d {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}
}

package main
import(
    "fmt"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var n,d int
		fmt.Scan(&n,&d)
		var lowest,second_lowest int = 999999999,9999999999
		var highest int = 0
		for j:=0;j<n;j++{
			var x int
			fmt.Scan(&x)
			if x >= highest {
				highest = x
			}
			if x <= lowest {
				second_lowest = lowest
				lowest = x
			}
		}
		if lowest+second_lowest > d {
			if d >= highest {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		} else {
			fmt.Println("YES")
		}
	}
}

package main
import(
    "fmt"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var n,d int
		fmt.Scan(&n,&d)
		var lowest,second_lowest int = 999999999,9999999999
		var highest int = 0
		for j:=0;j<n;j++{
			var x int
			fmt.Scan(&x)
			if x > highest {
				highest = x
			}
			if x < lowest {
				lowest = x
			}
			if x > lowest && x < second_lowest {
				second_lowest = x
			}
		}
		if lowest+second_lowest > d {
			if d >= highest {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		} else {
			fmt.Println("YES")
		}
	}
}

package main

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

func main() {
	sc:=bufio.NewScanner(os.Stdin)
	sc.Scan()
	ns,_:=strconv.Atoi(sc.Text())

	for i:=0; i < ns; i++{
		sc.Scan()
		d, _ :=strconv.Atoi(strings.Split(sc.Text(), " ")[1])
		l, _ :=strconv.Atoi(strings.Split(sc.Text(), " ")[0])
		a := make([]int, l)
		sc.Scan()
		for j,el := range strings.Split(sc.Text()," "){
			a[j],_ = strconv.Atoi(el)
		}
		fmt.Printf("%s\n",fn(a, d))
	}
}

func fn(a []int, d int) string{
	min1 := a[0]
	min2 := a[0]
	max:= a[0]
	for i:=1; i < len(a); i++{
		if a[i] > max{
			max=a[i]
		}
		if a[i] < min1{
			if min1 < min2{
				min2 = min1
			}
			min1 = a[i]
		} else {
			if a[i] < min2 {
				min2 = a[i]
			}
		}
	}
	if max <= d || (min1+min2) <= d{return "YES"}
	return "NO"
}

package main

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

func main() {
	sc:=bufio.NewScanner(os.Stdin)
	sc.Scan()
	ns,_:=strconv.Atoi(sc.Text())

	for i:=0; i < ns; i++{
		sc.Scan()
		d, _ :=strconv.Atoi(strings.Split(sc.Text(), " ")[1])
		l, _ :=strconv.Atoi(strings.Split(sc.Text(), " ")[0])
		a := make([]int, l)
		sc.Scan()
		for j,el := range strings.Split(sc.Text()," "){
			a[j],_ = strconv.Atoi(el)
		}
		fmt.Printf("%s\n",fn(a, d))
	}
}

func fn(a []int, d int) string{
	min1 := a[0]
	min2 := a[0]
	max:= a[0]
	for i:=1; i < len(a); i++{
		if a[i] > max{
			max=a[i]
		}
		if a[i] < min1{
			if min1 < min2{
				min2 = min1
			}
			min1 = a[i]
		} else {
			if a[i] < min2 && a[i] != min1 {
				min2 = a[i]
			}
		}
	}
	if max <= d || (min1+min2) <= d{return "YES"}
	return "NO"
}

package main

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

func main() {
	sc:=bufio.NewScanner(os.Stdin)
	sc.Scan()
	ns,_:=strconv.Atoi(sc.Text())

	for i:=0; i < ns; i++{
		sc.Scan()
		d, _ :=strconv.Atoi(strings.Split(sc.Text(), " ")[1])
		l, _ :=strconv.Atoi(strings.Split(sc.Text(), " ")[0])
		a := make([]int, l)
		sc.Scan()
		for j,el := range strings.Split(sc.Text()," "){
			a[j],_ = strconv.Atoi(el)
		}
		fmt.Printf("%s\n",fn(a, d))
	}
}

func fn(a []int, d int) string{
	min1 := 101
	min2 := 101
	max:= -1
	for i:=0; i < len(a); i++{
		if a[i] > max{
			max=a[i]
		}
		if a[i] < min1{
			if min1 < min2{
				min2 = min1
			}
			min1 = a[i]
		}
		if a[i] < min2 && a[i] != min1{
			min2 = a[i]
		}
	}
	if max <= d || (min1+min2) <= d{return "YES"}
	return "NO"
}

package main

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

func main() {
	sc:=bufio.NewScanner(os.Stdin)
	sc.Scan()
	ns,_:=strconv.Atoi(sc.Text())

	for i:=0; i < ns; i++{
		sc.Scan()
		d, _ :=strconv.Atoi(strings.Split(sc.Text(), " ")[1])
		l, _ :=strconv.Atoi(strings.Split(sc.Text(), " ")[0])
		a := make([]int, l)
		sc.Scan()
		for j,el := range strings.Split(sc.Text()," "){
			a[j],_ = strconv.Atoi(el)
		}
		fmt.Printf("%s\n",fn(a, d))
	}
}

func fn(a []int, d int) string{
	min1 := 101
	min2 := 101
	max:= -1
	for i:=0; i < len(a)-1; i++{
		if a[i] > max{
			max=a[i]
		}
		if a[i] < min1{
			if min1 < min2{
				min2 = min1
			}
			min1 = a[i]
		}
		if a[i] < min2 && a[i] != min1{
			min2 = a[i]
		}
	}
	if max <= d || (min1+min2) < d{return "YES"}
	return "NO"
}

package main

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

func main() {
	sc:=bufio.NewScanner(os.Stdin)
	sc.Scan()
	ns,_:=strconv.Atoi(sc.Text())

	for i:=0; i < ns; i++{
		sc.Scan()
		d, _ :=strconv.Atoi(strings.Split(sc.Text(), " ")[1])
		l, _ :=strconv.Atoi(strings.Split(sc.Text(), " ")[0])
		a := make([]int, l)
		sc.Scan()
		for j,el := range strings.Split(sc.Text()," "){
			a[j],_ = strconv.Atoi(el)
		}
		fmt.Printf("%s\n",fn(a, d))
	}
}

func fn(a []int, d int) string{
	more := false
	for i:=0; i < len(a)-1; i++{
		if !(a[i] <= d){
			more = true
		}
		if (a[i] + a[i+1]) <= d{
			return "YES"
		}
	}
	if more{
		return "NO"
	}
	return "YES"
}

package main

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

func main() {
	var t, n, d, a int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)

	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n, &d)
		m1 := 1000
		m2 := 1000
		ans := true
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a)
			if a <= m1 {
				m2 = m1
				m1 = a
			}
			if a > d {
				ans = false
			}
		}
		if ans || m1+m2 <= d {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	var t, n, d, a int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)

	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n, &d)
		m1 := 1000
		m2 := 1000
		ans := true
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a)
			if a < m1 {
				m2 = m1
				m1 = a
			}
			if a > d {
				ans = false
			}
		}
		if ans || m1+m2 <= d {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	var t, n, d, a int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)

	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n, &d)
		m1 := math.MaxInt32
		m2 := math.MaxInt32
		ans := true
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a)
			if a < m1 {
				m2 = m1
				m1 = a
			}
			if a > d {
				ans = false
			}
		}
		if ans || m1+m2 <= d {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func sorting(arr []int32, left int32, right int32) []int32 {
	if left > right {
		return []int32{}
	}
	if left == right {
		return []int32{arr[left]}
	}
	mid := (left + right) / 2
	arrLeft := sorting(arr, left, mid)
	arrRight := sorting(arr, mid+1, right)
	sizeLeft := len(arrLeft)
	sizeRight := len(arrRight)
	startLeft := 0
	startRight := 0
	sorted := []int32{}
	for startLeft < sizeLeft && startRight < sizeRight {
		if arrLeft[startLeft] < arrRight[startRight] {
			sorted = append(sorted, arrLeft[startLeft])
			startLeft++
		} else {
			sorted = append(sorted, arrRight[startRight])
			startRight++
		}
	}
	for startLeft < sizeLeft {
		sorted = append(sorted, arrLeft[startLeft])
		startLeft++
	}
	for startRight < sizeRight {
		sorted = append(sorted, arrRight[startRight])
		startRight++
	}
	return sorted
}

func isValid(d int32, arr []int32) bool {
	for _, value := range arr {
		if value > d {
			return false
		}
	}
	return true
}

func solve(n int32, d int32, arr []int32) string {
	sorted := sorting(arr, 0, n-1)
	if isValid(d, arr) || sorted[0]+sorted[1] <= d {
		return "YES"
	} else {
		return "NO"
	}
}

func arrayScanf(in *bufio.Reader, n int32) []int32 {
	m := int32(0)
	arr := []int32{}
	for i := int32(0); i < n; i++ {
		if i > 0 {
			fmt.Fscanf(in, " ")
		}
		fmt.Fscanf(in, "%d", &m)
		arr = append(arr, m)
	}
	fmt.Fscanf(in, "\n")
	return arr
}

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

	tt := int32(0)
	fmt.Fscanf(in, "%d\n", &tt)
	for tt > 0 {
		n := int32(0)
		d := int32(0)
		arr := arrayScanf(in, n)
		fmt.Fprintf(out, "%s\n", solve(n, d, arr))
		out.Flush()
		tt--
	}
}

package main

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

var bytes []byte

func nextByte() byte {
	b := bytes[0]
	bytes = bytes[1:]
	return b
}

func scanInt64() int64 {
	var negative bool
	var result int64

	b := nextByte()

	for ; b < '0' || b > '9'; b = nextByte() {
		if b == '-' {
			negative = true
		}
	}

	for ; '0' <= b && b <= '9'; b = nextByte() {
		result = (result << 3) + (result << 1) + int64(b-'0')
	}

	if negative {
		return -result
	} else {
		return result
	}
}

func scanInt() int {
	return int(scanInt64())
}

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

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

	bytes, _ = ioutil.ReadAll(bufio.NewReader(f))
}

func main() {
	for t := scanInt(); t > 0; t-- {
		n, d := scanInt(), scanInt()
		a := make([]int, n)

		for i := 0; i < n; i++ {
			a[i] = scanInt()
		}

		switch {
		case a[n-1] <= d:
			fmt.Println("YES")
		case n == 1:
			fmt.Println("NO")
		case a[0]+a[1] <= d:
			fmt.Println("YES")
		default:
			fmt.Println("NO")
		}
	}
}


package main

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

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

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

	stack := make([]int, n)
	place := make([]int, n+1)
	deleted := make([]bool, n+1)

	for i := 0; i < n; i++ {
		scanner.Scan()
		bookID, _ := strconv.Atoi(scanner.Text())

		stack[i] = bookID
		place[bookID] = i
		deleted[bookID] = false
	}

	bottom := -1
	for i := 0; i < n; i++ {
		scanner.Scan()
		bookID, _ := strconv.Atoi(scanner.Text())

		pos := place[bookID]
		cnt := max(pos-bottom, 0)
		bottom = max(pos, bottom)

		fmt.Println(cnt)
	}
}

func max(a, b int) int {
	if b > a {
		return b
	}
	return 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 pubChan(s []int, c chan int) {
	for _, val := range s {
		c <- val
	}
	close(c)
}

func solution(stack, sequence []int) []int {
	solSeq := make([]int, len(sequence))
	had := make(map[int]bool)

	s, q := make(chan int, len(sequence)), make(chan int, len(sequence))
	go pubChan(stack, s)
	go pubChan(sequence, q)

	index, counter := 0, 0

	for qVal := range q {
		if _, ok := had[qVal]; ok {
			// printf("skipping value: %v\n", qVal)
			index++
			continue
		}
		counter = 0

		for sVal := range s {
			// printf("inside inner loop:%v\n", sVal)
			counter++
			if sVal == qVal {
				solSeq[index] = counter
				index++
				// printf("breaked inner loop: %v\n", sVal)
				break
			}
			had[sVal] = true
		}
	}

	return solSeq
}

func main() {
	//STDOUT MUST BE FLUSHED MANUALLY
	defer writer.Flush()

	var n int
	scanf("%d\n", &n)
	stack, sequence := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		scanf("%d", &stack[i])
	}
	scanf("\n")
	for i := 0; i < n; i++ {
		scanf("%d", &sequence[i])
	}
	scanf("\n")
	for _, val := range solution(stack, sequence) {
		printf("%v ", val)
	}
	printf("\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 pubChan(s []int, c chan int) {
	for _, val := range s {
		c <- val
	}
	close(c)
}

func solution(stack, sequence []int) []int {
	solSeq := make([]int, len(sequence))
	had := make(map[int]bool)

	s, q := make(chan int, len(sequence)), make(chan int, len(sequence))
	pubChan(stack, s)
	pubChan(sequence, q)

	index, counter := 0, 0

	for qVal := range q {
		if _, ok := had[qVal]; ok {
			// printf("skipping value: %v\n", qVal)
			index++
			continue
		}
		counter = 0

		for sVal := range s {
			// printf("inside inner loop:%v\n", sVal)
			counter++
			if sVal == qVal {
				solSeq[index] = counter
				index++
				// printf("breaked inner loop: %v\n", sVal)
				break
			}
			had[sVal] = true
		}
	}

	return solSeq
}

func main() {
	//STDOUT MUST BE FLUSHED MANUALLY
	defer writer.Flush()

	var n int
	scanf("%d\n", &n)
	stack, sequence := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		scanf("%d", &stack[i])
	}
	scanf("\n")
	for i := 0; i < n; i++ {
		scanf("%d", &sequence[i])
	}
	scanf("\n")
	for _, val := range solution(stack, sequence) {
		printf("%v ", val)
	}
	printf("\n")
}

package main

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

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

	m := map[string]int{}
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	for i := 1; i <= n; i++ {
		scanner.Scan()
		m[scanner.Text()] = i
	}

	top := 0
	result := []string{}
	for i := 1; i <= n; i++ {
		scanner.Scan()
		newTop := m[scanner.Text()]
		if newTop > top {
			result = append(result, strconv.Itoa(newTop-top))
			top = newTop
		} else {
			result = append(result, "0")
		}
	}
	fmt.Println(strings.Join(result, " "))
}

// A simple #ad-hoc problem.
package main

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

func main() {
	N, _ := strconv.Atoi(readLine())
	a := make([]int, N)
	b := make([]int, N)
	m := map[int]int{}
	counter := 0
	for i, raw := range strings.Split(readLine(), " ") {
		a[i], _ = strconv.Atoi(raw)
		m[a[i]] = i + 1
	}
	for i, raw := range strings.Split(readLine(), " ") {
		b[i], _ = strconv.Atoi(raw)
	}

	steps := make([]string, N)
	for i := 0; i < N; i++ {
		step := m[b[i]] - counter
		if step < 0 {
			steps[i] = "0"
		} else {
			steps[i] = strconv.Itoa(step)
			counter = m[b[i]]
		}
	}
	fmt.Println(strings.Join(steps, " "))
}

var scanner = bufio.NewScanner(os.Stdin)

func readLine() string {
	scanner.Scan()
	return scanner.Text()
}

package main

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

func main() {
	m := map[string]int{}
	readLine()
	for i, s := range strings.Split(readLine(), " ") {
		m[s] = i + 1
	}
	top := 0
	for _, s := range strings.Split(readLine(), " ") {
		newTop := m[s]
		if newTop > top {
			fmt.Println(newTop - top)
			top = newTop
		} else {
			fmt.Println(0)
		}
	}
}

var scanner = bufio.NewScanner(os.Stdin)

func readLine() string {
	scanner.Scan()
	return scanner.Text()
}

package main

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

func main() {
	m := map[string]int{}
	readLine()
	for i, s := range strings.Split(readLine(), " ") {
		m[s] = i + 1
	}
	top := 0
	result := []string{}
	for _, s := range strings.Split(readLine(), " ") {
		newTop := m[s]
		if newTop > top {
			result = append(result, strconv.Itoa(newTop-top))
			top = newTop
		} else {
			result = append(result, "0")
		}
	}
	fmt.Println(strings.Join(result, " "))
}

var scanner = bufio.NewReader(os.Stdin)

func readLine() string {
	line, _, _ := scanner.ReadLine()
	return string(line)
}


package main

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

func main()  {

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

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

	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &arr[i])
	}

	max := 1
	cnt := 1
	for i := 0; i < n - 1; i++ {
		if arr[i] * 2 >= arr[i + 1] {
			cnt++
		} else {
			if max < cnt {
				max = cnt
			}
			cnt = 1
		}
	}
	if max < cnt {
		max = cnt
	}

	fmt.Fprintln(out, max)

}

package main

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

func main(){
	var n,pre int
	Scan(&n,&pre)
	max:=1
	cnt:=1
	in:=bufio.NewReader(os.Stdin)
	for i:=1;i<n;i++{
		var cur int
		Fscan(in,&cur)
		if cur<=pre<<1{
			cnt++
			if max<cnt{
				max=cnt
			}
		}else{
			cnt=1
		}
		pre=cur
	}

	Print(max)
}

package main

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

func main(){
	var n,pre int
	Scan(&n,&pre)
	max:=1
	cnt:=1
	in:=bufio.NewReader(os.Stdin)
	for i:=1;i<n;i++{
		var cur int
		Fscan(in,&cur)
		if cur<=pre<<1{
			cnt++
		}else{
			if max<cnt{
				max=cnt
			}
			cnt=1
		}
		pre=cur
	}

	if max<cnt{
		max=cnt
	}
	Print(max)
}

package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()

	A := sc.NextIntArray()

	mx := 0
	for i := 0; i < N; i++ {
		j := i + 1
		for ; j < N; j++ {
			if A[j-1]*2 < A[j] {
				if mx < j-i {
					mx = j - i
				}
				break
			}
		}

		if j == N {
			if mx < j-i {
				mx = j - i
			}
		}
		i = j - 1
	}
	fmt.Println(mx)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

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

const (
	Maxn = 200005
)

var n int
var a, dp [Maxn]int

func find(value, end int) int {
	l, r, mid, last := 0, end + 1, end, end
	for l < r {
		mid = (l + r) / 2
		if a[mid] < value {
			l = mid + 1
		} else {
			r = mid
			last = mid
		}
	}
	return last
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(buf, "%d", &a[i])
	}
	ans := 1
	for i := 0; i < n; i++ {
		threshold := a[i] / 2 + a[i] % 2
		index := find(threshold, i)
		dp[i] = 1
		res := dp[index] + i - index
		if dp[i] < res {
			dp[i] = res
		}
		if ans < dp[i] {
			ans = dp[i]
		}
	}
	fmt.Println(ans)
}

package main

import (
	"fmt"
	"bufio"
	"strconv"
	"os"
)
var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func ReadInt32() int {
	scanner.Scan()
	ans, _ := strconv.Atoi(scanner.Text())
	return ans
}
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)
	var n int
	fmt.Scan(&n)
	var l,m,k int
	for i:=0;i<n;i++{
		j := ReadInt32()
		if i == 0 {
			k++
		} else if j <= l *2 {
			k++
		} else if j> l*2  {
			k = 1
		}
		if k>m {
			m = k
		}
		l=j
	}
	fmt.Println(m)
}

package main

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

func main(){
	var n,pre int
	Scan(&n,&pre)
	max:=1
	cnt:=1
	in:=bufio.NewReader(os.Stdin)
	for i:=1;i<n;i++{
		var cur int
		Fscan(in,&cur)
		if cur<=pre<<1{
			cnt++
		}else{
			if max<cnt{
				max=cnt
			}
			cnt=1
		}
		pre=cur
	}

	Print(max)
}

package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()

	A := sc.NextIntArray()

	mx := 0
	for i := 0; i < N; i++ {
		j := i + 1
		for ; j < N; j++ {
			if A[i]*2 < A[j] {
				if mx < j-i {
					mx = j - i
				}
				break
			}
		}
		if j == N {
			if mx < j-i {
				mx = j - i
			}
		}
		i = j - 1
	}
	fmt.Println(mx)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


package main

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

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

	var n, q, v, t, d int
	Fscan(in, &n, &q)
	g := make([][]int, n)
	for w := 1; w < n; w++ {
		Fscan(in, &v)
		g[v-1] = append(g[v-1], w)
	}
	var s string
	Fscan(in, &s)
	tin := make([]int, n)
	tout := make([]int, n)
	depT := make([][]int, n+1)
	dep := make([][]int, n+1)
	for i := range dep {
		dep[i] = []int{0}
	}
	var f func(v, fa, d int)
	f = func(v, fa, d int) {
		t++
		tin[v] = t
		depT[d] = append(depT[d], t)
		dep[d] = append(dep[d], dep[d][len(dep[d])-1]^1<<(s[v]-'a'))
		for _, w := range g[v] {
			if w != fa {
				f(w, v, d+1)
			}
		}
		tout[v] = t
	}
	f(0, -1, 1)

	for ; q > 0; q-- {
		Fscan(in, &v, &d)
		v--
		row := depT[d]
		l := sort.SearchInts(row, tin[v])
		r := sort.SearchInts(row, tout[v]+1)
		c := dep[d][r] ^ dep[d][l]
		if c&(c-1) == 0 {
			Fprintln(out, "Yes")
		} else {
			Fprintln(out, "No")
		}
	}
}

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

package main

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

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

	var n, q, v, t, d int
	Fscan(in, &n, &q)
	g := make([][]int, n)
	for w := 1; w < n; w++ {
		Fscan(in, &v)
		g[v-1] = append(g[v-1], w)
	}
	var s string
	Fscan(in, &s)
	tin := make([]int, n)
	tout := make([]int, n)
	dep := make([][]int, n+1)
	depT := make([][]int, n+1)
	for i := range dep {
		dep[i] = []int{0}
		depT[i] = []int{0}
	}
	var f func(v, fa, d int)
	f = func(v, fa, d int) {
		t++
		tin[v] = t
		dep[d] = append(dep[d], dep[d][len(dep[d])-1]^1<<(s[v]-'a'))
		depT[d] = append(depT[d], t)
		for _, w := range g[v] {
			if w != fa {
				f(w, v, d+1)
			}
		}
		tout[v] = t
	}
	f(0, -1, 1)

	for ; q > 0; q-- {
		Fscan(in, &v, &d)
		v--
		row := depT[d]
		l := sort.SearchInts(row, tin[v]) - 1
		r := sort.SearchInts(row, tout[v]+1) - 1
		c := dep[d][r] ^ dep[d][l]
		if c&(c-1) == 0 {
			Fprintln(out, "Yes")
		} else {
			Fprintln(out, "No")
		}
	}
}

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


// Try Codeforces
// author: Leonardone @ NEETSDKASU
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([][]int, n)
	for i := range a {
		a[i] = make([]int, n)
		for j := range a[i] {
			fmt.Scan(&a[i][j])
		}
	}
	for i := range a {
	loop:
		for j, v := range a[i] {
			if v == 1 {
				continue
			}
			for s := 0; s < n; s++ {
				for t := 0; t < n; t++ {
					if a[s][j]+a[i][t] == v {
						continue loop
					}
				}
			}
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

package main

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

// var file, err = os.Open("a.in")
// var sc *Scanner = NewScanner(bufio.NewReader(file))
var sc *Scanner = NewScanner(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

type Scanner struct {
	r            io.Reader
	split        bufio.SplitFunc
	maxTokenSize int
	token, buf   []byte
	start, end   int
}

func NewScanner(r io.Reader) *Scanner {
	return &Scanner{
		r:            r,
		split:        bufio.ScanWords,
		maxTokenSize: 16777216,
		buf:          make([]byte, 4096),
	}
}

func (s *Scanner) advance(n int) bool {
	if n < 0 || n > s.end-s.start {
		return false
	}
	s.start += n
	return true
}

func (s *Scanner) Text() string {
	return string(s.token)
}

func (s *Scanner) Scan() bool {
	for {
		if s.end > s.start {
			advance, token, err := s.split(s.buf[s.start:s.end], false)
			if err != nil || !s.advance(advance) {
				return false
			}
			s.token = token
			if token != nil {
				return true
			}
		}
		if s.start > 0 && (s.end == len(s.buf) || s.start > len(s.buf)/2) {
			copy(s.buf, s.buf[s.start:s.end])
			s.end -= s.start
			s.start = 0
		}
		if s.end == len(s.buf) {
			if len(s.buf) >= s.maxTokenSize {
				return false
			}
			newSize := len(s.buf) * 2
			if newSize > s.maxTokenSize {
				newSize = s.maxTokenSize
			}
			newBuf := make([]byte, newSize)
			copy(newBuf, s.buf[s.start:s.end])
			s.buf = newBuf
			s.end -= s.start
			s.start = 0
			continue
		}
		for loop := 0; ; {
			n, _ := s.r.Read(s.buf[s.end:len(s.buf)])
			s.end += n
			if n > 0 {
				break
			}
			loop++
			if loop > 100 {
				break
			}
		}
	}
}

func (s *Scanner) Split(split bufio.SplitFunc) {
	s.split = split
}

func printSpace() { w.WriteByte(' ') }
func println()    { w.WriteByte('\n') }

func nextToken() string { sc.Scan(); return sc.Text() }

func nextInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func nextInt64() int64 {
	sc.Scan()
	n, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return n
}

func printInt(i ...int) {
	for _, ii := range i {
		w.WriteString(strconv.Itoa(ii))
		printSpace()
	}
}

func printInt64(i ...int64) {
	for _, ii := range i {
		w.WriteString(strconv.FormatInt(ii, 10))
		printSpace()
	}
}

func print(s ...string) {
	for _, ss := range s {
		w.WriteString(ss)
		printSpace()
	}
}

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

func max(i, j int) int {
	if i > j {
		return i
	}
	return j
}

func min64(i, j int64) int64 {
	if i < j {
		return i
	}
	return j
}

func max64(i, j int64) int64 {
	if i < j {
		return i
	}
	return j
}

func main() {
	defer w.Flush()

	n := nextInt()
	a := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, n)
		for j := 0; j < n; j++ {
			a[i][j] = nextInt()
		}
	}
	result := true
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if a[i][j] != 1 {
				found := false
				for s := 0; s < n; s++ {
					for t := 0; t < n; t++ {
						if a[i][j] == a[i][s]+a[t][j] {
							found = true
							break
						}
					}
				}
				result = result && found
			}
		}
	}

	if result {
		print("Yes")
	} else {
		print("No")
	}
}

package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	matrix := make([][]int, N)
	for i := 0; i < N; i++ {
		matrix[i] = sc.NextIntArray()
	}

	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			if matrix[i][j] == 1 {
				continue
			}

			ok := false
			for k := 0; k < N; k++ {
				if k == i {
					continue
				}
				for l := 0; l < N; l++ {
					if l == j {
						continue
					}

					if matrix[i][j] == matrix[k][j]+matrix[i][l] {
						ok = true
						break
					}
				}
			}
			if !ok {
				fmt.Println("No")
				return
			}
		}
	}
	fmt.Println("Yes")

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

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

// var file, err = os.Open("a.in")
// var sc *Scanner = NewScanner(bufio.NewReader(file))
var sc *Scanner = NewScanner(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

type Scanner struct {
	r            io.Reader
	split        bufio.SplitFunc
	maxTokenSize int
	token, buf   []byte
	start, end   int
}

func NewScanner(r io.Reader) *Scanner {
	return &Scanner{
		r:            r,
		split:        bufio.ScanWords,
		maxTokenSize: 16777216,
		buf:          make([]byte, 4096),
	}
}

func (s *Scanner) advance(n int) bool {
	if n < 0 || n > s.end-s.start {
		return false
	}
	s.start += n
	return true
}

func (s *Scanner) Text() string {
	return string(s.token)
}

func (s *Scanner) Scan() bool {
	for {
		if s.end > s.start {
			advance, token, err := s.split(s.buf[s.start:s.end], false)
			if err != nil || !s.advance(advance) {
				return false
			}
			s.token = token
			if token != nil {
				return true
			}
		}
		if s.start > 0 && (s.end == len(s.buf) || s.start > len(s.buf)/2) {
			copy(s.buf, s.buf[s.start:s.end])
			s.end -= s.start
			s.start = 0
		}
		if s.end == len(s.buf) {
			if len(s.buf) >= s.maxTokenSize {
				return false
			}
			newSize := len(s.buf) * 2
			if newSize > s.maxTokenSize {
				newSize = s.maxTokenSize
			}
			newBuf := make([]byte, newSize)
			copy(newBuf, s.buf[s.start:s.end])
			s.buf = newBuf
			s.end -= s.start
			s.start = 0
			continue
		}
		for loop := 0; ; {
			n, _ := s.r.Read(s.buf[s.end:len(s.buf)])
			s.end += n
			if n > 0 {
				break
			}
			loop++
			if loop > 100 {
				break
			}
		}
	}
}

func (s *Scanner) Split(split bufio.SplitFunc) {
	s.split = split
}

func printSpace() { w.WriteByte(' ') }
func println()    { w.WriteByte('\n') }

func nextToken() string { sc.Scan(); return sc.Text() }

func nextInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func nextInt64() int64 {
	sc.Scan()
	n, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return n
}

func printInt(i ...int) {
	for _, ii := range i {
		w.WriteString(strconv.Itoa(ii))
		printSpace()
	}
}

func printInt64(i ...int64) {
	for _, ii := range i {
		w.WriteString(strconv.FormatInt(ii, 10))
		printSpace()
	}
}

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

func max(i, j int) int {
	if i > j {
		return i
	}
	return j
}

func min64(i, j int64) int64 {
	if i < j {
		return i
	}
	return j
}

func max64(i, j int64) int64 {
	if i < j {
		return i
	}
	return j
}

func main() {
	defer w.Flush()

	n := nextInt()
	a := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, n)
		for j := 0; j < n; j++ {
			a[i][j] = nextInt()
		}
	}
	result := true
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if a[i][j] != 1 {
				found := false
				for s := 0; s < n; s++ {
					for t := 0; t < n; t++ {
						if a[i][j] == a[i][s]+a[t][j] {
							found = true
							break
						}
					}
				}
				result = result && found
			}
		}
	}

	if result {
		print("Yes")
	} else {
		print("No")
	}
}


//http://codeforces.com/problemset/problem/451/B

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"io"
	"os"
)

func main() {
	reader := NewStdReader(os.Stdin)
	n := reader.ReadInt()
	a := make([]int, n)

	type Segment struct {
		Begin, End int
	}

	listSegment := list.New()
	var curSegment *Segment

	for i := 0; i < n; i++ {
		a[i] = reader.ReadInt()
		if i > 0 {
			if a[i-1] > a[i] {
				if curSegment == nil {
					curSegment = &Segment{
						Begin: i - 1,
					}
					listSegment.PushBack(curSegment)
					if listSegment.Len() > 1 {
						break
					}
				}
				curSegment.End = i
			} else {
				curSegment = nil
			}
		}
	}

	if listSegment.Len() == 0 {
		fmt.Println("yes")
		fmt.Println(1, 1)
		return
	}
	if listSegment.Len() == 1 {
		segment := listSegment.Front().Value.(*Segment)
		if (segment.Begin == 0 || a[segment.Begin - 1] < a[segment.End]) &&
			(segment.End == n - 1 || a[segment.End + 1] > a[segment.Begin]) {
			fmt.Println("yes")
			fmt.Println(segment.Begin + 1, segment.End + 1)
			return
		}
	}

	fmt.Println("no")

}

type StdReader struct {
	buf *bufio.Reader
}

func NewStdReader(reader io.Reader) *StdReader {
	return &StdReader{bufio.NewReaderSize(reader, 20*1024*1024)}
}

func (std *StdReader) ReadInt() int {

	r := 0
	sign := 1
	ok := false

	for {
		b, e := std.buf.ReadByte()

		if e != nil {
			break
		}
		if b >= '0' && b <= '9' {
			r = r*10 + int(b-'0')
			ok = true
		} else {
			if ok {
				break
			} else {
				if b == '-' {
					sign = -sign
				}
			}
		}
	}

	return sign * r
}

package main

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

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

	//var n int
	//var a int
	//var b int
	var a []int

	inputLine1, _ := reader.ReadString('\n')
	value := strings.Split(strings.TrimSpace(inputLine1), " ")

	_, _ = strconv.Atoi(value[0])

	inputLine2, _ := reader.ReadString('\n')
	tmpArray := strings.Split(strings.TrimSpace(inputLine2), " ")

	a = convertStringToInt(tmpArray)

	var length = len(a)
	var max = a[0]
	var startIndex = 0

	for i := 0; i < length; i++ {
		if a[i] < max {
			startIndex = i - 1
			break
		}
		max = a[i]
	}

	//fmt.Println("start: ", startIndex)

	var min = a[startIndex]
	var endIndex = startIndex
	for i := endIndex; i < length; i++ {
		if a[i] > min {
			endIndex = i - 1
			break
		}
		if i == length - 1 {
			endIndex = i
		}
		min = a[i]
	}
	//fmt.Println("end: ", endIndex)

	if startIndex == endIndex {
		fmt.Println("yes")
		fmt.Println(startIndex + 1, endIndex + 1)
		os.Exit(0)
	}

	//fmt.Println(a)
	i := startIndex
	end := float64(endIndex - startIndex + 1)
	end = math.Floor(end / 2)
	stopIndex := startIndex + int(end) - 1
	for i <= stopIndex {
		gap := i - startIndex
		tmp := a[i]
		a[i] = a[endIndex - gap]
		a[endIndex - gap] = tmp
		i++
	}

	//fmt.Println("sorted: ", a)

	if isSort := sort.IntsAreSorted(a); isSort {
		fmt.Println("yes")
		fmt.Println(startIndex + 1, endIndex + 1)
	} else {
		fmt.Println("no")
	}
}

func convertStringToInt(arr []string) (result []int) {

	for _, string := range arr {
		if string == "" {
			continue
		}
		value, err := strconv.Atoi(string)
		if err != nil {
			fmt.Println(err)
		}
		result = append(result, value)
	}
	return result
}

package main

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

func solve(n int, arr []int) {
	left, right := -1, -1
	arr2 := make([]int, len(arr))
	copy(arr2, arr)
	sort.Slice(arr2, func(i int, j int) bool { return arr2[i] < arr2[j] })

	for i := range arr {
		if arr[i] != arr2[i] {
			if left == -1 {
				left = i
			} else {
				right = i
			}
		}
	}

	if left != -1 {
		j := right
		for i := left; i <= right; i++ {
			if arr[i] != arr2[j] {
				fmt.Println("no")
				return
			}
			j--
		}
	} else {
		fmt.Println("yes")
		fmt.Println(1, 1)
		return
	}

	fmt.Println("yes")
	fmt.Println(left+1, right+1)
}

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

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

	arr := make([]int, n)

	for i := range arr {
		fmt.Fscanf(r, "%d", &arr[i])
	}

	solve(n, arr)
}

package main

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

func solve(n int, arr []int) {
	left, right := -1, -1
	arr2 := make([]int, len(arr))
	copy(arr2, arr)
	sort.Slice(arr2, func(i int, j int) bool { return arr2[i] < arr2[j] })

	for i := range arr {
		if arr[i] != arr2[i] {
			if left == -1 {
				left = i
				continue
			}
			right = i
		}
	}

	if left == -1 {
		fmt.Println("yes")
		fmt.Println(1, 1)
		return
	}

	j := right
	for i := left; i <= right; i++ {
		if arr[i] != arr2[j] {
			fmt.Println("no")
			return
		}
		j--
	}

	fmt.Println("yes")
	fmt.Println(left+1, right+1)
}

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

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

	arr := make([]int, n)

	for i := range arr {
		fmt.Fscanf(r, "%d", &arr[i])
	}

	solve(n, arr)
}

package main

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

func can_sort(a []int64, n int) (bool, int, int) {
	// comparisons := make([]int, n)
	// for i := 1; i < n; i++ {
	//	if a[i-1] > a[i] {
	//		comparisons[i-1] = 1
	//		continue
	//	}
	//	if a[i-1] < a[i] {
	//		comparisons[i-1] = -1
	//		continue
	//	}
	//	comparisons[i-1] = 0
	// }
	var i int
	for i = 0; i < n-1 && a[i] <= a[i+1]; i++ {
	}
	if i == n-1 {
		// Array is already sorted
		return true, 1, 1
	}
	start := i
	for ; i < n-1 && a[i] >= a[i+1]; i++ {
	}
	end := i
	for ; i < n-1 && a[i] <= a[i+1]; i++ {
	}
	if i < n-1 {
		return false, -1, -1
	}
	if start > 0 && a[start - 1] > a[end] {
		return false, -1, -1
	}
	if end < n - 1 && a[end + 1] < a[start] {
		return false, -1, -1
	}
	return true, start + 1, end + 1
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &a[i])
	}
	yes, start, end := can_sort(a, n)
	if !yes {
		fmt.Fprintln(writer, "no")
		return
	}
	fmt.Fprintln(writer, "yes")
	fmt.Fprintln(writer, start, end)
}

package main

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

func solve(n int, an []int) (can bool, left, right int) {
	/* find left */
	left = -1
	for i := 0; i < n-1; i++ {
		if an[i+1] < an[i] {
			left = i
			break
		}
	}

	/* sorted */
	if left == -1 {
		return true, 1, 1
	}

	/* find right */
	right = -1
	for i := left; i < n-1; i++ {
		if an[i] < an[i+1] {
			right = i
			break
		}
	}
	if right == -1 {
		right = n - 1
	}

	for i := right + 1; i < n; i++ {
		if an[i] < an[i-1] {
			return false, -1, -1
		}
	}

	if left >= 1 && an[left-1] > an[right] {
		return false, -1, -1
	}
	if right != n-1 && an[right+1] < an[left] {
		return false, -1, -1
	}

	return true, left + 1, right + 1
}

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

	an := make([]int, n, n)
	bs := bufio.NewScanner(os.Stdin)
	bs.Split(bufio.ScanWords)

	for i := 0; i < n; i++ {
		bs.Scan()
		an[i], _ = strconv.Atoi(bs.Text())
	}

	can, left, right := solve(n, an)
	if can {
		fmt.Println("yes")
		fmt.Println(left, right)
	} else {
		fmt.Println("no")
	}
}

package main

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

var in = bufio.NewScanner(os.Stdin)

func readInt() int {
	if !in.Scan() {
		panic(in.Err())
	}
	res := 0
	for _, b := range in.Bytes() {
		res = res*10 + int(b-'0')
	}
	return res
}

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

	n := readInt()
	a := make([]int, n)
	for i := range a {
		a[i] = readInt()
	}
	st := 0
	for ; st < n-1; st++ {
		if a[st+1] < a[st] {
			break
		}
	}
	en := st
	for ; en < n-1; en++ {
		if a[en+1] > a[en] {
			break
		}
	}
	for i := en; i < n-1; i++ {
		if a[i+1] < a[i] {
			fmt.Println("no")
			return
		}
	}
	if st > 0 && a[st-1] > a[en] || en < n-1 && a[en+1] < a[st] {
		fmt.Println("no")
		return
	}
	fmt.Println("yes")
	fmt.Println(st+1, en+1)
}

package main

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

var scanner = bufio.NewScanner(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	a := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	i := 0

	for i < n - 1{
		if a[i] < a[i + 1] {
			i++
		} else {
			break
		}
	}

	if i == n - 1 {
		println("yes")
		println("1 1")
		return
	}

	l, r := i, 0

	for i < n - 1 {
		if a[i] > a[i + 1] {
			i++
		} else {
			r = i
			break
		}
	}

	if i == n - 1 {
		r = n - 1
	}

	// println(i, l, r)

	if i < n - 1 && a[l] > a[i + 1] {
		println("no")
		return
	}

	if l > 0 && a[r] < a[l - 1] {
		println("no")
		return
	}

	for i < n - 1 {
		if a[i] < a[i + 1] {
			i++
		} else {
			println("no")
			return
		}
	}

	println("yes")
	println(l + 1, r + 1)
}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return n
}

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

func printf(format string, a ...interface{}) {
	fmt.Fprintf(writer, format, a...)
}

package main

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

var scanner = bufio.NewScanner(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	a := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	i := 0

	for i < n - 1{
		if a[i] < a[i + 1] {
			i++
		} else {
			break
		}
	}

	if i == n - 1 {
		println("yes")
		println("1 1")
		return
	}

	l, r := i, 0

	for i < n - 1 {
		if a[i] > a[i + 1] {
			i++
		} else {
			r = i + 1
			break
		}
	}

	if i == n - 1 {
		r = n
	}

	// println(i, l, r)

	if i < n - 1 && a[l] > a[i + 1] {
		println("no")
		return
	}

	for i < n - 1 {
		if a[i] < a[i + 1] {
			i++
		} else {
			println("no")
			return
		}
	}

	println("yes")
	println(l + 1, r)
}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return n
}

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

func printf(format string, a ...interface{}) {
	fmt.Fprintf(writer, format, a...)
}

package main

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

var scanner = bufio.NewScanner(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	a := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	i := 0

	for i < n - 1{
		if a[i] < a[i + 1] {
			i++
		} else {
			break
		}
	}

	if i == n - 1 {
		println("yes")
		println("1 1")
		return
	}

	l, r := i, 0

	for i < n - 1 {
		if a[i] > a[i + 1] {
			i++
		} else {
			r = i
			break
		}
	}

	if i == n - 1 {
		r = n - 1
	}

	println(i, l, r)

	if i < n - 1 && a[l] > a[i + 1] {
		println("no")
		return
	}

	if l > 0 && a[r] < a[l - 1] {
		println("no")
		return
	}

	for i < n - 1 {
		if a[i] < a[i + 1] {
			i++
		} else {
			println("no")
			return
		}
	}

	println("yes")
	println(l + 1, r + 1)
}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return n
}

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

func printf(format string, a ...interface{}) {
	fmt.Fprintf(writer, format, a...)
}

package main

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

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

	//var n int
	//var a int
	//var b int
	var a []int

	inputLine1, _ := reader.ReadString('\n')
	value := strings.Split(strings.TrimSpace(inputLine1), " ")

	_, _ = strconv.Atoi(value[0])

	inputLine2, _ := reader.ReadString('\n')
	tmpArray := strings.Split(strings.TrimSpace(inputLine2), " ")

	a = convertStringToInt(tmpArray)

	var length = len(a)
	var max = a[0]
	var startIndex = 0

	for i := 0; i < length; i++ {
		if a[i] < max {
			startIndex = i - 1
			break
		}
		max = a[i]
	}

	//fmt.Println("start: ", startIndex)

	var min = a[startIndex]
	var endIndex = startIndex
	for i := endIndex; i < length; i++ {
		if a[i] > min {
			endIndex = i - 1
			break
		}
		if i == length - 1 {
			endIndex = i
		}
		min = a[i]
	}
	//fmt.Println("end: ", endIndex)

	if startIndex == endIndex {
		fmt.Println("yes")
		fmt.Println(startIndex + 1, endIndex + 1)
		os.Exit(0)
	}

	//fmt.Println(a)
	sort.Slice(a, func(i, j int) bool {
		//fmt.Println(i, a[i], j, a[j])
		return startIndex <= j && i <= endIndex
	})

	//fmt.Println("sorted: ", a)

	if isSort := sort.IntsAreSorted(a); isSort {
		fmt.Println("yes")
		fmt.Println(startIndex + 1, endIndex + 1)
	} else {
		fmt.Println("no")
	}
}

func convertStringToInt(arr []string) (result []int) {

	for _, string := range arr {
		if string == "" {
			continue
		}
		value, err := strconv.Atoi(string)
		if err != nil {
			fmt.Println(err)
		}
		result = append(result, value)
	}
	return result
}

package main

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

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

	//var n int
	//var a int
	//var b int
	var a []int

	inputLine1, _ := reader.ReadString('\n')
	value := strings.Split(strings.TrimSpace(inputLine1), " ")

	_, _ = strconv.Atoi(value[0])

	inputLine2, _ := reader.ReadString('\n')
	tmpArray := strings.Split(strings.TrimSpace(inputLine2), " ")

	a = convertStringToInt(tmpArray)

	var length = len(a)
	var max = a[0]
	var startIndex = 0

	for i := 0; i < length; i++ {
		if a[i] < max {
			startIndex = i - 1
			break
		}
		max = a[i]
	}

	//fmt.Println("start: ", startIndex)

	var min = a[startIndex]
	var endIndex = startIndex
	for i := endIndex; i < length; i++ {
		if a[i] > min {
			endIndex = i - 1
			break
		}
		if i == length - 1 {
			endIndex = i
		}
		min = a[i]
	}
	//fmt.Println("end: ", endIndex)

	if startIndex == endIndex {
		fmt.Println("yes")
		fmt.Println(startIndex + 1, endIndex + 1)
		os.Exit(0)
	}

	fmt.Println(a)
	sort.Slice(a, func(i, j int) bool {
		//fmt.Println(i, a[i], j, a[j])
		return startIndex <= j && i <= endIndex
	})

	//fmt.Println("sorted: ", a)

	if isSort := sort.IntsAreSorted(a); isSort {
		fmt.Println("yes")
		fmt.Println(startIndex + 1, endIndex + 1)
	} else {
		fmt.Println("no")
	}
}

func convertStringToInt(arr []string) (result []int) {

	for _, string := range arr {
		if string == "" {
			continue
		}
		value, err := strconv.Atoi(string)
		if err != nil {
			fmt.Println(err)
		}
		result = append(result, value)
	}
	return result
}

package main

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

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

	//var n int
	//var a int
	//var b int
	var a []int

	inputLine1, _ := reader.ReadString('\n')
	value := strings.Split(strings.TrimSpace(inputLine1), " ")

	_, _ = strconv.Atoi(value[0])

	inputLine2, _ := reader.ReadString('\n')
	tmpArray := strings.Split(strings.TrimSpace(inputLine2), " ")

	a = convertStringToInt(tmpArray)

	var length = len(a)
	var max = a[0]
	var startIndex = 0

	for i := 0; i < length; i++ {
		if a[i] < max {
			startIndex = i - 1
			break
		}
		max = a[i]
	}

	//fmt.Println("start: ", startIndex)

	var min = a[startIndex]
	var endIndex = startIndex
	for i := endIndex; i < length; i++ {
		if a[i] > min {
			endIndex = i - 1
			break
		}
		if i == length - 1 {
			endIndex = i
		}
		min = a[i]
	}
	//fmt.Println("end: ", endIndex)

	if startIndex == endIndex {
		fmt.Println("yes")
		fmt.Println(startIndex + 1, endIndex + 1)
		os.Exit(0)
	}

	//fmt.Println(a)
	i := startIndex
	for float64(i) <= math.Ceil(float64(endIndex) / 2) {
		gap := i - startIndex
		tmp := a[i]
		a[i] = a[endIndex - gap]
		a[endIndex - gap] = tmp
		i++
	}

	//fmt.Println("sorted: ", a)

	if isSort := sort.IntsAreSorted(a); isSort {
		fmt.Println("yes")
		fmt.Println(startIndex + 1, endIndex + 1)
	} else {
		fmt.Println("no")
	}
}

func convertStringToInt(arr []string) (result []int) {

	for _, string := range arr {
		if string == "" {
			continue
		}
		value, err := strconv.Atoi(string)
		if err != nil {
			fmt.Println(err)
		}
		result = append(result, value)
	}
	return result
}

package main

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

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

	//var n int
	//var a int
	//var b int
	var a []int

	inputLine1, _ := reader.ReadString('\n')
	value := strings.Split(strings.TrimSpace(inputLine1), " ")

	_, _ = strconv.Atoi(value[0])

	inputLine2, _ := reader.ReadString('\n')
	tmpArray := strings.Split(strings.TrimSpace(inputLine2), " ")

	a = convertStringToInt(tmpArray)

	var length = len(a)
	var max = a[0]
	var startIndex = 0

	for i := 0; i < length; i++ {
		if a[i] < max {
			startIndex = i - 1
			break
		}
		max = a[i]
	}

	//fmt.Println("start: ", startIndex)

	var min = a[startIndex]
	var endIndex = startIndex
	for i := endIndex; i < length; i++ {
		if a[i] > min {
			endIndex = i - 1
			break
		}
		if i == length - 1 {
			endIndex = i
		}
		min = a[i]
	}
	//fmt.Println("end: ", endIndex)

	if startIndex == endIndex {
		fmt.Println("yes")
		fmt.Println(startIndex + 1, endIndex + 1)
		os.Exit(0)
	}

	//fmt.Println(a)
	i := startIndex
	var end float64
	if endIndex % 2 == 0 {
		end = math.Ceil(float64(endIndex) / 2)
	} else {
		end = math.Floor(float64(endIndex) / 2)
	}
	for float64(i) <= end {
		gap := i - startIndex
		tmp := a[i]
		a[i] = a[endIndex - gap]
		a[endIndex - gap] = tmp
		i++
	}

	//fmt.Println("sorted: ", a)

	if isSort := sort.IntsAreSorted(a); isSort {
		fmt.Println("yes")
		fmt.Println(startIndex + 1, endIndex + 1)
	} else {
		fmt.Println("no")
	}
}

func convertStringToInt(arr []string) (result []int) {

	for _, string := range arr {
		if string == "" {
			continue
		}
		value, err := strconv.Atoi(string)
		if err != nil {
			fmt.Println(err)
		}
		result = append(result, value)
	}
	return result
}

package main

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

func canBeSort(arr []int)  {
	start, end, found, dupe := -1, -1, false, 0

	for i := 0; i < len(arr)-1; i++ {
		if arr[i] > arr[i+1] {
			if start == -1 {
				start = i - dupe
			} else if !found {
				end = i + 1
			} else {
			    fmt.Println("no")
				return
			}
		} else if arr[i] < arr[i+1] {
			if !found && start != -1 {
				end = i
				found = true
			} else {
				dupe = 0
			}
		} else {
			if start != -1 {
				end = i + 1
			} else {
				dupe++
			}
		}
	}

	if start == 0 && end == len(arr)-1 {
	    fmt.Println("yes")
		fmt.Println(start + 1, end + 1)
		return
	} else if start == 0 {
		if arr[start] > arr[end+1] {
			    fmt.Println("no")
				return
		}
	} else if end == len(arr)-1 {
		if arr[end] < arr[start-1] {
			    fmt.Println("no")
				return
		}
	} else if start != -1 && (end == -1 || arr[end] < arr[start-1] || arr[start] > arr[end+1]) {
	    fmt.Println("no")
				return
	}

	 fmt.Println("yes")
	fmt.Println(start + 1, end + 1)
}
func main() {
	r := bufio.NewReader(os.Stdin)

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

	arr := make([]int, n)

	for i := range arr {
		fmt.Fscanf(r, "%d", &arr[i])
	}

	canBeSort(arr)

}

package main

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

func solve(n int, arr []int) {
	left, right := -1, -1
	arr2 := make([]int, len(arr))
	copy(arr2, arr)
	sort.Slice(arr2, func(i int, j int) bool { return arr[i] < arr[j] })

	for i := range arr {
		if arr[i] != arr2[i] {
			if left == -1 {
				left = i
			} else {
				right = i
			}
		}
	}

	if left != -1 {
		j := right
		for i := left; i <= right; i++ {
			if arr[i] != arr2[j] {
				fmt.Println("no")
				return
			}
			j--
		}
	} else {
		fmt.Println("yes")
		fmt.Println(1, 1)
		return
	}

	fmt.Println("yes")
	fmt.Println(left+1, right+1)
}

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

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

	arr := make([]int, n)

	for i := range arr {
		fmt.Fscanf(r, "%d", &arr[i])
	}

	solve(n, arr)
}

package main

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

func canBeSort(arr []int) string {
	start, end, found, dupe := -1, -1, false, 0

	for i := 0; i < len(arr)-1; i++ {
		if arr[i] > arr[i+1] {
			if start == -1 {
				start = i - dupe
			} else if !found {
				end = i + 1
			} else {
				return "no"
			}
		} else if arr[i] < arr[i+1] {
			if !found && start != -1 {
				end = i
				found = true
			} else {
				dupe = 0
			}
		} else {
			if start != -1 {
				end = i + 1
			} else {
				dupe++
			}
		}
	}

	if start == 0 && end == len(arr)-1 {
		return "yes"
	} else if start == 0 {
		if arr[start] > arr[end+1] {
			return "no"
		}
	} else if end == len(arr)-1 {
		if arr[end] < arr[start-1] {
			return "no"
		}
	} else if start != -1 && (end == -1 || arr[end] < arr[start-1] || arr[start] > arr[end+1]) {
		return "no"
	}

	return "yes"
}
func main() {
	r := bufio.NewReader(os.Stdin)

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

	arr := make([]int, n)

	for i := range arr {
		fmt.Fscanf(r, "%d", &arr[i])
	}

	fmt.Fprintf(os.Stdout, "%s\n", canBeSort(arr))
}