Moamen has an array of $$$n$$$ distinct integers. He wants to sort that array in non-decreasing order by doing the following operations in order exactly once:  Split the array into exactly $$$k$$$ non-empty subarrays such that each element belongs to exactly one subarray.  Reorder these subarrays arbitrary.  Merge the subarrays in their new order. A sequence $$$a$$$ is a subarray of a sequence $$$b$$$ if $$$a$$$ can be obtained from $$$b$$$ by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.Can you tell Moamen if there is a way to sort the array in non-decreasing order using the operations written above?

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^3$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 10^5$$$). The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le |a_i| \le 10^9$$$). It is guaranteed that all numbers are distinct. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$3\cdot10^5$$$.

For each test case, you should output a single string. If Moamen can sort the array in non-decreasing order, output "YES" (without quotes). Otherwise, output "NO" (without quotes). You can print each letter of "YES" and "NO" in any case (upper or lower).

NoteIn the first test case, $$$a = [6, 3, 4, 2, 1]$$$, and $$$k = 4$$$, so we can do the operations as follows:   Split $$$a$$$ into $$$\{ [6], [3, 4], [2], [1] \}$$$.  Reorder them: $$$\{ [1], [2], [3,4], [6] \}$$$.  Merge them: $$$[1, 2, 3, 4, 6]$$$, so now the array is sorted. In the second test case, there is no way to sort the array by splitting it into only $$$2$$$ subarrays.As an example, if we split it into $$$\{ [1, -4], [0, -2] \}$$$, we can reorder them into $$$\{ [1, -4], [0, -2] \}$$$ or $$$\{ [0, -2], [1, -4] \}$$$. However, after merging the subarrays, it is impossible to get a sorted array.

package main

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

var in = NewIn()
var out = NewOut()

func main() {
	defer out.flush()

	tests()
	// solve()
}

type pair struct {
	first  int
	second int
}

/* --- Solution B --- */
func solve() {
	n := in.nextInt()
	k := in.nextInt()

	ans := 1
	arr := make([]int, n)
	sort_arr := make([]int, n)
	for i:=0; i < n; i++{
		arr[i] = in.nextInt()
		sort_arr[i] = arr[i]
	}

	sort.Slice(sort_arr, func(i, j int) bool {
		return sort_arr[i] < sort_arr[j]
	})
	M := make(map[int]int)
	for i, val := range sort_arr{
		M[val] = i
	}
	for i:=1; i < n; i ++{
		if arr[i] < arr[i-1] {
			ans ++
		}else if M[arr[i]] - M[arr[i-1]] != 1{
			ans ++
		}
	}
	if ans <= k{
		out.println("Yes")
	}else{
		out.println("No")
	}
}

func tests() {
	tt := in.nextInt()
	for ; tt > 0; tt-- {
		solve()
	}
}

/* --- I/O --- */
type In struct {
	scanner *bufio.Scanner
}

func NewIn() *In {
	in := In{bufio.NewScanner(os.Stdin)}
	in.scanner.Split(bufio.ScanWords)
	return &in
}

func (in *In) nextInt() int {
	in.scanner.Scan()
	i, _ := strconv.Atoi(in.scanner.Text())
	return i
}

func (in *In) nextLong() int64 {
	in.scanner.Scan()
	i, _ := strconv.ParseInt(in.scanner.Text(), 10, 64)
	return i
}

func (in *In) next() string {
	in.scanner.Scan()
	return in.scanner.Text()
}

type Out struct {
	writer *bufio.Writer
}

func NewOut() *Out {
	out := Out{bufio.NewWriter(os.Stdout)}
	return &out
}

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

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

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

func (out *Out) flush() {
	out.writer.Flush()
}

package main

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

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

func solve() {
	n, k := getI(), getI()
	s := NewSlice(n)

	groups := int64(1)

	for i := 0; i < int(n)-1; i++ {
		if s.i[i+1]-s.i[i] != 1 {
			groups++
		}

		if groups > k {
			out("No")

			return
		}
	}

	out("Yes")
}

// http://github.com/KadoBOT (me@ricardoambrogi.com)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)

	maxBuffer := 1e9
	byteSliceLen := 4096
	sc.Buffer(make([]byte, byteSliceLen), int(maxBuffer))

	for i := getI(); i > 0; i-- {
		solve()
	}
	out()
}

// !------- 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()

	b64 := 64
	i, e := strconv.ParseFloat(sc.Text(), b64)

	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 ceil(n, d int64) int64 {
	return (n + d - 1) / d
}

func nsort(data ...int64) []int64 {
	int64AsIntValues := make([]int, len(data))

	for i, val := range data {
		int64AsIntValues[i] = int(val)
	}

	sort.Ints(int64AsIntValues)

	for i, val := range int64AsIntValues {
		data[i] = int64(val)
	}

	return data
}

func nsum(data ...int64) int64 {
	var res int64
	for _, n := range data {
		res += n
	}

	return res
}

func njoin(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
}

// !------- FORMULAS -------!
func gcd(a, b int64) int64 {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}

	return a
}

func lcm(a, b int64, integers ...int64) int64 {
	result := a * b / gcd(a, b)

	for i := 0; i < len(integers); i++ {
		result = lcm(result, integers[i])
	}

	return result
}

func sieve(n int64) []int64 {
	integers := make([]bool, n+1)

	start := 2

	for i := int64(start); i < n+1; i++ {
		integers[i] = true
	}

	for p := int64(start); p*p <= n; p++ {
		if integers[p] {
			for i := p * int64(start); i <= n; i += p {
				integers[i] = false
			}
		}
	}

	var primes []int64

	for p := int64(start); p <= n; p++ {
		if integers[p] {
			primes = append(primes, p)
		}
	}

	return primes
}

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

type Slice struct {
	s []int64
	i []int
}

func NewSlice(n int64) *Slice {
	s := &Slice{s: getInts(n), i: make([]int, int(n))}

	for i := range s.i {
		s.i[i] = i
	}

	sort.Sort(s)

	return s
}

func (s Slice) Len() int {
	return len(s.s)
}

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

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

package main

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

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

func solve() {
	n, k := getI(), getI()
	s := NewSlice(n)

	groups := int64(1)

	for i := 0; i < int(n); i++ {
		if i != int(n)-1 && s.i[i+1]-s.i[i] != 1 {
			groups++
		}

		if groups > k {
			out("No")

			return
		}
	}

	out("Yes")
}

// http://github.com/KadoBOT (me@ricardoambrogi.com)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)

	maxBuffer := 1e9
	byteSliceLen := 4096
	sc.Buffer(make([]byte, byteSliceLen), int(maxBuffer))

	for i := getI(); i > 0; i-- {
		solve()
	}
	out()
}

// !------- 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()

	b64 := 64
	i, e := strconv.ParseFloat(sc.Text(), b64)

	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 ceil(n, d int64) int64 {
	return (n + d - 1) / d
}

func nsort(data ...int64) []int64 {
	int64AsIntValues := make([]int, len(data))

	for i, val := range data {
		int64AsIntValues[i] = int(val)
	}

	sort.Ints(int64AsIntValues)

	for i, val := range int64AsIntValues {
		data[i] = int64(val)
	}

	return data
}

func nsum(data ...int64) int64 {
	var res int64
	for _, n := range data {
		res += n
	}

	return res
}

func njoin(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
}

// !------- FORMULAS -------!
func gcd(a, b int64) int64 {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}

	return a
}

func lcm(a, b int64, integers ...int64) int64 {
	result := a * b / gcd(a, b)

	for i := 0; i < len(integers); i++ {
		result = lcm(result, integers[i])
	}

	return result
}

func sieve(n int64) []int64 {
	integers := make([]bool, n+1)

	start := 2

	for i := int64(start); i < n+1; i++ {
		integers[i] = true
	}

	for p := int64(start); p*p <= n; p++ {
		if integers[p] {
			for i := p * int64(start); i <= n; i += p {
				integers[i] = false
			}
		}
	}

	var primes []int64

	for p := int64(start); p <= n; p++ {
		if integers[p] {
			primes = append(primes, p)
		}
	}

	return primes
}

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

type Slice struct {
	s []int64
	i []int
}

func NewSlice(n int64) *Slice {
	s := &Slice{s: getInts(n), i: make([]int, int(n))}

	for i := range s.i {
		s.i[i] = i
	}

	sort.Sort(s)

	return s
}

func (s Slice) Len() int {
	return len(s.s)
}

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

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

package main

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

var in = NewIn()
var out = NewOut()

func main() {
	defer out.flush()

	tests()
	// solve()
}

type pair struct {
	first  int
	second int
}

/* --- Solution B --- */
func solve() {
	n := in.nextInt()
	k := in.nextInt()

	pairs := make([]pair, n)

	for i := 0; i < n; i++ {
		pairs[i] = pair{in.nextInt(), i}
	}

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

	q := 1
	for i := 1; i < n; i++ {
		if pairs[i-1].second+1 != pairs[i].second {
			q++
		}
	}

	var answer string
	if q <= k {
		answer = "Yes"
	} else {
		answer = "No"
	}
	out.println(answer)
}

func tests() {
	tt := in.nextInt()
	for ; tt > 0; tt-- {
		solve()
	}
}

/* --- I/O --- */
type In struct {
	scanner *bufio.Scanner
}

func NewIn() *In {
	in := In{bufio.NewScanner(os.Stdin)}
	in.scanner.Split(bufio.ScanWords)
	return &in
}

func (in *In) nextInt() int {
	in.scanner.Scan()
	i, _ := strconv.Atoi(in.scanner.Text())
	return i
}

func (in *In) nextLong() int64 {
	in.scanner.Scan()
	i, _ := strconv.ParseInt(in.scanner.Text(), 10, 64)
	return i
}

func (in *In) next() string {
	in.scanner.Scan()
	return in.scanner.Text()
}

type Out struct {
	writer *bufio.Writer
}

func NewOut() *Out {
	out := Out{bufio.NewWriter(os.Stdout)}
	return &out
}

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

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

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

func (out *Out) flush() {
	out.writer.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for c:=0;c<t;c++{
		var n, k int
		fmt.Fscan(in,&n,&k)
		l := []int{}
		or := []int{}
		for i:=1;i<=n;i++{
			var m int
			fmt.Fscan(in,&m)
			l = append(l,m)
			or = append(or,m)
		}
		sort.Ints(l)
		mp := map[int]int{}
		for i:=0;i<n-1;i++{
			mp[l[i]]=l[i+1]
		}
		cnt :=1
		for i:=0;i<n-1;i++{
			if mp[or[i]]!=or[i+1]||(or[i]==l[n-1]){
				cnt++
			}
		}
		if(cnt>k){
			fmt.Fprintln(out,"No")
		}else{
			fmt.Fprintln(out,"Yes")
		}
	}
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var caseNum int
	fmt.Fscan(r, &caseNum)
	for c := 0; c < caseNum; c++ {
		var n, k int
		fmt.Fscan(r, &n, &k)
		arr := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &arr[i])
		}
		solve1557E(arr, k)
	}
}
func solve1557E(arr []int, k int) {
	n := len(arr)
	sortArr := make([]int, n)
	for i := 0; i < n; i++ {
		sortArr[i] = arr[i]
	}
	sort.Slice(sortArr, func(i, j int) bool {
		return sortArr[i] < sortArr[j]
	})
	idxMap := map[int]int{}
	for i := 0; i < n; i++ {
		idxMap[sortArr[i]] = i
	}
	var pair int = 1
	for i := 1; i < n; i++ {
		if arr[i] < arr[i-1] {
			pair++
		} else if idxMap[arr[i]]-idxMap[arr[i-1]] != 1 {
			pair++
		}
	}
	if pair <= k {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

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, 4096), 1e9)
}

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

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

func _int64() int64 {
	s := _string()
	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 _string() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

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

func sol(n, k int, a []int) string {
	tmp := make([]int, n)
	copy(tmp, a)
	sort.Ints(tmp)
	m := map[int]int{} // val: idx
	for i := range tmp {
		m[tmp[i]] = i
	}
	spl := 0
	for i := 1; i < len(a); i++ {
		if m[a[i-1]] != m[a[i]]-1 {
			spl++
		}
	}
	part := spl + 1
	if k >= part {
		return "Yes"
	}
	return "No"
}

package main

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

func main() {

	r := bufio.NewReader(os.Stdin)

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

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

		a := make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Fscan(r, &a[j])
		}

		fmt.Println(solve(a, n, k))
	}
}

func solve(a []int, n, k int) string {
	if k > n {
		return "NO"
	}
	cop := make([]int, n)
	copy(cop, a)
	sort.Ints(cop)

	mp := make(map[int]int)

	for i := 0; i < n; i++ {
		mp[cop[i]] = i
	}

	//...345....

	//12345
	var c int

	for j := 0; j < len(a);  j++{
		e := a[j]
		pos := mp[e]

		if pos >= n - 1 {
			c++
			continue
		}
		k1 := j
		k2 := pos

		for ;k1 < n && k2 < n; {
			if a[k1] != cop[k2] {
				c++
				break
			}
			k1++
			k2++
		}
		if k1 == n || k2 == n {
			c++
		}
		j = k1 - 1
	}

	if c <= k {
		return "YES"
	}
	return "NO"
}

package main

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

func main() {
	defer wr.Flush()

	t := scanInt()

	for i := 0; i < t; i++ {
		n := scanInt()
		k := scanInt()

		ls := make([]int, n)
		for j := 0; j < n; j++ {
			ls[j] = scanInt()
		}

		sorted := make([]int, n)
		copy(sorted, ls)

		sort.Ints(sorted)

		sMap := make(map[int]int, n)

		for j := range sorted {
			sMap[sorted[j]] = j
		}

		sum := 1

		for j := 0; j < n-1; j++ {
			if sMap[ls[j+1]] - sMap[ls[j]] != 1 {
				sum += 1
			}
		}

		if sum <= k {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

var (
	sc *bufio.Scanner
	wr *bufio.Writer
)

func init() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	wr = bufio.NewWriter(os.Stdout)
}

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

package main

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

var _, _, _ = main, rw, do

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

func rw(r io.Reader, w io.Writer) {
	var t int
	var n, k int
	a := make([]int, 1e5+5)
	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		fmt.Fscan(r, &n, &k)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &a[i])
		}
		w1 := do(n, k, a[:n])
		if w1 {
			fmt.Fprint(w, "Yes")

		} else {
			fmt.Fprint(w, "No")

		}
		fmt.Fprintln(w)
	}
}

func do(n, k int, a []int) bool {
	b := make([]int, len(a))
	for i := range a {
		b[i] = i
	}
	sort.Slice(b, func(i, j int) bool { return a[b[i]] < a[b[j]] })
	r := 0
	for i := range b {
		if i == 0 || b[i]-b[i-1] != 1 {
			r++
		}
	}
	return r <= k
}

package main

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

/*
8
1 1
1
2 1
4 2
2 1
2 4
2 2
3 2
3 1
2 1 4
3 1
1 2 3
3 2
2 1 4
3 2
4 1 2
---
YES
NO
YES
YES
NO
YES
NO
YES
*/

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

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

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

		for i := range a {
			scanf("%d", &a[i])
			sorted[i] = a[i]
		}
		scanf("\n")

		sort.Ints(sorted)

		subArrCnt := 0

		for i := 0; i < len(a); {
			num := a[i]

			j := sort.SearchInts(sorted, num)

			for i < len(a) && j < len(sorted) {
				if a[i] == sorted[j] {
					i++
					j++

					if i == n || j == n {
						subArrCnt++
					}
				} else if a[i] != sorted[j] {
					subArrCnt++
					break
				}
			}
		}

		if subArrCnt <= k {
			fmt.Fprintln(writer, "YES")
		} else {
			fmt.Fprintln(writer, "NO")
		}
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int64) int64 {
	quot := num / div
	if num%div != 0 {
		quot++
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	minimum := nums[0]
	for _, num := range nums {
		if num < minimum {
			minimum = num
		}
	}
	return minimum
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	maximum := nums[0]
	for _, num := range nums {
		if num > maximum {
			maximum = num
		}
	}
	return maximum
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

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

var iost *Iost

type Iost struct {
	Scanner *bufio.Scanner
	Writer  *bufio.Writer
}

func NewIost(fp io.Reader, wfp io.Writer) *Iost {
	const BufSize = 1000000
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, BufSize), BufSize)
	return &Iost{Scanner: scanner, Writer: bufio.NewWriter(wfp)}
}

func (i *Iost) Text() string {
	if !i.Scanner.Scan() {
		panic("scan failed")
	}
	return i.Scanner.Text()
}

func (i *Iost) Atoi(s string) int                 { x, _ := strconv.Atoi(s); return x }
func (i *Iost) GetNextInt() int                   { return i.Atoi(i.Text()) }
func (i *Iost) Atoi64(s string) int64             { x, _ := strconv.ParseInt(s, 10, 64); return x }
func (i *Iost) GetNextInt64() int64               { return i.Atoi64(i.Text()) }
func (i *Iost) Atof64(s string) float64           { x, _ := strconv.ParseFloat(s, 64); return x }
func (i *Iost) GetNextFloat64() float64           { return i.Atof64(i.Text()) }
func (i *Iost) Print(x ...interface{})            { fmt.Fprint(i.Writer, x...) }
func (i *Iost) Printf(s string, x ...interface{}) { fmt.Fprintf(i.Writer, s, x...) }
func (i *Iost) Println(x ...interface{})          { fmt.Fprintln(i.Writer, x...) }
func isLocal() bool                               { return os.Getenv("I") == "IronMan" }

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	if isLocal() {
		fp, _ = os.Open(os.Getenv("END_GAME"))
	}
	iost = NewIost(fp, wfp)
	defer func() {
		if isLocal() {
			iost.Println(recover())
		}
		iost.Writer.Flush()
	}()
	solve()
	for i := 0; isLocal() && i < 100; i++ {
		iost.Println("-----------------------------------")
		solve()
	}
}

func solve() {
	t := iost.GetNextInt()
	for t > 0 {
		t--
		func() {
			n := iost.GetNextInt()
			k := iost.GetNextInt()
			num := make([]int, n)
			numSort := make([]int, n)
			numPos := make(map[int]int)
			minK := 0
			for i := 0; i < n; i++ {
				num[i] = iost.GetNextInt()
				numSort[i] = num[i]
				numPos[num[i]] = i
			}
			sort.Ints(numSort)
			for i := 0; i < n; {
				j := numPos[numSort[i]]
				for i <= n && j <= n {
					if i == n || j == n || numSort[i] != num[j] {
						minK++
						break
					} else {
						i++
						j++
					}
				}
			}
			// iost.Println(minK, k)
			ret := "NO"
			if minK <= k {
				ret = "YES"
			}
			iost.Println(ret)
		}()
	}
}

package main

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

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

	var T, n, k int
	fmt.Fscanf(r, "%d\n", &T)
	for t := 0; t < T; t++ {
		fmt.Fscanf(r, "%d %d\n", &n, &k)
		arr := make([]int, n)
		pos := make(map[int]int)

		for i := 0; i < n; i++ {
			fmt.Fscanf(r, "%d", &arr[i])
			pos[arr[i]] = i
		}
		fmt.Fscanf(r, "\n")

		sort.Ints(arr)

		for i := 0; i < len(arr); {
			v := pos[arr[i]]
			k--
			for i++; i < len(arr) && pos[arr[i]] == v+1; i++ {
				v = pos[arr[i]]
			}
		}

		if k >= 0 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

package main

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

var in = NewIn()
var out = NewOut()

func main() {
	defer out.flush()

	tests()
	// solve()
}

type pair struct {
	first  int
	second int
}

/* --- Solution B --- */
func solve() {
	n := in.nextInt()
	k := in.nextInt()

	ans := 1
	arr := make([]int, n)
	sort_arr := make([]int, n)
	for i:=0; i < n; i++{
		arr[i] = in.nextInt()
		sort_arr[i] = arr[i]
	}

	sort.Slice(sort_arr, func(i, j int) bool {
		return sort_arr[i] < sort_arr[j]
	})
	fmt.Println(sort_arr, arr)
	M := make(map[int]int)
	for i, val := range sort_arr{
		M[val] = i
	}
	for i:=1; i < n; i ++{
		if arr[i] < arr[i-1] {
			ans ++
		}else if M[arr[i]] - M[arr[i-1]] != 1{
			ans ++
		}
	}
	if ans <= k{
		out.println("Yes")
	}else{
		out.println("No")
	}
}

func tests() {
	tt := in.nextInt()
	for ; tt > 0; tt-- {
		solve()
	}
}

/* --- I/O --- */
type In struct {
	scanner *bufio.Scanner
}

func NewIn() *In {
	in := In{bufio.NewScanner(os.Stdin)}
	in.scanner.Split(bufio.ScanWords)
	return &in
}

func (in *In) nextInt() int {
	in.scanner.Scan()
	i, _ := strconv.Atoi(in.scanner.Text())
	return i
}

func (in *In) nextLong() int64 {
	in.scanner.Scan()
	i, _ := strconv.ParseInt(in.scanner.Text(), 10, 64)
	return i
}

func (in *In) next() string {
	in.scanner.Scan()
	return in.scanner.Text()
}

type Out struct {
	writer *bufio.Writer
}

func NewOut() *Out {
	out := Out{bufio.NewWriter(os.Stdout)}
	return &out
}

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

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

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

func (out *Out) flush() {
	out.writer.Flush()
}

package main

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

var in = NewIn()
var out = NewOut()

func main() {
	defer out.flush()

	tests()
	// solve()
}

type pair struct {
	first  int
	second int
}

/* --- Solution B --- */
func solve() {
	n := in.nextInt()
	k := in.nextInt()

	ans := 1
	arr := make([]int, n)
	sort_arr := make([]int, n)
	for i:=0; i < n; i++{
		arr[i] = in.nextInt()
		sort_arr[i] = arr[i]
	}

	sort.Slice(sort_arr, func(i, j int) bool {
		return i < j
	})
	M := make(map[int]int)
	for i, val := range(sort_arr){
		M[val] = i
	}
	for i:=1; i < n; i ++{
		if arr[i] < arr[i-1] {
			ans ++
		}else if(M[arr[i]] - M[arr[i-1]] != 1){
			ans ++
		}
	}
	if ans <= k{
		out.println("Yes")
	}else{
		out.println("No")
	}
}

func tests() {
	tt := in.nextInt()
	for ; tt > 0; tt-- {
		solve()
	}
}

/* --- I/O --- */
type In struct {
	scanner *bufio.Scanner
}

func NewIn() *In {
	in := In{bufio.NewScanner(os.Stdin)}
	in.scanner.Split(bufio.ScanWords)
	return &in
}

func (in *In) nextInt() int {
	in.scanner.Scan()
	i, _ := strconv.Atoi(in.scanner.Text())
	return i
}

func (in *In) nextLong() int64 {
	in.scanner.Scan()
	i, _ := strconv.ParseInt(in.scanner.Text(), 10, 64)
	return i
}

func (in *In) next() string {
	in.scanner.Scan()
	return in.scanner.Text()
}

type Out struct {
	writer *bufio.Writer
}

func NewOut() *Out {
	out := Out{bufio.NewWriter(os.Stdout)}
	return &out
}

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

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

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

func (out *Out) flush() {
	out.writer.Flush()
}

package main

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

var in = NewIn()
var out = NewOut()

func main() {
	defer out.flush()

	tests()
	// solve()
}

type pair struct {
	first  int
	second int
}

/* --- Solution B --- */
func solve() {
	n := in.nextInt()
	k := in.nextInt()

	ans := 1
	arr := make([]int, n)
	for i:=0; i < n; i++{
		arr[i] = in.nextInt()
	}
	for i:=1; i < n; i ++{
		if arr[i] < arr[i-1]{
			ans ++
		}
	}
	if ans <= k{
		out.println("Yes")
	}else{
		out.println("No")
	}
}

func tests() {
	tt := in.nextInt()
	for ; tt > 0; tt-- {
		solve()
	}
}

/* --- I/O --- */
type In struct {
	scanner *bufio.Scanner
}

func NewIn() *In {
	in := In{bufio.NewScanner(os.Stdin)}
	in.scanner.Split(bufio.ScanWords)
	return &in
}

func (in *In) nextInt() int {
	in.scanner.Scan()
	i, _ := strconv.Atoi(in.scanner.Text())
	return i
}

func (in *In) nextLong() int64 {
	in.scanner.Scan()
	i, _ := strconv.ParseInt(in.scanner.Text(), 10, 64)
	return i
}

func (in *In) next() string {
	in.scanner.Scan()
	return in.scanner.Text()
}

type Out struct {
	writer *bufio.Writer
}

func NewOut() *Out {
	out := Out{bufio.NewWriter(os.Stdout)}
	return &out
}

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

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

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

func (out *Out) flush() {
	out.writer.Flush()
}

package main

import "fmt"

func main()  {
	var T, n, k int
	fmt.Scanf("%d\n", &T)
	for ;T > 0; T--{
		fmt.Scanf("%d%d\n", &n, &k)
		ans := 1
		arr := make([]int, n)
		for i:=0; i < n; i++{
			if i == n - 1 {
				fmt.Scanf("%d\n", &arr[i])
			}else{
				fmt.Scanf("%d", &arr[i])
			}
		}
		for i:=1; i < n; i ++{
			if arr[i] < arr[i-1]{
				ans ++
			}
		}
		fmt.Println(n, k, arr)
		if ans == k{
			fmt.Println("Yes")
		}else{
			fmt.Println("No")
		}
	}
}

package main

import "fmt"

func main()  {
	var T, n, k int
	fmt.Scanf("%d\n", &T)
	for ;T > 0; T--{
		fmt.Scanf("%d %d\n", &n, &k)
		ans := 1
		arr := make([]int, n)
		for i:=0; i < n; i++{
			if i == n - 1 {
				fmt.Scanf("%d\n", &arr[i])
			}else{
				fmt.Scanf("%d ", &arr[i])
			}
		}
		for i:=1; i < n; i ++{
			if arr[i] < arr[i-1]{
				ans ++
			}
		}
		if ans == k{
			fmt.Println("Yes")
		}else{
			fmt.Println("No")
		}
	}

}

package main

import "fmt"

func main()  {
	var T, n, k int
	fmt.Scanf("%d\n", &T)
	for ;T > 0; T--{
		fmt.Scanf("%d%d\n", &n, &k)
		ans := 1
		arr := make([]int, n)
		for i:=0; i < n; i++{
			fmt.Scanf("%d", &arr[i])
		}
		//fmt.Scanf("\n")
		for i:=1; i < n; i ++{
			if arr[i] < arr[i-1]{
				ans ++
			}
		}
		if ans == k{
			fmt.Println("Yes")
		}else{
			fmt.Println("No")
		}
	}

}

package main

import "fmt"

func main()  {
	var T, n, k int
	fmt.Scanf("%d\n", &T)
	for ;T > 0; T--{
		fmt.Scanf("%d %d\n", &n, &k)
		ans := 1
		arr := make([]int, n)
		for i:=0; i < n; i++{
			fmt.Scanf("%d", &arr[i])
		}
		//fmt.Scanf("\n")
		for i:=1; i < n; i ++{
			if arr[i] < arr[i-1]{
				ans ++
			}
		}
		if ans == k{
			fmt.Println("Yes")
		}else{
			fmt.Println("No")
		}
	}

}

package main

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

func main()  {
	r := bufio.NewReaderSize(os.Stdin, 1024*1024)
	var T, n, k int
	fmt.Fscanf(r, "%d\n", &T)
	for ;T > 0; T--{
		fmt.Fscanf(r, "%d %d", &n, &k)
		ans := 1
		arr := make([]int, n)
		for i:=0; i < n; i++{
			fmt.Fscanf(r,"%d", &arr[i])
		}
		for i:=1; i < n; i ++{
			if arr[i] < arr[i-1]{
				ans ++
			}
		}
		if ans == k{
			fmt.Println("Yes")
		}else{
			fmt.Println("No")
		}
	}

}

package main

import "fmt"

func main()  {
	var T, n, k int
	fmt.Scanf("%d", &T)
	for ;T > 0; T--{
		fmt.Scanf("%d %d", &n, &k)
		ans := 1
		arr := make([]int, n)
		for i:=0; i < n; i++{
			fmt.Scanf("%d", &arr[i])
		}
		for i:=1; i < n; i ++{
			if arr[i] < arr[i-1]{
				ans ++
			}
		}
		if ans == k{
			fmt.Println("Yes")
		}else{
			fmt.Println("No")
		}
	}

}

package main

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

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

func solve() {
	n, k := getI(), getI()
	slice := NewSlice(getInts(n)...)

	var changes int64
	result := "Yes"
	for i := 0; i < int(n)-1; i++ {
		num1, num2 := slice.idx[i], slice.idx[i+1]
		cond2 := num2-num1 > 1 && (num1 != i && num2 != i+1)
		if num2 < num1 || cond2 {
			changes++
		}
		if changes > k {
			result = "No"
			break
		}
	}

	out(result)
}

// http://github.com/KadoBOT (me@ricardoambrogi.com)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	for i := getI(); i > 0; i-- {
		solve()
	}
	out()
}

// !------- 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 ceil(n, d int64) int64 {
	return (n + d - 1) / d
}

func nequal(a, b []int64) bool {
	if len(a) != len(b) {
		return false
	}
	for i, v := range a {
		if v != b[i] {
			return false
		}
	}
	return true
}

func nsum(data ...int64) int64 {
	var res int64
	for _, n := range data {
		res += n
	}
	return res
}

func njoin(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
}

// !------- FORMULAS -------!
func gcd(a, b int64) int64 {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

func lcm(a, b int64, integers ...int64) int64 {
	result := a * b / gcd(a, b)

	for i := 0; i < len(integers); i++ {
		result = lcm(result, integers[i])
	}

	return result
}

func sieve(n int64) []int64 {
	integers := make([]bool, n+1)
	for i := int64(2); i < n+1; i++ {
		integers[i] = true
	}

	for p := int64(2); p*p <= n; p++ {
		if integers[p] == true {
			for i := p * 2; i <= n; i += p {
				integers[i] = false
			}
		}
	}

	var primes []int64
	for p := int64(2); p <= n; p++ {
		if integers[p] == true {
			primes = append(primes, p)
		}
	}

	return primes
}

// !-------- Interfaces Impl -------!

type Slice struct {
	arr []int64
	idx []int
}

func NewSlice(data ...int64) *Slice {
	s := &Slice{arr: data, idx: make([]int, len(data))}
	for i := range s.idx {
		s.idx[i] = i
	}

	sort.Sort(s)

	return s
}

func (s Slice) Swap(i, j int) {
	s.arr[i], s.arr[j] = s.arr[j], s.arr[i]
	s.idx[i], s.idx[j] = s.idx[j], s.idx[i]
}

func (s Slice) Len() int           { return len(s.arr) }
func (s Slice) Less(i, j int) bool { return s.arr[i] < s.arr[j] }

package main

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

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

func solve() {
	n, k := getI(), getI()
	slice := NewSlice(getInts(n)...)

	var changes int64
	result := "Yes"
	for i := 0; i < int(n)-1; i++ {
		num1, num2 := slice.idx[i], slice.idx[i+1]
		if num2-num1 != 1 {
			changes++
		}
		if changes > k {
			result = "No"
			break
		}
	}

	out(result)
}

// http://github.com/KadoBOT (me@ricardoambrogi.com)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	for i := getI(); i > 0; i-- {
		solve()
	}
	out()
}

// !------- 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 ceil(n, d int64) int64 {
	return (n + d - 1) / d
}

func nequal(a, b []int64) bool {
	if len(a) != len(b) {
		return false
	}
	for i, v := range a {
		if v != b[i] {
			return false
		}
	}
	return true
}

func nsum(data ...int64) int64 {
	var res int64
	for _, n := range data {
		res += n
	}
	return res
}

func njoin(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
}

// !------- FORMULAS -------!
func gcd(a, b int64) int64 {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

func lcm(a, b int64, integers ...int64) int64 {
	result := a * b / gcd(a, b)

	for i := 0; i < len(integers); i++ {
		result = lcm(result, integers[i])
	}

	return result
}

func sieve(n int64) []int64 {
	integers := make([]bool, n+1)
	for i := int64(2); i < n+1; i++ {
		integers[i] = true
	}

	for p := int64(2); p*p <= n; p++ {
		if integers[p] == true {
			for i := p * 2; i <= n; i += p {
				integers[i] = false
			}
		}
	}

	var primes []int64
	for p := int64(2); p <= n; p++ {
		if integers[p] == true {
			primes = append(primes, p)
		}
	}

	return primes
}

// !-------- Interfaces Impl -------!

type Slice struct {
	arr []int64
	idx []int
}

func NewSlice(data ...int64) *Slice {
	s := &Slice{arr: data, idx: make([]int, len(data))}
	for i := range s.idx {
		s.idx[i] = i
	}

	sort.Sort(s)

	return s
}

func (s Slice) Swap(i, j int) {
	s.arr[i], s.arr[j] = s.arr[j], s.arr[i]
	s.idx[i], s.idx[j] = s.idx[j], s.idx[i]
}

func (s Slice) Len() int           { return len(s.arr) }
func (s Slice) Less(i, j int) bool { return s.arr[i] < s.arr[j] }

package main

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

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

func solve() {
	n, k := getI(), getI()

	twosG := n / k
	onesG := k - twosG

	arr := getInts(n)
	cur := arr[0]

	res := "Yes"
	for _, n := range arr[1:] {
		if n < cur {
			if onesG <= 0 {
				res = "No"
				break
			}
			onesG--
		}
		cur = n
	}

	out(res)
}

// http://github.com/KadoBOT (me@ricardoambrogi.com)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)

	for i := getI(); i > 0; i-- {
		solve()
	}
	out()
}

// !------- 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 ceil(n, d int64) int64 {
	return (n + d - 1) / d
}

func nsort(data ...int64) []int64 {
	int64AsIntValues := make([]int, len(data))

	for i, val := range data {
		int64AsIntValues[i] = int(val)
	}
	sort.Ints(int64AsIntValues)

	for i, val := range int64AsIntValues {
		data[i] = int64(val)
	}

	return data
}

func nsum(data ...int64) int64 {
	var res int64
	for _, n := range data {
		res += n
	}
	return res
}

func njoin(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
}

// !------- FORMULAS -------!
func gcd(a, b int64) int64 {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

func lcm(a, b int64, integers ...int64) int64 {
	result := a * b / gcd(a, b)

	for i := 0; i < len(integers); i++ {
		result = lcm(result, integers[i])
	}

	return result
}

func sieve(n int64) []int64 {
	integers := make([]bool, n+1)
	for i := int64(2); i < n+1; i++ {
		integers[i] = true
	}

	for p := int64(2); p*p <= n; p++ {
		if integers[p] == true {
			for i := p * 2; i <= n; i += p {
				integers[i] = false
			}
		}
	}

	var primes []int64
	for p := int64(2); p <= n; p++ {
		if integers[p] == true {
			primes = append(primes, p)
		}
	}

	return primes
}

package main

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

var in = NewIn()
var out = NewOut()

func main() {
	defer out.flush()

	tests()
	// solve()
}

/* --- Solution B --- */
func solve() {
	n := in.nextInt()
	k := in.nextInt()

	nums := make([]int, n)

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

	q := 0
	for i := 0; i < n-1; i++ {
		if nums[i] > nums[i+1] {
			q++
		}
	}

	if q < k {
		out.println("Yes")
	} else {
		out.println("No")
	}
}

func tests() {
	tt := in.nextInt()
	for ; tt > 0; tt-- {
		solve()
	}
}

/* --- I/O --- */
type In struct {
	scanner *bufio.Scanner
}

func NewIn() *In {
	in := In{bufio.NewScanner(os.Stdin)}
	in.scanner.Split(bufio.ScanWords)
	return &in
}

func (in *In) nextInt() int {
	in.scanner.Scan()
	i, _ := strconv.Atoi(in.scanner.Text())
	return i
}

func (in *In) nextLong() int64 {
	in.scanner.Scan()
	i, _ := strconv.ParseInt(in.scanner.Text(), 10, 64)
	return i
}

func (in *In) next() string {
	in.scanner.Scan()
	return in.scanner.Text()
}

type Out struct {
	writer *bufio.Writer
}

func NewOut() *Out {
	out := Out{bufio.NewWriter(os.Stdout)}
	return &out
}

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

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

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

func (out *Out) flush() {
	out.writer.Flush()
}

package main

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

var in = NewIn()
var out = NewOut()

func main() {
	defer out.flush()

	tests()
	// solve()
}

/* --- Solution B --- */
func solve() {
	n := in.nextInt()
	k := in.nextInt()

	min := math.MaxInt32
	indexMin := -1
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		v := in.nextInt()
		nums[i] = v
		if v < min {
			min = v
			indexMin = i
		}
	}

	if k > 2 {
		out.println("Yes")
		return
	} else if k == 1 {
		for i := 0; i < n-1; i++ {
			if nums[i] > nums[i+1] {
				out.println("No")
				return
			}
		}
		out.println("Yes")
	} else if k == 2 {
		for i := 0; i < n-1; i++ {
			if nums[(indexMin+i)%n] > nums[(indexMin+i+1)%n] {
				out.println("No")
				return
			}
		}
		out.println("Yes")
	}
}

func tests() {
	tt := in.nextInt()
	for ; tt > 0; tt-- {
		solve()
	}
}

/* --- I/O --- */
type In struct {
	scanner *bufio.Scanner
}

func NewIn() *In {
	in := In{bufio.NewScanner(os.Stdin)}
	in.scanner.Split(bufio.ScanWords)
	return &in
}

func (in *In) nextInt() int {
	in.scanner.Scan()
	i, _ := strconv.Atoi(in.scanner.Text())
	return i
}

func (in *In) nextLong() int64 {
	in.scanner.Scan()
	i, _ := strconv.ParseInt(in.scanner.Text(), 10, 64)
	return i
}

func (in *In) next() string {
	in.scanner.Scan()
	return in.scanner.Text()
}

type Out struct {
	writer *bufio.Writer
}

func NewOut() *Out {
	out := Out{bufio.NewWriter(os.Stdout)}
	return &out
}

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

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

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

func (out *Out) flush() {
	out.writer.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for c:=0;c<t;c++{
		var n, k int
		fmt.Fscan(in,&n,&k)
		l := []int{}
		or := []int{}
		for i:=1;i<=n;i++{
			var m int
			fmt.Fscan(in,&m)
			l = append(l,m)
			or = append(or,m)
		}
		sort.Ints(l)
		mp := map[int]int{}
		for i:=0;i<n-1;i++{
			mp[l[i]]=l[i+1]
		}
		cnt :=1
		for i:=0;i<n-1;i++{
			if mp[or[i]]!=or[i+1]{
				cnt++
			}
		}
		if(cnt>k){
			fmt.Fprintln(out,"No")
		}else{
			fmt.Fprintln(out,"Yes")
		}
	}

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for c:=0;c<t;c++{
		var n, k int
		fmt.Fscan(in,&n,&k)
		l := []int{}
		or := []int{}
		for i:=1;i<=n;i++{
			var m int
			fmt.Fscan(in,&m)
			l = append(l,m)
			or = append(or,m)
		}
		sort.Ints(l)
		mp := map[int]int{}
		for i:=0;i<n-1;i++{
			mp[l[i]]=l[i+1]
		}
		cnt :=1
		for i:=2;i<n-1;i++{
			if mp[or[i]]!=or[i+1]{
				cnt++
			}
		}
		if(cnt>k){
			fmt.Fprintln(out,"No")
		}else{
			fmt.Fprintln(out,"Yes")
		}
	}

}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for c:=0;c<t;c++{
		var n, k int
		fmt.Fscan(in,&n,&k)
		l := [300005]int{}
		for i:=1;i<=n;i++{
			fmt.Fscan(in,&l[i])
		}
		cnt :=1
		for i:=2;i<=n;i++{
			if l[i]<l[i-1]{
				cnt++
			}
		}
		if(cnt>k){
			fmt.Fprintln(out,"No")
		}else{
			fmt.Fprintln(out,"Yes")
		}
	}

}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var caseNum int
	fmt.Fscan(r, &caseNum)
	for c := 0; c < caseNum; c++ {
		var n, k int
		fmt.Fscan(r, &n, &k)
		arr := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &arr[i])
		}
		solve1557E(arr, k)
	}
}
func solve1557E(arr []int, k int) {
	n := len(arr)
	var pair int = 0
	for i := 1; i < n; i++ {
		if arr[i] < arr[i-1] {
			pair++
		}
	}
	pair++
	if n >= k && pair <= k {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var caseNum int
	fmt.Fscan(r, &caseNum)
	for c := 0; c < caseNum; c++ {
		var n, k int
		fmt.Fscan(r, &n, &k)
		arr := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &arr[i])
		}
		solve1557E(arr, k)
	}
}
func solve1557E(arr []int, k int) {
	n := len(arr)
	var pair int = 0
	for i := 1; i < n; i++ {
		if arr[i] < arr[i-1] {
			pair++
		}
	}
	if n > 1 && arr[0] > arr[1] {
		pair++
	}
	if n >= k && pair <= k {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

package main

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

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

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

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

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

func _int64() int64 {
	s := _string()
	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 _string() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

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

func sol(n, k int64, a []int64) string {
	dec := int64(0)
	for i := 1; i < len(a); i++ {
		if a[i-1] > a[i] {
			dec++
		}
	}
	part := dec + 1
	if k >= part {
		return "Yes"
	}
	return "No"
}

package main

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

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

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

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

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

func _int64() int64 {
	s := _string()
	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 _string() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

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

func sol(n, k int, a []int) string {
	dec := 0
	for i := 1; i < len(a); i++ {
		if a[i] < a[i-1] {
			dec++
		}
	}
	part := dec + 1
	if k >= part {
		return "Yes"
	}
	return "No"
}

package main

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

func main() {

	r := bufio.NewReader(os.Stdin)

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

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

		a := make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Fscan(r, &a[j])
		}

		fmt.Println(solve(a, n, k))
	}
}

func solve(a []int, n, k int) string {
	if k > n {
		return "NO"
	}
	cop := make([]int, n)
	copy(cop, a)
	sort.Ints(cop)

	mp := make(map[int]int)

	for i := 0; i < n; i++ {
		mp[cop[i]] = i
	}

	//612345

	//123456
	var c int

	for j := 0; j < len(a);  j++{
		e := a[j]
		pos := mp[e]

		if pos >= n - 1 {
			c++
			continue
		}
		k1 := j
		k2 := pos

		for ;k1 < n && k2 < n; {
			if a[k1] != cop[k2] {
				c++
				break
			}
			k1++
			k2++
		}
		if k1 == n {
			c++
		}
		j = k1 - 1
	}

	if c <= k {
		return "YES"
	}
	return "NO"
}

package main

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

func main() {

	r := bufio.NewReader(os.Stdin)

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

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

		a := make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Fscan(r, &a[j])
		}

		fmt.Println(solve(a, n, k))
	}
}

func solve(a []int, n, k int) string {
	cop := make([]int, n)
	copy(cop, a)
	sort.Ints(cop)

	mp := make(map[int]int)

	for i := 0; i < n; i++ {
		mp[cop[i]] = i
	}

	//12345

	//12345
	var c int

	for j := 0; j < len(a);  {
		e := a[j]
		pos := mp[e]

		if pos >= n - 1 {
			c++
			j++
			continue
		}

		var i int
		var d int
		for i, d = j + 1, pos + 1; i < n && d < n; i, d = i + 1, d + 1  {
			if a[i] == cop[d] {
				continue
			}
			c++
			break
		}
		if i == n {
			c++
		}
		j = i
	}

	if c == k {
		return "YES"
	}
	return "NO"
}

package main

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

func main() {
	defer wr.Flush()

	t := scanInt()

	for i := 0; i < t; i++ {
		n := scanInt()
		k := scanInt()

		ls := make([]int, n)
		for j := 0; j < n; j++ {
			ls[j] = scanInt()
		}

		sum := 1

		for j := 0; j < n-1; j++ {
			if ls[j] > ls[j+1] {
				sum += 1
			}
		}

		if sum <= k {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

var (
	sc *bufio.Scanner
	wr *bufio.Writer
)

func init() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	wr = bufio.NewWriter(os.Stdout)
}

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

package main

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

var _, _, _ = main, rw, do

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

func rw(r io.Reader, w io.Writer) {
	var t, n, k int
	a := make([]int, 1e5+5)

	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		fmt.Fscan(r, &n)
		fmt.Fscan(r, &k)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &a[i])
		}
		w1 := do(n, k, a[:n])
		if w1 {
			fmt.Fprintf(w, "Yes")
		} else {
			fmt.Fprintf(w, runtime.GOARCH)
		}
		fmt.Fprintln(w)
	}
}

func do(n, k int, a []int) bool {
	return false
}


Bash likes playing with arrays. He has an array a1, a2, ... an of n integers. He likes to guess the greatest common divisor (gcd) of different segments of the array. Of course, sometimes the guess is not correct. However, Bash will be satisfied if his guess is almost correct.Suppose he guesses that the gcd of the elements in the range [l, r] of a is x. He considers the guess to be almost correct if he can change at most one element in the segment such that the gcd of the segment is x after making the change. Note that when he guesses, he doesn't actually change the array — he just wonders if the gcd of the segment can be made x. Apart from this, he also sometimes makes changes to the array itself.Since he can't figure it out himself, Bash wants you to tell him which of his guesses are almost correct. Formally, you have to process q queries of one of the following forms:  1 l r x — Bash guesses that the gcd of the range [l, r] is x. Report if this guess is almost correct.  2 i y — Bash sets ai to y. Note: The array is 1-indexed.

The first line contains an integer n (1 ≤ n ≤ 5·105)  — the size of the array. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109)  — the elements of the array. The third line contains an integer q (1 ≤ q ≤ 4·105)  — the number of queries. The next q lines describe the queries and may have one of the following forms:   1 l r x (1 ≤ l ≤ r ≤ n, 1 ≤ x ≤ 109).  2 i y (1 ≤ i ≤ n, 1 ≤ y ≤ 109).  Guaranteed, that there is at least one query of first type.

For each query of first type, output "YES" (without quotes) if Bash's guess is almost correct and "NO" (without quotes) otherwise.

NoteIn the first sample, the array initially is {2, 6, 3}. For query 1, the first two numbers already have their gcd as 2.For query 2, we can achieve a gcd of 3 by changing the first element of the array to 3. Note that the changes made during queries of type 1 are temporary and do not get reflected in the array. After query 3, the array is now {9, 6, 3}. For query 4, no matter which element you change, you cannot get the gcd of the range to be 2.

package main

import (
	"bufio"
	"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 gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

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

	n := readInt()
	vals := make([][]int, 30)
	vals[0] = make([]int, n)
	for i := range vals[0] {
		vals[0][i] = readInt()
	}
	for i, j := 1, n/2; j > 0; i, j = i+1, j/2 {
		vals[i] = make([]int, j)
		for k := range vals[i] {
			vals[i][k] = gcd(vals[i-1][k*2], vals[i-1][k*2+1])
		}
	}

	lrGCD := func(l, r int) int {
		res := -1
		for l < r {
			lvl := uint(0)
			for r&(1<<lvl) == 0 && r-(1<<(lvl+1)) >= l {
				lvl++
			}
			cur := vals[lvl][(r>>lvl)-1]
			if res == -1 {
				res = cur
			} else {
				res = gcd(res, cur)
			}
			r -= 1 << lvl
		}
		return res
	}

	query1 := func() bool {
		l, r, x := readInt()-1, readInt(), readInt()
		if gcd(lrGCD(l, r), x) == x {
			return true
		}
		for r-l > 1 {
			mid := l + (r-l)/2
			if gcd(lrGCD(l, mid), x) == x {
				l = mid
			} else if gcd(lrGCD(mid, r), x) == x {
				r = mid
			} else {
				return false
			}
		}
		return true
	}

	for q := readInt(); q > 0; q-- {
		switch readInt() {
		case 1:
			if query1() {
				out.WriteString("YES\n")
			} else {
				out.WriteString("NO\n")
			}
		case 2:
			i, y := readInt()-1, readInt()
			vals[0][i] = y
			for lvl := 1; lvl < len(vals) && i/2 < len(vals[lvl]); lvl++ {
				i /= 2
				vals[lvl][i] = gcd(vals[lvl-1][i*2], vals[lvl-1][i*2+1])
			}
		}
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
type seg []struct{ l, r, g int }

func (seg) gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func (t seg) _pushUp(o int) { t[o].g = t.gcd(t[o<<1].g, t[o<<1|1].g) }

func (t seg) _build(a []int, o, l, r int) {
	t[o].l, t[o].r = l, r
	if l == r {
		t[o].g = a[l-1]
		return
	}
	m := (l + r) >> 1
	t._build(a, o<<1, l, m)
	t._build(a, o<<1|1, m+1, r)
	t._pushUp(o)
}

func (t seg) _update(o, i, v int) {
	if t[o].l == t[o].r {
		t[o].g = v
		return
	}
	if i <= (t[o].l+t[o].r)>>1 {
		t._update(o<<1, i, v)
	} else {
		t._update(o<<1|1, i, v)
	}
	t._pushUp(o)
}

func (t seg) _query(o, l, r, v int) (c int8) {
	if t[o].g%v == 0 {
		return
	}
	if t[o].l == t[o].r {
		return 1
	}
	m := (t[o].l + t[o].r) >> 1
	if l <= m {
		c += t._query(o<<1, l, r, v)
	}
	if c <= 1 && r > m {
		c += t._query(o<<1|1, l, r, v)
	}
	return
}

func (t seg) init(a []int)           { t._build(a, 1, 1, len(a)) }
func (t seg) update(i, v int)        { t._update(1, i, v) }
func (t seg) query(l, r, v int) bool { return t._query(1, l, r, v) <= 1 }

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

	var n, q, op, l, r, v int
	Fscan(in, &n)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	t := make(seg, 4*n)
	t.init(a)
	for Fscan(in, &q); q > 0; q-- {
		if Fscan(in, &op, &l, &r); op == 1 {
			if Fscan(in, &v); t.query(l, r, v) {
				Fprintln(out, "YES")
			} else {
				Fprintln(out, "NO")
			}
		} else {
			t.update(l, r)
		}
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go

var buf = make([]byte, 4096)
var _i = len(buf)

func rc() byte {
	if _i == len(buf) {
		os.Stdin.Read(buf)
		_i = 0
	}
	b := buf[_i]
	_i++
	return b
}
func ri() (x int) {
	b := rc()
	for ; '0' > b; b = rc() {
	}
	for ; '0' <= b; b = rc() {
		x = x*10 + int(b&15)
	}
	return
}

type seg []struct{ l, r, g int }

func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func (t seg) _pushUp(o int) { t[o].g = gcd(t[o<<1].g, t[o<<1|1].g) }

func (t seg) _build(o, l, r int) {
	t[o].l, t[o].r = l, r
	if l == r {
		t[o].g = ri()
		return
	}
	m := (l + r) >> 1
	t._build(o<<1, l, m)
	t._build(o<<1|1, m+1, r)
	t._pushUp(o)
}

func (t seg) _update(o, i int) {
	if t[o].l == t[o].r {
		t[o].g = ri()
		return
	}
	if i <= (t[o].l+t[o].r)>>1 {
		t._update(o<<1, i)
	} else {
		t._update(o<<1|1, i)
	}
	t._pushUp(o)
}

func (t seg) _query(o, l, r, v int) (c int8) {
	if t[o].g%v == 0 {
		return
	}
	if t[o].l == t[o].r {
		return 1
	}
	m := (t[o].l + t[o].r) >> 1
	if l <= m {
		c += t._query(o<<1, l, r, v)
	}
	if c <= 1 && r > m {
		c += t._query(o<<1|1, l, r, v)
	}
	return
}

func (t seg) init(n int)             { t._build(1, 1, n) }
func (t seg) update(i int)           { t._update(1, i) }
func (t seg) query(l, r, v int) bool { return t._query(1, l, r, v) <= 1 }

func main() {
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := ri()
	t := make(seg, 4*n)
	t.init(n)
	for q := ri(); q > 0; q-- {
		if ri() == 1 {
			if t.query(ri(), ri(), ri()) {
				Fprintln(out, "YES")
			} else {
				Fprintln(out, "NO")
			}
		} else {
			t.update(ri())
		}
	}
}

package main

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

var scanner *bufio.Scanner
var save = make([]int, 0)
var tree = make([]int, 0)

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	}
	return gcd(y, x%y)
}

func pushup(num int) {
	var lson = num << 1
	var rson = num<<1 | 1
	tree[num] = gcd(tree[lson], tree[rson])
}

func build(num, s, e int) {
	if s == e {
		tree[num] = save[s]
		return
	}
	var mid = (s + e) >> 1
	build(num<<1, s, mid)
	build(num<<1|1, mid+1, e)
	pushup(num)
}

func query(num, s, e, l, r, x int) int {
	// fmt.Println(s, e, l, r)
	if l <= s && r >= e {
		if tree[num]%x == 0 {
			return 0
		}
		var rt = num
		for tree[rt]%x != 0 {
			// fmt.Println("debug", rt, s, e, tree[rt<<1], tree[rt<<1|1])
			if (rt<<1) >= len(tree) || (rt<<1|1) >= len(tree) {
				return 1
			}
			if tree[rt<<1]%x == 0 && tree[rt<<1|1]%x == 0 {
				return 1
			}

			if tree[rt<<1]%x != 0 && tree[rt<<1|1]%x != 0 {
				return 2
			}

			if tree[rt<<1]%x != 0 {
				rt = rt << 1
			} else {
				rt = rt<<1 | 1
			}
		}
		return 0
	}
	var mid = (s + e) >> 1
	if l > mid {
		return query(num<<1|1, mid+1, e, l, r, x)
	} else if r <= mid {
		return query(num<<1, s, mid, l, r, x)
	} else {
		return query(num<<1, s, mid, l, mid, x) + query(num<<1|1, mid+1, e, mid+1, r, x)
	}
}

func update(num, s, e, pos, x int) {
	if s == e {
		tree[num] = x
		return
	}
	var mid = (s + e) >> 1
	if pos <= mid {
		update(num<<1, s, mid, pos, x)
	} else {
		update(num<<1|1, mid+1, e, pos, x)
	}
	pushup(num)
}

func solve() {
	var n = readInt()
	save = make([]int, n+1)
	for i := 1; i <= n; i++ {
		save[i] = readInt()
	}
	tree = make([]int, n<<2)
	build(1, 1, n)
	type OP struct {
		t int
		x int
		y int
		z int
	}
	var q = readInt()
	var ops = make([]OP, q)
	for _, p := range ops {
		p.t = readInt()
		if p.t == 1 {
			p.x, p.y, p.z = readInt(), readInt(), readInt()
			var tans = query(1, 1, n, p.x, p.y, p.z)
			// fmt.Println(tans)
			if tans <= 1 {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		} else {
			p.x, p.y = readInt(), readInt()
			update(1, 1, n, p.x, p.y)
		}
	}
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)

	solve()
}

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

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

package main

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

// github.com/EndlessCheng/codeforces-go
type seg []struct{ l, r, g, h int }

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

func (seg) gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func (t seg) _pushUp(o int) {
	lo, ro := t[o<<1], t[o<<1|1]
	t[o].g = t.gcd(lo.g, ro.g)
	t[o].h = t.max(t.gcd(lo.g, ro.h), t.gcd(lo.h, ro.g))
}

func (t seg) _build(a []int, o, l, r int) {
	t[o].l, t[o].r = l, r
	if l == r {
		t[o].g = a[l-1]
		return
	}
	m := (l + r) >> 1
	t._build(a, o<<1, l, m)
	t._build(a, o<<1|1, m+1, r)
	t._pushUp(o)
}

func (t seg) _update(o, i, v int) {
	if t[o].l == t[o].r {
		t[o].g = v
		return
	}
	if i <= (t[o].l+t[o].r)>>1 {
		t._update(o<<1, i, v)
	} else {
		t._update(o<<1|1, i, v)
	}
	t._pushUp(o)
}

func (t seg) _query(o, l, r int) (int, int) {
	if l <= t[o].l && t[o].r <= r {
		return t[o].g, t[o].h
	}
	m := (t[o].l + t[o].r) >> 1
	if r <= m {
		return t._query(o<<1, l, r)
	}
	if l > m {
		return t._query(o<<1|1, l, r)
	}
	gl, hl := t._query(o<<1, l, r)
	gr, hr := t._query(o<<1|1, l, r)
	return t.gcd(gl, gr), t.max(t.gcd(gl, hr), t.gcd(hl, gr))
}

func (t seg) init(a []int)       { t._build(a, 1, 1, len(a)) }
func (t seg) update(i, v int)    { t._update(1, i, v) }
func (t seg) query(l, r int) int { _, h := t._query(1, l, r); return h }

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

	var n, q, op, l, r, v int
	Fscan(in, &n)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}

	t := make(seg, 4*n)
	t.init(a)
	for Fscan(in, &q); q > 0; q-- {
		if Fscan(in, &op); op == 1 {
			if Fscan(in, &l, &r, &v); t.query(l, r)%v == 0 {
				Fprintln(out, "YES")
			} else {
				Fprintln(out, "NO")
			}
		} else {
			Fscan(in, &l, &v)
			t.update(l, v)
		}
	}
}

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


Little penguin Polo adores integer segments, that is, pairs of integers [l; r] (l ≤ r). He has a set that consists of n integer segments: [l1; r1], [l2; r2], ..., [ln; rn]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 unit to the left or 1 unit to the right, that is transform [l; r] to either segment [l - 1; r], or to segment [l; r + 1].The value of a set of segments that consists of n segments [l1; r1], [l2; r2], ..., [ln; rn] is the number of integers x, such that there is integer j, for which the following inequality holds, lj ≤ x ≤ rj.Find the minimum number of moves needed to make the value of the set of Polo's segments divisible by k.

The first line contains two integers n and k (1 ≤ n, k ≤ 105). Each of the following n lines contain a segment as a pair of integers li and ri ( - 105 ≤ li ≤ ri ≤ 105), separated by a space. It is guaranteed that no two segments intersect. In other words, for any two integers i, j (1 ≤ i < j ≤ n) the following inequality holds, min(ri, rj) < max(li, lj).

In a single line print a single integer — the answer to the problem.

package main

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

func main() {
    var n, k, p, x, r, l int
    re := bufio.NewScanner(os.Stdin)
    re.Split(bufio.ScanWords)
    re.Scan()
    n, _ = strconv.Atoi(re.Text())
    re.Scan()
    k, _ = strconv.Atoi(re.Text())
    w := bufio.NewWriter(os.Stdout)
    for i:=0; i<n; i++ {
		re.Scan()
		l, _ = strconv.Atoi(re.Text())
		re.Scan()
		r, _ = strconv.Atoi(re.Text())
        p += r - l + 1
    }
    x = (k -(p % k))% k
    w.WriteString(strconv.Itoa(int(x))+"\n")
    w.Flush()
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    var n,k int
    fmt.Scan(&n,&k)
    cnt := 0
    for i := 0; i < n; i++ {
        scanner.Scan()
        l, _ := strconv.Atoi(scanner.Text())
        scanner.Scan()
        r, _ := strconv.Atoi(scanner.Text())
        cnt += (r-l+1)
    }
    fmt.Println((k-(cnt%k))%k)
}

// 289A
package main

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

func main() {
	in := bufio.NewScanner(os.Stdin)
	in.Split(bufio.ScanWords)
	var n, k, a, b int
	sum := 0
	fmt.Scan(&n, &k)
	for i := 0; i < n; i++ {
		in.Scan()
		a, _ = strconv.Atoi(in.Text())
		in.Scan()
		b, _ = strconv.Atoi(in.Text())
		sum += (b - a + 1)
	}
	fmt.Print((k - (sum % k)) % k)
}

// 289A-mic_rizal
package main

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

func main() {
    var n, k, x, y, cou int
    z := bufio.NewReader(os.Stdin)
    fmt.Scan(&n, &k)

    for i := 0; i < n; i++ {
        fmt.Fscan(z, &x, &y)
        cou += y - x + 1
    }
    ans := 0
    for cou%k != 0 {
        ans++
        cou++
    }
    fmt.Println(ans)
}

// 289A
package main

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

func main() {
	var n, k, a, b int
	sum := 0
	in := bufio.NewScanner(os.Stdin)
	fmt.Scan(&n, &k)
	for i := 0; i < n; i++ {
		for in.Scan() {
			fmt.Scan(&a, &b)
		}
		sum += (b - a + 1)
		sum = (sum-1)%k + 1
	}
	fmt.Println(k - sum)
}

// 289A
package main

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

func main() {
	var n, k, a, b int
	sum := 0
	in := bufio.NewScanner(os.Stdin)
	in.Split(bufio.ScanWords)
	in.Scan()
	aa, _ := strconv.Atoi(in.Text())
	n, k = aa, aa
	//	fmt.Scan(&n, &k)
	for i := 0; i < n; i++ {
		a, b = aa, aa
		sum += (b - a + 1)
		sum = (sum-1)%k + 1
	}
	fmt.Println(k - sum)
}

// 289A
package main

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

func main() {
	var n, k, a, b int
	sum := 0
	out := bufio.NewWriter(os.Stdout)
	fmt.Scan(&n, &k)
	for i := 0; i < n; i++ {
		fmt.Scan(&a, &b)
		sum += (b - a + 1)
	}
	x := strconv.Itoa((k-(sum%k))%k - 1)
	out.WriteString(x)
}

// 289A
package main

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

func main() {
	var n, k, a, b int
	sum := 0
	in := bufio.NewScanner(os.Stdin)
	in.Split(bufio.ScanWords)
	in.Scan()
	aa, _ := strconv.Atoi(in.Text())
	n, k = aa, aa
	fmt.Scan(&n, &k)
	for i := 0; i < n; i++ {
		for in.Scan() {
			fmt.Scan(&a, &b)
		}
		sum += (b - a + 1)
		sum = (sum-1)%k + 1
	}
	fmt.Println(k - sum)
}

// 289A
package main

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

func main() {
	var n, k, a, b int
	sum := 0
	out := bufio.NewWriter(os.Stdout)
	fmt.Scan(&n, &k)
	for i := 0; i < n; i++ {
		fmt.Scan(&a, &b)
		sum += (b - a + 1)
	}
	x := sum % k
	out.WriteString(strconv.Itoa((k - x) % k))
}

// 289A
package main

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

func main() {
	var n, k, a, b int
	sum := 0
	in := bufio.NewScanner(os.Stdin)
	for in.Scan() {
		fmt.Scan(&n, &k)
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&a, &b)
		sum += (b - a + 1)
		sum = (sum-1)%k + 1
	}
	fmt.Println(k - sum)
}

// 289A
package main

import (
	"fmt"
)

func main() {
	var n, k, a, b int
	sum := 0
	fmt.Scan(&n, &k)
	for i := 0; i < n; i++ {
		fmt.Scan(&a, &b)
		sum += (b - a + 1)
		sum = (sum-1)&k + 1
	}
	fmt.Println(k - 1)
}

// 289A
package main

import (
	"fmt"
)

func main() {
	var n, k, a, b int
	sum := 0
	fmt.Scan(&n, &k)
	for i := 0; i < n; i++ {
		fmt.Scan(&a, &b)
		sum += (b - a + 1)
		sum = (sum-1)&k + 1
	}
	fmt.Println(k - sum)
}