Lindsey Buckingham told Stevie Nicks "Go your own way". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.Consider a hexagonal tiling of the plane as on the picture below.  Nicks wishes to go from the cell marked $$$(0, 0)$$$ to a certain cell given by the coordinates. She may go from a hexagon to any of its six neighbors you want, but there is a cost associated with each of them. The costs depend only on the direction in which you travel. Going from $$$(0, 0)$$$ to $$$(1, 1)$$$ will take the exact same cost as going from $$$(-2, -1)$$$ to $$$(-1, 0)$$$. The costs are given in the input in the order $$$c_1$$$, $$$c_2$$$, $$$c_3$$$, $$$c_4$$$, $$$c_5$$$, $$$c_6$$$ as in the picture below.  Print the smallest cost of a path from the origin which has coordinates $$$(0, 0)$$$ to the given cell.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^{4}$$$). Description of the test cases follows. The first line of each test case contains two integers $$$x$$$ and $$$y$$$ ($$$-10^{9} \le x, y \le 10^{9}$$$) representing the coordinates of the target hexagon. The second line of each test case contains six integers $$$c_1$$$, $$$c_2$$$, $$$c_3$$$, $$$c_4$$$, $$$c_5$$$, $$$c_6$$$ ($$$1 \le c_1, c_2, c_3, c_4, c_5, c_6 \le 10^{9}$$$) representing the six costs of the making one step in a particular direction (refer to the picture above to see which edge is for each value).

For each testcase output the smallest cost of a path from the origin to the given cell.

NoteThe picture below shows the solution for the first sample. The cost $$$18$$$ is reached by taking $$$c_3$$$ 3 times and $$$c_2$$$ once, amounting to $$$5+5+5+3=18$$$.

package main

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

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

	tc := readNum(reader)
	var buf bytes.Buffer
	for tc > 0 {
		tc--
		dest := readNNums(reader, 2)
		C := readNNums(reader, 6)
		res := solve(dest, C)
		buf.WriteString(fmt.Sprintf("%d\n", res))
	}
	fmt.Print(buf.String())
}

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

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

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

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

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

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

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

	return i
}

var dx = []int64{1, 1, 0, -1, -1, 0}
var dy = []int64{1, 0, -1, -1, 0, 1}

func solve(dest []int, C []int) int64 {
	x, y := int64(dest[1]), int64(dest[0])

	var calc func(i, j int) int64
	calc = func(i, j int) int64 {
		if i == j {
			if dx[i] != 0 {
				a := x / dx[i]
				if a > 0 && a*dx[i] == x && a*dy[i] == y {
					return a * int64(C[i])
				}
				return math.MaxInt64
			}
			// dy[i] != 0
			b := y / dy[i]
			if b > 0 && b*dx[i] == x && b*dy[i] == y {
				return b * int64(C[i])
			}
			return math.MaxInt64
		}
		if i > j {
			if j+3 == i {
				return math.MaxInt64
			}
		} else {
			if i+3 == j {
				return math.MaxInt64
			}
		}
		// a, b => a * dx[i], a * dy[i] => x1, y1
		// x1 + b * dx[j], y1+ b * dy[j] => x, y
		// a * dx[i] + b * dx[j] = x
		// a * dy[i] + b * dy[j] = y
		var a, b int64
		if dx[i] == 0 {
			b = x / dx[j]
			a = (y - b*dy[j]) / dy[i]

		}
		if dx[j] == 0 {
			a = x / dx[i]
			b = (y - a*dy[i]) / dy[j]

		}
		if dy[i] == 0 {
			b = y / dy[j]
			a = (x - b*dx[j]) / dx[i]

		}
		// dy[j] == 0
		if dy[j] == 0 {
			a = y / dy[i]
			b = (x - a*dx[i]) / dx[j]

		}
		if a < 0 || b < 0 {
			return math.MaxInt64
		}
		return a*int64(C[i]) + b*int64(C[j])
	}

	var best int64 = math.MaxInt64

	for i := 0; i < 6; i++ {
		for j := 0; j < 6; j++ {
			tmp := calc(i, j)
			if tmp < best {
				best = tmp
			}
		}
	}
	return best
}

package main

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

var _r = bufio.NewReader(os.Stdin)
var _w = bufio.NewWriter(os.Stdout)

var T int
var x, y int64

func absInt(x int64) int64 {
	if x >= 0 {
		return x
	}
	return -x
}

func minInt(x, y, z int64) int64 {
	if x <= y && x <= z {
		return x
	}
	if y <= x && y <= z {
		return y

	}
	return z
}

func main() {
	for _, _ = fmt.Fscan(_r, &T); T > 0; T-- {
		_, _ = fmt.Fscan(_r, &x, &y)
		c:=make([]int64,6)
		for i := 0; i < 6; i++ {
			_, _ = fmt.Fscan(_r, &c[i])
		}

		var wg sync.WaitGroup
		var len1, len2, len3 int64

		wg.Add(1)
		go func() {
			defer wg.Done()
			if x >= 0 {
				len1 += absInt(x) * c[0]
			} else {
				len1 += absInt(x) * c[3]
			}
		}()

		wg.Add(1)
		go func() {
			defer wg.Done()
			if y >= 0 {
				len2 += absInt(y) * c[0]
				len3 += absInt(y) * c[1]
			} else {
				len2 += absInt(y) * c[3]
				len3 += absInt(y) * c[4]
			}
		}()

		wg.Add(1)
		go func() {
			defer wg.Done()
			if (y - x) >= 0 {
				len1 += absInt(y-x) * c[1]
			} else {
				len1 += absInt(y-x) * c[4]
			}
		}()

		wg.Add(1)
		go func() {
			defer wg.Done()
			if (x - y) >= 0 {
				len2 += absInt(x-y) * c[5]
			} else {
				len2 += absInt(x-y) * c[2]
			}
		}()

		wg.Add(1)
		go func() {
			defer wg.Done()
			if x >= 0 {
				len3 += absInt(x) * c[5]
			} else {
				len3 += absInt(x) * c[2]
			}
		}()

		//fmt.Println(len1,len2,len3)

		wg.Wait()

		_,_=fmt.Fprintln(_w,minInt(len1,len2,len3))
		_=_w.Flush()
	}
}

package main

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

var _r = bufio.NewReader(os.Stdin)
var _w = bufio.NewWriter(os.Stdout)

var T int
var x, y int64

func absInt(x int64) int64 {
	if x >= 0 {
		return x
	}
	return -x
}

func minInt(x, y, z int64) int64 {
	if x <= y && x <= z {
		return x
	}
	if y <= x && y <= z {
		return y

	}
	return z
}

func main() {
	for _, _ = fmt.Fscan(_r, &T); T > 0; T-- {
		_, _ = fmt.Fscan(_r, &x, &y)
		c:=make([]int64,6)
		for i := 0; i < 6; i++ {
			_, _ = fmt.Fscan(_r, &c[i])
		}

		var len1, len2, len3 int64
		if x >= 0 {
			len1 += absInt(x) * c[0]
		} else {
			len1 += absInt(x) * c[3]
		}
		if y >= 0 {
			len2 += absInt(y) * c[0]
			len3 += absInt(y) * c[1]
		} else {
			len2 += absInt(y) * c[3]
			len3 += absInt(y) * c[4]
		}
		if (y - x) >= 0 {
			len1 += absInt(y-x) * c[1]
		} else {
			len1 += absInt(y-x) * c[4]
		}

		if (x - y) >= 0 {
			len2 += absInt(x-y) * c[5]
		} else {
			len2 += absInt(x-y) * c[2]
		}

		if x >= 0 {
			len3 += absInt(x) * c[5]
		} else {
			len3 += absInt(x) * c[2]
		}
		//fmt.Println(len1,len2,len3)

		_,_=fmt.Fprintln(_w,minInt(len1,len2,len3))
		_=_w.Flush()

	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1421D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	min := func(a, b int64) int64 {
		if a < b {
			return a
		}
		return b
	}

	var T int
	var x, y, c1, c2, c3, c4, c5, c6 int64
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &x, &y, &c1, &c2, &c3, &c4, &c5, &c6)
		if x < 0 {
			x, y, c1, c2, c3, c4, c5, c6 = -x, -y, c4, c5, c6, c1, c2, c3
		}
		if y > x {
			c1 = min(c1, c2+c6)
			c2 = min(c2, c1+c3)
			Fprintln(out, x*c1+(y-x)*c2)
		} else if y > 0 {
			x, y, c2, c3, c5, c6 = y, x, c6, c5, c3, c2
			c1 = min(c1, c2+c6)
			c2 = min(c2, c1+c3)
			Fprintln(out, x*c1+(y-x)*c2)
		} else {
			c6 = min(c6, c1+c5)
			c5 = min(c5, c6+c4)
			Fprintln(out, x*c6-y*c5)
		}
	}
}

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

package main

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

var _r = bufio.NewReader(os.Stdin)
var _w = bufio.NewWriter(os.Stdout)

var T, x, y int

func absInt(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func minInt(x, y, z int) int {
	if x <= y && x <= z {
		return x
	}
	if y <= x && y <= z {
		return y

	}
	return z
}

func main() {
	for _, _ = fmt.Fscan(_r, &T); T > 0; T-- {
		_, _ = fmt.Fscan(_r, &x, &y)
		c:=make([]int,6)
		for i := 0; i < 6; i++ {
			_, _ = fmt.Fscan(_r, &c[i])
		}

		var len1, len2, len3 int
		if x >= 0 {
			len1 += absInt(x) * c[0]
		} else {
			len1 += absInt(x) * c[3]
		}
		if y >= 0 {
			len2 += absInt(y) * c[0]
			len3 += absInt(y) * c[1]
		} else {
			len2 += absInt(y) * c[3]
			len3 += absInt(y) * c[4]
		}
		if (y - x) >= 0 {
			len1 += absInt(y-x) * c[1]
		} else {
			len1 += absInt(y-x) * c[4]
		}

		if (x - y) >= 0 {
			len2 += absInt(x-y) * c[5]
		} else {
			len2 += absInt(x-y) * c[2]
		}

		if x >= 0 {
			len3 += absInt(x) * c[5]
		} else {
			len3 += absInt(x) * c[2]
		}
		//fmt.Println(len1,len2,len3)

		_,_=fmt.Fprintln(_w,minInt(len1,len2,len3))
		_=_w.Flush()

	}
}


This is the easy version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the minimum number of contiguous subsegments, and for each subsegment, all bits in each subsegment are the same. After that, $$$s$$$ is considered good if the lengths of all subsegments are even.For example, if $$$s$$$ is "11001111", it will be divided into "11", "00" and "1111". Their lengths are $$$2$$$, $$$2$$$, $$$4$$$ respectively, which are all even numbers, so "11001111" is good. Another example, if $$$s$$$ is "1110011000", it will be divided into "111", "00", "11" and "000", and their lengths are $$$3$$$, $$$2$$$, $$$2$$$, $$$3$$$. Obviously, "1110011000" is not good.Tokitsukaze wants to make $$$s$$$ good by changing the values of some positions in $$$s$$$. Specifically, she can perform the operation any number of times: change the value of $$$s_i$$$ to '0' or '1'($$$1 \leq i \leq n$$$). Can you tell her the minimum number of operations to make $$$s$$$ good?

The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, print a single line with one integer — the minimum number of operations to make $$$s$$$ good.

NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively. There are other ways to operate $$$3$$$ times to make $$$s$$$ good, such as "1111110000", "1100001100", "1111001100".In the second, third and fourth test cases, $$$s$$$ is good initially, so no operation is required.

package main

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

func f(in io.Reader, out io.Writer) {
	var n int
	var s string
	Fscan(in, &n, &s)
	prev := 1
	count := 0
	prev_num := 2
	ans := 0

	for _, char := range s {
		tmp, _ := strconv.Atoi(string(char))
		if tmp == prev {
			count++
		} else {
			if prev_num == 2 {
				prev_num = count % 2
				if prev_num == 1 {
					ans++
				}
			} else {
				if prev_num == 1 {
					if count%2 == 0 {
						ans++
					} else {
						prev_num = 0
					}
				} else {
					if count%2 == 1 {
						ans++
						prev_num = 1
					}
				}

			}
			prev = 1 - prev
			count = 1
		}
	}
	Fprintln(out, ans)
}

func main() {
	var t int
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	Fscan(in, &t)

	for i := 0; i < t; i++ {
		f(in, out)
	}
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var s string
		fmt.Scan(&s)
		fmt.Scan(&s)
		segmentedBuilder := strings.Builder{}
		var start int = 0
		for i, ch := range s {
			if ch != rune(s[start]) {
				length := i - start
				if length%2 == 0 {
					segmentedBuilder.Write([]byte{'e'})
				} else {
					segmentedBuilder.Write([]byte{'o'})
				}
				start = i
			}
		}
		if start < len(s) {
			length := len(s) - start
			if length%2 == 0 {
				segmentedBuilder.Write([]byte{'e'})
			} else {
				segmentedBuilder.Write([]byte{'o'})
			}
			start = i + 1
		}
		segmented := segmentedBuilder.String()
		prev := 'e'
		ans := 0
		for _, ch := range segmented {
			if prev == 'o' && ch == 'e' {
				ch = 'o'
				ans++
			} else if prev == 'o' && ch == 'o' {
				ch = 'e'
				ans++
			}
			prev = ch
		}
		if prev == 'o' {
			ans++
		}
		fmt.Println(ans)
	}
}

package main

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

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

func slove() {
	defer w.Flush()
	var n int
	var s string
	fmt.Fscan(r, &n, &s)
	last := 0
	ans := 0
	for i:=0;i<n;i++ {
		if s[i] != s[last] {
			if (i - last) % 2 == 1 {
				ans++
				last = i + 1
			} else {
				last = i
			}
		}
	}
	fmt.Fprintln(w, ans)
}

func main() {
	var n int
	fmt.Fscan(r, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

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

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	_, _ = fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	_, _ = fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	_, _ = fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	_, _ = fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) Println(v ...interface{}) {
	_, _ = fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	_, _ = fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	_, _ = fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

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

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

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

func main() {
	io := NewIO(os.Stdin, os.Stdout)
	for t := io.ReadInt(); t > 0; t-- {
		_ = io.ReadInt()
		s := io.ReadString()
		a := make([]int, 1)
		a[0] = 1

		for i := 1; i < len(s); i++ {
			if s[i] == s[i-1] {
				a[len(a)-1]++
			} else {
				a = append(a, 1)
			}
		}

		ans := 0

		for i := 1; i < len(a); i++ {
			if a[i-1]%2 != 0 {
				a[i-1]++
				a[i]--
				ans++
			}
		}

		fmt.Println(ans)
	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1678B
Date: 9/10/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1678/B1
Problem: CF1678B
**/
func (in *CF1678B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		str := in.NextString()
		arr := make([]int, 0)
		count := 0
		current := str[0]
		for i := 0; i < n; i++ {
			if str[i] == current {
				count++
			} else {
				arr = append(arr, count)
				count = 1
				current = str[i]
			}
		}
		arr = append(arr, count)

		ans := 0
		for i := 0; i < len(arr); i++ {
			if arr[i]%2 != 0 {
				arr[i]++
				ans++
				if i+1 < len(arr) {
					arr[i+1]--
					ans++
				}
			}
		}

		fmt.Println(ans / 2)

	}
}

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

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

package main

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

const MAXN = 2e5

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var ntests int
	fmt.Fscan(in, &ntests)
	for iiter := 0; iiter < ntests; iiter++ {
		var n int
		fmt.Fscan(in, &n)
		sums := make([]int, 0)
		last := '2'
		curr := 0
		var s string
		fmt.Fscan(in, &s)
		for _, el := range s {
			if el == last {
				curr++
			} else {
				last = el
				sums = append(sums, curr)
				curr = 1
			}
		}
		sums = append(sums, curr)
		sums = sums[1:]
		//fmt.Println("_", sums)
		res := 0
		flag := false
		count := 0
		for i := 0; i < len(sums); i++ {
			count++
			if sums[i]%2 == 1 {
				if flag {
					res += count
					flag = false
				} else {
					count = 0
					flag = true
				}
			}
		}
		fmt.Fprintln(out, res)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
var wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)
var rdr = bufio.NewScanner(os.Stdin)
func gs() string  { rdr.Scan(); return rdr.Text() }
func gi() int     { i,e := strconv.Atoi(gs()); if e != nil {panic(e)}; return i }
func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	T := gi()
	for tt:=1;tt<=T;tt++ {
		N := gi(); S := gs()
		ep := []int{}
		for i:=0;i<N-1;i++ { if S[i] != S[i+1] { ep = append(ep,i) } }; ep = append(ep,N-1)
		larr := []int{}; larr = append(larr,ep[0]+1); for i:=1;i<len(ep);i++ { larr = append(larr,ep[i]-ep[i-1]) }
		odds := []int{}; for i:=0;i<len(larr);i++ { if larr[i] % 2 == 1 { odds = append(odds,i) } }
		ans := 0;  for i:=0;i<len(odds);i+=2 {	ans += odds[i+1]-odds[i] }
		fmt.Fprintln(wrtr,ans)
	}
}

package main

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

func solve(in io.Reader, out io.Writer) {
	var n int
	var s string
	Fscan(in, &n, &s)

	//Fscanf(in, "%s", &s)

	//Fprintln(out, n, "         ", s)
	var prev uint8 = '2'
	notEqCnt := 0
	segmentCnt := 0

	for i := 0; i < n; i += 2 {
		if s[i] != s[i+1] {
			notEqCnt++
		} else if prev != s[i] {
			prev = s[i]
			segmentCnt++
		}
	}

	//Fprintf(out, "%d %d\n", notEqCnt, segmentCnt)
	Fprintln(out, notEqCnt)

}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var T int
	for Fscan(in, &T); T > 0; T-- {
		solve(in, out)
	}
}

package main

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

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

	var T, n int
	var s string
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &s)
		ans := 0
		for i := 0; i < n; i += 2 {
			if s[i] != s[i+1] {
				ans++
			}
		}
		Fprintln(out, ans)
	}
}

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

package main

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

const eof = 0

type any = interface{}

type MyIO struct {
	in  *os.File
	out *bufio.Writer
	_i  int
	_n  int
	buf []byte
}

func NewIO(in *os.File, out *os.File) *MyIO {
	return &MyIO{
		in,
		bufio.NewWriter(out),
		0, 0, make([]byte, 1<<12),
	}
}

func (myio *MyIO) rc() byte {
	if myio._i == myio._n {
		myio._n, _ = myio.in.Read(myio.buf)
		if myio._n == 0 { // EOF
			return eof
		}
		myio._i = 0
	}
	b := myio.buf[myio._i]
	myio._i++
	return b
}

func (myio *MyIO) ReadInt() (x int) {
	rc := myio.rc
	b := rc()
	neg := false

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
		if b == '-' {
			neg = true
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int(b&15)
	}
	if neg {
		return -x
	}
	return x
}

func (myio *MyIO) ReadBytes() (s []byte) {
	rc := myio.rc
	b := rc()
	for ; b <= ' '; b = rc() {
	}
	for ; b > ' '; b = rc() {
		s = append(s, b)
	}
	return
}

func (myio *MyIO) ReadStr() (s string) {
	return string(myio.ReadBytes())
}

func (myio *MyIO) Flush() {
	myio.out.Flush()
}

func (myio *MyIO) Printf(format string, a ...any) (n int, err error) {
	return fmt.Fprintf(myio.out, format, a...)
}

func (myio *MyIO) Println(a ...any) (n int, err error) {
	return fmt.Fprintln(myio.out, a...)
}

func (myio *MyIO) Print(a ...any) (n int, err error) {
	return fmt.Fprint(myio.out, a...)
}

func main() {
	myio := NewIO(os.Stdin, os.Stdout)
	defer myio.Flush()

	t := myio.ReadInt()
	sol := func() {
		n := myio.ReadInt()
		b := myio.ReadBytes()
		c := 0
		for i := 0; i < n; i += 2 {
			if b[i] != b[i+1] {
				c++
			}
		}
		myio.Println(c)
	}
	for ; t > 0; t-- {
		sol()
	}
}

package main

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

type Int int64

const (
	INF = 3e5 + 10
	L0  = Int(0)
	L1  = Int(1)
)

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

	var t int
	Fscan(in, &t)

	for tt := 0; tt < t; tt++ {
		var n int
		Fscan(in, &n)
		var s string
		Fscan(in, &s)

		dp := MakeGrid(n+1, 2)

		dp[0][0] = L0
		dp[0][1] = L0
		ans := Int(n)
		for i := 1; i < n; i += 2 {
			dp[i][0] = Int(n)
			dp[i][1] = Int(n)

			to0 := L0
			if s[i-1] == '1' {
				to0++
			}
			if s[i] == '1' {
				to0++
			}

			to1 := L0
			if s[i-1] == '0' {
				to1++
			}
			if s[i] == '0' {
				to1++
			}

			if i > 2 {
				dp[i][0].MinAs(dp[i-2][0]+to0, dp[i-2][1]+to0)
				dp[i][1].MinAs(dp[i-2][1]+to1, dp[i-2][0]+to1)
			} else {
				dp[i][0] = to0
				dp[i][1] = to1
			}

			if i == n-1 {
				ans.MinAs(dp[i][0], dp[i][1])
			}
		}
		Fprintln(out, ans)

	}

}

func MakeGrid(h, w int) [][]Int {
	index := make([][]Int, h)
	data := make([]Int, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

func Abs(x Int) Int {
	if x > 0 {
		return x
	}
	return -x
}

func Min(nums ...Int) Int {
	return nums[MinIdx(nums...)]
}

func MinIdx(nums ...Int) Int {
	maxNumIdx := L0
	for i, num := range nums {
		if num < nums[maxNumIdx] {
			maxNumIdx = Int(i)
		}
	}
	return maxNumIdx
}

func Max(nums ...Int) Int {
	return nums[MaxIdx(nums...)]
}

func MaxIdx(nums ...Int) Int {
	maxNumIdx := L0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = Int(i)
		}
	}
	return maxNumIdx
}

var (
	mod  Int
	fmod func(Int) Int = doNothing
)

// SetMod sets the mod. It must be called first.
func SetMod(newMod Int) {
	mod = newMod
	fmod = dynamicMod
}

func dynamicMod(m Int) Int {
	m %= mod
	if m < 0 {
		return m + mod
	}
	return m
}

func doNothing(m Int) Int {
	return m
}

// Mod returns m % mod.
func (m Int) Mod() Int {
	return fmod(m)
}

// Inv returns modular multiplicative inverse
func (m Int) Inv() Int {
	return m.Pow(Int(0).Sub(2))
}

// Pow returns m^n
func (m Int) Pow(n Int) Int {
	p := Int(1)
	for n > 0 {
		if n&1 == 1 {
			p.MulAs(m)
		}
		m.MulAs(m)
		n >>= 1
	}
	return p
}

// Add returns m+x
func (m Int) Add(x Int) Int {
	return (m + x).Mod()
}

// Sub returns m-x
func (m Int) Sub(x Int) Int {
	return (m - x).Mod()
}

// Mul returns m*x
func (m Int) Mul(x Int) Int {
	return (m * x).Mod()
}

// Div returns m/x
func (m Int) Div(x Int) Int {
	return m.Mul(x.Inv())
}

// AddAs assigns *m + x to *m and returns m
func (m *Int) AddAs(x Int) *Int {
	*m = m.Add(x)
	return m
}

// SubAs assigns *m - x to *m and returns m
func (m *Int) SubAs(x Int) *Int {
	*m = m.Sub(x)
	return m
}

// MulAs assigns *m * x to *m and returns m
func (m *Int) MulAs(x Int) *Int {
	*m = m.Mul(x)
	return m
}

// DivAs assigns *m / x to *m and returns m
func (m *Int) DivAs(x Int) *Int {
	*m = m.Div(x)
	return m
}

func (m *Int) MaxAs(x ...Int) *Int {
	*m = Max(append(x, *m)...)
	return m
}

func (m *Int) MinAs(x ...Int) *Int {
	*m = Min(append(x, *m)...)
	return m
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		var s string
		fmt.Fscan(in, &n, &s)

		var c0, c1 int
		if s[0] == '0' {
			c0++
		} else {
			c1++
		}

		var tot int
		for i := 1; i < n; i++ {
			if s[i] == '0' {
				if c0 > 0 {
					c0++
				} else if c1%2 == 0 {
					c1 = 0
					c0 = 1
				} else {
					c1++
					tot++
				}
			} else {
				if c1 > 0 {
					c1++
				} else if c0%2 == 0 {
					c0 = 0
					c1 = 1
				} else {
					c0++
					tot++
				}
			}
		}

		fmt.Fprintln(out, tot)
	}
}

package main

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

func f(in io.Reader, out io.Writer){
	var n int
	var s string
	Fscan(in,&n, &s)
	prev := 1
	count := 0
	prev_num := 2
	ans := 0

	for _, char := range s {
		tmp, _ := strconv.Atoi(string(char))
		if tmp == prev {
			count++
		} else {
			if prev_num == 2 {
				prev_num = count % 2
				if prev_num == 1{
					ans++
				}
			} else {
				if prev_num == 1{
					ans++
				}
				if count%2 == 0 {
					continue
				} else {
					prev_num = 1 - prev_num
				}
			}
			prev = 1 - prev
			count = 1
		}
	}
	Fprintln(out, ans)
}

func main() {
	var t int
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	Fscan(in, &t)

	for i := 0; i < t; i++ {
		f(in, out)
	}
}

package main

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

func f() int {
	var n int
	var s string
	fmt.Scanf("%d", &n)
	fmt.Scanf("%s", &s)
	prev := 1
	count := 0
	prev_num := 2
	ans := 0

	for _, char := range s {
		tmp, _ := strconv.Atoi(string(char))
		if tmp == prev {
			count++
		} else {
			if prev_num == 2 {
				prev_num = count % 2
				if prev_num == 1{
					ans++
				}
			} else {
				if prev_num == 1{
					ans++
				}
				if count%2 == 0 {
					continue
				} else {
					prev_num = 1 - prev_num
				}
			}
			prev = 1 - prev
			count = 1
		}
	}
	return ans
}

func main() {
	var t int
	//in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	fmt.Scanf("%d", &t)

	for i := 0; i < t; i++ {
		fmt.Fprintln(out,f())
	}
}

package main

import (
	"fmt"
	"strconv"
)

func f() int {
	var n int
	var s string
	fmt.Scanf("%d", &n)
	fmt.Scanf("%s", &s)
	prev := 1
	count := 0
	prev_num := 2
	ans := 0

	for _, char := range s {
		tmp, _ := strconv.Atoi(string(char))
		if tmp == prev {
			count++
		} else {
			if prev_num == 2 {
				prev_num = count % 2
				if prev_num == 1{
					ans++
				}
			} else {
				if prev_num == 1{
					ans++
				}
				if count%2 == 0 {
					continue
				} else {
					prev_num = 1 - prev_num
				}
			}
			prev = 1 - prev
			count = 1
		}
	}
	return ans
}

func main() {
	var t int
	fmt.Scanf("%d", &t)

	for i := 0; i < t; i++ {
		fmt.Println(f())
	}
}

package main

import (
	"fmt"
	"strconv"
)

func f()int{
		var n int
		var s string
		fmt.Scanf("%d", &n)
		fmt.Scanf("%s", &s)
		prev := 1
		count := 0
		var l []int

		for _, char := range s{
			tmp, _ := strconv.Atoi(string(char))
			if tmp == prev {
				count++
			}else{
				l = append(l, count)
				prev = 1 - prev
				count = 1
			}
		}
		l = append(l, count)
		prev = -1
		ans := 0
		for _, value := range l{
			if prev == 0{
				if value%2 == 0{
					continue
				}else {
					prev = 1
					ans++
				}
			} else if prev == 1{
				if value%2 == 0{
					ans++
				}else {
					prev = 0
				}
			} else{
				if value%2 == 0{
					prev = 0
				}else {
					prev = 1
					ans++
				}
			}
		}
	return ans
	}

func main() {
	var t int
	fmt.Scanf("%d", &t)

	for i := 0; i < t; i++ {
		fmt.Println(f())
	}
}

package main

import (
	"fmt"
	"strconv"
)

func f()int{
		var n int
		var s string
		fmt.Scanf("%d", &n)
		fmt.Scanf("%s", &s)
		prev := 1
		count := 0
		var l []int

		for _, char := range s{
			tmp, _ := strconv.Atoi(string(char))
			if tmp == prev {
				count++
			}else{
				l = append(l, count)
				prev = 1 - prev
				count = 1
			}
		}
		l = append(l, count)
		prev = -1
		ans := 0
		for _, value := range l{
			if prev == 0{
				if value%2 == 0{
					continue
				}else {
					prev = 1
					ans++
				}
			} else if prev == 1{
				if value%2 == 0{
					ans++
				}else {
					prev = 0
				}
			} else{
				if value%2 == 0{
					prev = 0
				}else {
					prev = 1
					ans++
				}
			}
		}
	return ans
	}

func main() {
	var t int
	fmt.Scanf("%d", &t)

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

package main

import (
	"fmt"
	"strconv"
)

func f(){
		var n int
		var s string
		fmt.Scanf("%d", &n)
		fmt.Scanf("%s", &s)
		prev := 1
		count := 0
		var l []int

		for _, char := range s{
			tmp, _ := strconv.Atoi(string(char))
			if tmp == prev {
				count++
			}else{
				l = append(l, count)
				prev = 1 - prev
				count = 1
			}
		}
		l = append(l, count)
		prev = -1
		ans := 0
		for _, value := range l{
			if prev == 0{
				if value%2 == 0{
					continue
				}else {
					prev = 1
					ans++
				}
			} else if prev == 1{
				if value%2 == 0{
					ans++
				}else {
					prev = 0
				}
			} else{
				if value%2 == 0{
					prev = 0
				}else {
					prev = 1
					ans++
				}
			}
		}
		fmt.Println(ans)
	}

func main() {
	var t int
	fmt.Scanf("%d", &t)

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

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var t int
	fmt.Scanf("%d", &t)

	for i := 0; i < t; i++ {
		var n int
		var s string
		fmt.Scanf("%d", &n)
		fmt.Scanf("%s", &s)
		prev := 1
		count := 0
		var l []int

		for _, char := range s{
			tmp, _ := strconv.Atoi(string(char))
			if tmp == prev {
				count++
			}else{
				l = append(l, count)
				prev = 1 - prev
				count = 1
			}
		}
		l = append(l, count)
		prev = -1
		ans := 0
		for _, value := range l{
			if prev == 0{
				if value%2 == 0{
					continue
				}else {
					prev = 1
					ans++
				}
			} else if prev == 1{
				if value%2 == 0{
					ans++
				}else {
					prev = 0
				}
			} else{
				if value%2 == 0{
					prev = 0
				}else {
					prev = 1
					ans++
				}
			}
		}
		fmt.Println(ans)
	}
}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var t int
	fmt.Scanf("%d", &t)

	for i := 0; i < t; i++ {
		var n int
		var s string
		fmt.Scanf("%d", &n)
		fmt.Scanf("%s", &s)
		prev := 1
		count := 0
		var l []int

		for _, char := range s{
			tmp, _ := strconv.Atoi(string(char))
			if tmp == prev {
				count++
			}else{
				l = append(l, count)
				prev = 1 - prev
				count = 1
			}
		}
		l = append(l, count)
		//fmt.Println(l)
		prev = -1
		ans := 0
		for _, value := range l{
			if prev == 0{
				if value%2 == 0{
					continue
				}else {
					prev = 1
					ans++
				}
			} else if prev == 1{
				if value%2 == 0{
					ans++
				}else {
					prev = 0
				}
			} else{
				if value%2 == 0{
					prev = 0
				}else {
					prev = 1
					ans++
				}
			}
		}
		fmt.Println(ans)
	}
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var s string
		fmt.Scan(&s)
		fmt.Scan(&s)
		segmentedBuilder := strings.Builder{}
		var start int = 0
		for i, ch := range s {
			if ch != rune(s[start]) {
				length := i - start
				if length%2 == 0 {
					segmentedBuilder.Write([]byte{'e'})
				} else {
					segmentedBuilder.Write([]byte{'o'})
				}
				start = i
			}
		}
		if start < len(s) {
			length := len(s) - start
			if length%2 == 0 {
				segmentedBuilder.Write([]byte{'e'})
			} else {
				segmentedBuilder.Write([]byte{'o'})
			}
			start = i + 1
		}
		segmented := segmentedBuilder.String()
		prev := 'e'
		ans := 0
		for _, ch := range segmented {
			if prev == 'o' && ch == 'e' {
				ch = 'o'
				ans++
			} else if prev == 'o' && ch == 'o' {
				ch = 'e'
				ans++
			}
			prev = ch
		}
		if prev == 'o' {
			ans++
		}
		fmt.Println(s, ":", segmented, ":", ans)
	}
}

package main

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

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	_, _ = fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	_, _ = fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	_, _ = fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	_, _ = fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) Println(v ...interface{}) {
	_, _ = fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	_, _ = fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	_, _ = fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

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

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

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

func main() {
	io := NewIO(os.Stdin, os.Stdout)
	for t := io.ReadInt(); t > 0; t-- {
		_ = io.ReadInt()
		s := io.ReadString()
		a := make([]int, 1)
		a[0] = 1

		for i := 1; i < len(s); i++ {
			if s[i] == s[i-1] {
				a[len(a)-1]++
			} else {
				a = append(a, 1)
			}
		}

		ans := 0

		for len(a) > 1 {
			a1 := a[len(a)-2]
			a2 := a[len(a)-1]
			if a1%2 == 0 && a2%2 == 0 {
				a = a[:len(a)-1]
				a[len(a)-1] = a1 + a2
				continue
			}

			if a1%2 == 1 && a2%2 == 1 {
				a = a[:len(a)-1]
				a[len(a)-1] = a1 - 1
				ans++
				continue
			}

			ans += min(a1, a2)

			if min(a1, a2) == a2 {
				a = a[:len(a)-1]
				a[len(a)-1] = a1 + a2
				continue
			} else {
				a = a[:len(a)-2]
				a[len(a)-1] += a1 + a2
			}
		}

		fmt.Println(ans)
	}
}


You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column from the tableabcdedfghijk we obtain the table:acdefghjk A table is called good if its rows are ordered from top to bottom lexicographically, i.e. each row is lexicographically no larger than the following one. Determine the minimum number of operations of removing a column needed to make a given table good.

The first line contains two integers  — n and m (1 ≤ n, m ≤ 100). Next n lines contain m small English letters each — the characters of the table.

Print a single number — the minimum number of columns that you need to remove in order to make the table good.

NoteIn the first sample the table is already good.In the second sample you may remove the first and third column.In the third sample you have to remove all the columns (note that the table where all rows are empty is considered good by definition).Let strings s and t have equal length. Then, s is lexicographically larger than t if they are not equal and the character following the largest common prefix of s and t (the prefix may be empty) in s is alphabetically larger than the corresponding character of t.

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, m := nextInt(), nextInt()
	count := 0
	s := make([]string, n)

	for i := 0; i < n; i++ {
		s[i] = next()
	}
	// println(s)
	for i := 0; i < n - 1; i++ {
		if s[i] > s[i+1] {
			count++
			for j := 0; j < m; j++ {
				if s[i][j] > s[i+1][j] {
					for k := 0; k < n; k++ {
						s[k] = s[k][:j] + s[k][j+1:]
					}

					m--
					break
				}
				// println("ij:", i, j, s[i], s[j], okRow[j], count)
			}

			i = -1
		}

	}
	// println(okRow)
	println(count)
}

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

package main

import (
	"fmt"
)

var (
	n, m   int
	input  []string
	result int = 0
)

func in() {
	fmt.Scanf("%d %d\n", &n, &m)
	input = make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scanln(&input[i])
	}
}

func out() {
	fmt.Println(result)
}

func run() {
	var table [][]int
	table = make([][]int, n-1)
	for i := 0; i < n-1; i++ {
		table[i] = make([]int, m)
		for j, _ := range input[i] {
			table[i][j] = int(input[i][j]) - int(input[i+1][j])
		}
	}

	for !isGood(table) {
		for i := 0; i < n-1; i++ {
			for j := 0; j < m; j++ {
				if table[i][j] < 0 {
					break
				} else if table[i][j] > 0 {
					result++
					for k := 0; k < n-1; k++ {
						table[k][j] = 0
					}
				}
			}
		}
	}
}

func isGood(table [][]int) bool {
	for i := 0; i < n-1; i++ {
		for j := 0; j < m; j++ {
			if table[i][j] == 0 {
				continue
			} else if table[i][j] > 0 {
				return false
			} else { // table[i][j] < 0
				break
			}
		}
	}
	return true
}

func main() {
	in()
	run()
	out()
}

package main

import (
	"fmt"
)

func main() {
	var n, m, res int
	fmt.Scan(&n, &m)
	table := make([][]byte, n)

	for i := 0; i < n; i++ {
		var row string
		fmt.Scan(&row)
		table[i] = []byte(row)
	}

	if n == 1 {
		fmt.Println(0)
		return
	}

	lcp := make([]int, n-1)

	for j := 0; j < len(table[0]); {
		illegal := false

		for i := 0; i < n-1; i++ {
			if lcp[i] < j {
				continue
			}

			if table[i][j] == table[i+1][j] {
				lcp[i]++
			} else if table[i][j] > table[i+1][j] {
				illegal = true
				break
			}
		}

		if !illegal {
			j++
		} else {
			res++

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

			for i, l := 0, len(table[0]); i < n; i++ {
				if j < l-1 {
					table[i] = append(table[i][:j], table[i][j+1:]...)
				} else {
					table[i] = table[i][:j]
				}
			}
		}
	}

	fmt.Println(res)
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	t := make([][]rune, n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		t[i] = []rune(s)
	}
	removed := make([]bool, m)
	for j := 0; j < m; j++ {
		for i := 1; i < n; i++ {
			if removed[j] {
				break
			}
			for k := 0; k <= j; k++ {
				if removed[k] {
					continue
				}
				if t[i-1][k] < t[i][k] {
					break
				}
				if k == j && t[i-1][k] > t[i][k] {
					removed[j] = true
				}
			}
		}
	}
	z := 0
	for i := 0; i < m; i++ {
		if removed[i] {
			z++
		}
	}
	fmt.Println(z)
}

// Author: sighduck
// URL: https://codeforces.com/problemset/problem/496/C

package main

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

func Solve(n, m int, words []string) int {
	pairs := make([]bool, n-1)
	ans := 0
	for i := 0; i < m; i++ {
		remove := 0
		for j := 0; j < n-1; j++ {
			if words[j][i] > words[j+1][i] && !pairs[j] {
				remove = 1
			}
		}
		ans += remove
		if remove == 0 {
			for j := 0; j < n-1; j++ {
				if words[j][i] < words[j+1][i] {
					pairs[j] = true
				}
			}
		}
	}
	return ans
}

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

	var n, m int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	words := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%s\n", &words[i])
	}

	fmt.Fprintf(writer, "%d\n", Solve(n, m, words))
}

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, m := nextInt(), nextInt()
	count := 0

	s := make([]string, n)

	for i := 0; i < n; i++ {
		s[i] = next()
	}
	// println(s)
	for i := 0; i < n - 1; i++ {
		for j := 0; j < m; j++ {
			if s[i][j] < s[i+1][j] {
				break
			} else if s[i][j] > s[i+1][j] {
				// println(i, j, s)
				removeCol(s, j)
				m--
				j--
				count++
			}
		}
	}

	if len(s) > 0 {
		for i := 0; i < len(s) - 1; i++ {
			if s[i][0] == s[i+1][0] {
				continue
			} else if s[i][0] > s[i+1][0] {
				count++
				break
			}
		}
	}

	println(count)
}

func removeCol(s []string, index int) {
	for i := 0; i < len(s); i++ {
		s[i] = s[i][:index] + s[i][index+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...)
}

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, m := nextInt(), nextInt()
	count := 0
	s := make([]string, n)
	delCol := make([]bool, m)

	for i := 0; i < n; i++ {
		s[i] = next()
	}
	// println(s)
	for i := 0; i < n - 1; i++ {
		for j := 0; j < m; j++ {
			if delCol[j] {
				continue
			}

			if s[i][j] < s[i+1][j] {
				break
			} else if s[i][j] > s[i+1][j] {
				// println(i, s[i], s[i+1], j)
				delCol[j] = true
				i = 0
				count++
			}
		}
	}
	// println(delCol)
	println(count)
}

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

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, m := nextInt(), nextInt()
	count := 0
	s := make([]string, n)
	okRow := make([]bool, n)

	for i := 0; i < n; i++ {
		s[i] = next()
	}
	// println(s)
	for i := 0; i < m; i++ {
		indexOkRows := make([]int, 0)
		isDelCol := false
		for j := 0; j < n - 1; j++ {
			// println("ij:", i, j, s[i], s[j], okRow[j], count)
			if s[j][i] == s[j+1][i] {
				continue
			}

			if okRow[j] {
				break
			}

			if s[j][i] > s[j+1][i] {
				count++
				isDelCol = true
				break
			} else {
				indexOkRows = append(indexOkRows, j)
			}
		}

		if !isDelCol {
			for _, v := range indexOkRows {
				okRow[v] = okRow[v] || true
			}
		}
	}
	// println(okRow)
	println(count)
}

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

package main

import (
	"fmt"
)

func main() {
	var n, m, res int
	fmt.Scan(&n, &m)
	table := make([][]byte, n)

	for i := 0; i < n; i++ {
		var row string
		fmt.Scan(&row)
		table[i] = []byte(row)
	}

	if n == 1 {
		fmt.Println(0)
		return
	}

	lcp := make([]int, n-1)

	for j := 0; j < len(table[0]); {
		illegal := false

		for i := 0; i < n-1; i++ {
			if lcp[i] < j {
				continue
			}

			if table[i][j] == table[i+1][j] {
				lcp[i]++
			} else if table[i][j] > table[i+1][j] {
				illegal = true
				break
			}
		}

		if !illegal {
			j++
		} else {
			res++

			for i, l := 0, len(table[0]); i < n; i++ {
				if j < l-1 {
					table[i] = append(table[i][:j], table[i][j+1:]...)
				} else {
					table[i] = table[i][:j]
				}
			}
		}
	}

	fmt.Println(res)
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	var table [110][110]int
	for i := 1; i <= n; i++ {
		var s string
		fmt.Scan(&s)
		for j, r := range s {
			table[j+1][i] = int(r - '0')
		}
	}
	var z, prevCol int
	for i := 1; i <= m; i++ {
		px := -1
		j := 1
		for ; j <= n; j++ {
			if px == table[prevCol][j] {
				if table[i][j-1] > table[i][j] {
					z++
					break
				}
			} else {
				px = table[prevCol][j]
			}
		}
		if j > n {
			prevCol = i
		}
	}
	fmt.Println(z)
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	var table [110][110]int
	for i := 1; i <= n; i++ {
		var s string
		fmt.Scan(&s)
		for j, r := range s {
			table[j+1][i] = int(r - '0')
		}
	}
	var z, prevCol int
	for i := 1; i <= m; i++ {
		px := table[prevCol][1]
		j := 1
		for j <= n {
			if px == table[prevCol][j] {
				if table[i][j-1] > table[i][j] {
					z++
					break
				}
				j++
			} else {
				px = table[prevCol][j]
				j++
			}
		}
		if j > n {
			prevCol = i
		}
	}
	fmt.Println(z)
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	var table [110][110]rune
	for i := 1; i <= n; i++ {
		var s string
		fmt.Scan(&s)
		for j, r := range s {
			table[j+1][i] = r
		}
	}
	var z, prevCol int
	var fixed, tmpFixed [110]bool
	fixed[1] = true
	for i := 1; i <= m; i++ {
		j := 1
		px := table[prevCol][1]
		for ; j <= n; j++ {
			if fixed[j] {
				px = table[prevCol][j]
				continue
			}
			if px == table[prevCol][j] {
				if table[i][j-1] > table[i][j] {
					z++
					break
				}
				if table[i][j-1] < table[i][j] {
					tmpFixed[j] = true
				}
			} else {
				px = table[prevCol][j]
			}
		}
		if j > n {
			prevCol = i
			for k := 0; k < n; k++ {
				if tmpFixed[k] {
					fixed[k] = true
				}
			}
		}
	}
	fmt.Println(z)
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	var table [110][110]rune
	for i := 1; i <= n; i++ {
		var s string
		fmt.Scan(&s)
		for j, r := range s {
			table[j+1][i] = r
		}
	}
	var z, prevCol int
	var fixed, tmpFixed [110]bool
	fixed[1] = true
	for i := 1; i <= m; i++ {
		j := 1
		var px rune
		for ; j <= n; j++ {
			if fixed[j] {
				px = table[prevCol][j]
				continue
			}
			if px == table[prevCol][j] {
				if table[i][j-1] > table[i][j] {
					z++
					break
				}
				if table[i][j-1] < table[i][j] {
					tmpFixed[j] = true
				}
			} else {
				px = table[prevCol][j]
			}
		}
		if j > n {
			prevCol = i
			for k := 1; k <= n; k++ {
				if tmpFixed[k] {
					fixed[k] = true
				}
			}
		}
	}
	fmt.Println(z)
}


$$$m$$$ chairs are arranged in a circle sequentially. The chairs are numbered from $$$0$$$ to $$$m-1$$$. $$$n$$$ people want to sit in these chairs. The $$$i$$$-th of them wants at least $$$a[i]$$$ empty chairs both on his right and left side. More formally, if the $$$i$$$-th person sits in the $$$j$$$-th chair, then no one else should sit in the following chairs: $$$(j-a[i]) \bmod m$$$, $$$(j-a[i]+1) \bmod m$$$, ... $$$(j+a[i]-1) \bmod m$$$, $$$(j+a[i]) \bmod m$$$.Decide if it is possible to sit down for all of them, under the given limitations.

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq n \leq 10^5$$$, $$$1 \leq m \leq 10^9$$$) — the number of people and the number of chairs. The next line contains $$$n$$$ integers, $$$a_1$$$, $$$a_2$$$, ... $$$a_n$$$ ($$$1 \leq a_i \leq 10^9$$$) — the minimum number of empty chairs, on both sides of the $$$i$$$-th person. It is guaranteed that the sum of $$$n$$$ over all test cases will not exceed $$$10^5$$$.

For each test case print "YES" (without quotes) if it is possible for everyone to sit down and fulfil the restrictions, and "NO" (without quotes) otherwise. You may print every letter in any case you want (so, for example, the strings "yEs", "yes", "Yes" and "YES" will all be recognized as positive answers).

NoteTest case $$$1$$$: $$$n>m$$$, so they can not sit down.Test case $$$2$$$: the first person can sit $$$2$$$-nd and the second person can sit in the $$$0$$$-th chair. Both of them want at least $$$1$$$ empty chair on both sides, chairs $$$1$$$ and $$$3$$$ are free, so this is a good solution.Test case $$$3$$$: if the second person sits down somewhere, he needs $$$2$$$ empty chairs, both on his right and on his left side, so it is impossible to find a place for the first person, because there are only $$$5$$$ chairs.Test case $$$4$$$: they can sit in the $$$1$$$-st, $$$4$$$-th, $$$7$$$-th chairs respectively.

package main

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

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

	var limit int64
	Fscan(reader, &limit)

	for limit != 0 {
		var people, chair int64

		Fscan(reader, &people, &chair)

		store := make([]int64, people)

		nofchair := chair-people

		for i := range store {
			Fscan(reader, &store[i])
		}

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

		left, right := store[0], store[0]
		nofchair -= left+right
		for i := int64(1); i < people; i++ {
			if i == people-1 {
				break
			}
			if i % 2 == 0 {
				if left >= store[i] {
					left = store[i]
					nofchair -= left
				}
			} else {
				if right >= store[i] {
					right = store[i]
					nofchair -= right
				}
			}
		}

		if nofchair >= 0 {
			Fprintln(writer, "YES")
		} else {
			Fprintln(writer, "NO")
		}

		limit--
	}
}

package main

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

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for i := 0;i < t;i++ {
		var n int
		var m int
		fmt.Fscan(in, &n, &m)
		want := make([]int64,n)
		for j := 0;j < n;j++ {
			fmt.Fscan(in, &want[j])
		}
		sort.Slice(want, func(i, j int) bool {
			return want[i] < want[j]
		})
		k := int64(0)
		for j := 1;j < n;j++ {
			if want[j-1] < want[j] {
				k += want[j]+1
			}else {
				k += want[j-1]+1
			}

		}
		if k + want[n-1] <= int64(m)-1 {
			fmt.Println("YES")
		}else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)

	for ii := 0; ii < t; ii++ {
		var n int
		var m int64
		fmt.Fscan(in, &n, &m)
		nums := make([]int64, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &nums[i])
		}
		sort.Slice(nums, func(i, j int) bool {
			return nums[i] < nums[j]
		})
		used := 1 + nums[n-1]
		for i := n - 2; i >= 0; i-- {
			if i == 0 {
				used += nums[n-1] + 1
			} else {
				used += nums[i] + 1
			}
		}
		if used <= m {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

//4444444444
//4444444444
//4444444444
//4444444444
//4444444444

package main

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

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

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

	var T, x, n int
	var m int64
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &m)

		row := []int{}
		for i := 0; i < n; i++ {
			Fscan(in, &x)
			row = append(row, x)
		}
		sort.Ints(row)

		u := int64(1 + 2*row[n-1])
		for i := n - 2; i >= 0; i-- {
			v := row[i]
			u += int64(1 + v)
		}
		u -= int64(row[0])

		if u > m {
			Fprintln(out, "NO")

		} else {
			Fprintln(out, "YES")
		}
	}
}

package main

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

const (
	INF = 3e5 + 10
	L0  = int64(0)
	L1  = int64(1)
)

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

	var t int
	Fscan(in, &t)

	for tt := 0; tt < t; tt++ {
		var n, m int
		Fscan(in, &n, &m)

		a := make([]int, n)
		sum := L0
		for i := 0; i < n; i++ {
			Fscan(in, &a[i])
		}
		sort.Ints(a)

		sum += int64(a[n-1]<<1) + 1
		for i := n - 2; i > 0; i-- {
			sum += 1 + int64(a[i])
		}
		sum += 1

		if sum <= int64(m) {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}

}

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

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

package main

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

/*
2
3 5
1 1 2
2 5
1 1
---
NO
YES
=======
5
3 8
1 2 3
3 8
1 1 1
3 8
1 1 2
3 8
1 2 2
3 9
1 2 2
---
NO
YES
YES
NO
YES
=======
2
4 13
1 2 2 3
4 14
1 2 2 3
*/

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var n, m int
	scanf("%d %d\n", &n, &m)

	a := make([]int, n)

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

	sort.Sort(sort.Reverse(sort.IntSlice(a)))

	reqSpace := 2 + 2*int64(a[0])

	for i := 1; i < n-1; i++ {
		reqSpace += 1 + int64(a[i])
	}

	if int64(m) >= reqSpace {
		fmt.Fprintln(writer, "YES")
	} else {
		fmt.Fprintln(writer, "NO")
	}
}

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

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

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

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 reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

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

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	return nums[minIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func minIdx(nums ...int) int {
	minNumIdx := 0
	for i, num := range nums {
		if num < nums[minNumIdx] {
			minNumIdx = i
		}
	}

	return minNumIdx
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	return nums[maxIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func maxIdx(nums ...int) int {
	maxNumIdx := 0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = i
		}
	}

	return maxNumIdx
}

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

//goland:noinspection GoUnhandledErrorResult
func factorize(num int) []int {
	factors := []int{1}

	sqrtA := int(math.Sqrt(float64(num)))

	for ftr := 2; ftr <= sqrtA; ftr++ {
		for num%ftr == 0 {
			num /= ftr
			factors = append(factors, ftr)
		}
	}

	if num > sqrtA {
		factors = append(factors, num)
	}

	return factors
}

package main

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

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

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

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

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

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

		var pos int64
		for i := 1; i < n; i++ {
			pos += max(arr[i-1], arr[i]) + 1
		}

		if pos+arr[n-1] <= int64(m)-1 {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for i := 0;i < t;i++ {
		var n int
		var m int
		fmt.Fscan(in, &n, &m)
		want := make([]int64,n)
		for j := 0;j < n;j++ {
			fmt.Fscan(in, &want[j])
		}
		if n > m {
			fmt.Println("NO")
			continue
		}
		k := int64(0)
		for j := 0;j < n-1;j++ {
			if want[j] < want[j+1] {
				k += want[j+1]+1
			}else {
				k += want[j]+1
			}

		}
		if k + want[n-1] >= int64(m) || k >= int64(m)-want[0] {
			fmt.Println("NO")
		}else {
			fmt.Println("YES")
		}
	}
}

package main

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

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for i := 0;i < t;i++ {
		var n int
		var m int
		fmt.Fscan(in, &n, &m)
		want := make([]int,n)
		for j := 0;j < n;j++ {
			fmt.Fscan(in, &want[j])
		}
		if n > m {
			fmt.Println("NO")
			continue
		}
		k := 0
		for j := 0;j < n-1;j++ {
			if want[j] < want[j+1] {
				k += want[j+1]+1
			}else {
				k += want[j]+1
			}
			if k >= m-want[0] {
				break
			}
		}
		if k + want[n-1] >= m || k >= m-want[0]{
			fmt.Println("NO")
		}else {
			fmt.Println("YES")
		}
	}
}

package main

import "fmt"

func main() {
	t,n,m := 0,0,0
	fmt.Scan(&t)
	for i := 0;i < t;i++ {
		fmt.Scan(&n,&m)
		want := make([]int,n)
		for j := 0;j < n;j++ {
			fmt.Scan(&want[j])
		}
		if n > m {
			println("NO")
			continue
		}
		k := 0
		for j := 0;j < n-1;j++ {
			if want[j] < want[j+1] {
				k += want[j+1]+1
			}else {
				k += want[j]+1
			}
			if k >= m-want[0] {
				break
			}
		}
		if k + want[n-1] >= m || k >= m-want[0]{
			println("NO")
		}else {
			println("YES")
		}
	}
}

package main

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

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)

	for ii := 0; ii < t; ii++ {
		var n, m int
		fmt.Fscan(in, &n, &m)
		nums := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &nums[i])
		}
		sort.Ints(nums)
		used := 1 + nums[n-1]
		for i := n - 2; i >= 0; i-- {
			if i == 0 {
				used += nums[n-1] + 1
			} else {
				used += nums[i] + 1
			}
		}
		if used <= m {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

//4444444444
//4444444444
//4444444444
//4444444444
//4444444444

package main

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

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)

	for ii := 0; ii < t; ii++ {
		var n, m int
		fmt.Fscan(in, &n, &m)
		nums := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &nums[i])
		}
		sort.Ints(nums)
		used := 1 + nums[n-1]*2
		for i := n - 2; i >= 0; i-- {
			if i == 0 {
				used++
			} else {
				used += nums[i] + 1
			}
		}
		if used <= m {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

//4444444444
//4444444444
//4444444444
//4444444444
//4444444444

package main

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

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

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

	var T, x, n, m int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &m)

		row := []int{}
		for i := 0; i < n; i++ {
			Fscan(in, &x)
			row = append(row, x)
		}
		sort.Ints(row)

		u := 1 + 2*row[n-1]
		for i := n - 2; i >= 0; i-- {
			v := row[i]
			u += 1 + v
		}
		u -= row[0]

		if u > m {
			Fprintln(out, "NO")

		} else {
			Fprintln(out, "YES")
		}
	}
}


You are given an array $$$a[0 \dots n-1]$$$ of $$$n$$$ integers. This array is called a "valley" if there exists exactly one subarray $$$a[l \dots r]$$$ such that:  $$$0 \le l \le r \le n-1$$$,  $$$a_l = a_{l+1} = a_{l+2} = \dots = a_r$$$,  $$$l = 0$$$ or $$$a_{l-1} > a_{l}$$$,  $$$r = n-1$$$ or $$$a_r < a_{r+1}$$$. Here are three examples:  The first image shows the array [$$$3, 2, 2, 1, 2, 2, 3$$$], it is a valley because only subarray with indices $$$l=r=3$$$ satisfies the condition.The second image shows the array [$$$1, 1, 1, 2, 3, 3, 4, 5, 6, 6, 6$$$], it is a valley because only subarray with indices $$$l=0, r=2$$$ satisfies the codition.The third image shows the array [$$$1, 2, 3, 4, 3, 2, 1$$$], it is not a valley because two subarrays $$$l=r=0$$$ and $$$l=r=6$$$ that satisfy the condition.You are asked whether the given array is a valley or not.Note that we consider the array to be indexed from $$$0$$$.

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the length of the array. The second line of each test case contains $$$n$$$ integers $$$a_i$$$ ($$$1 \leq a_i \leq 10^9$$$) — the elements of the array. It is guaranteed that the sum of $$$n$$$ over all test cases is smaller than $$$2\cdot10^5$$$.

For each test case, output "YES" (without quotes) if the array is a valley, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).

NoteThe first three test cases are explained in the statement.

package main

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

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

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

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

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

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

/**
Run solve the problem CF1760D
Date: 11/21/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1760/D
Problem: CF1760D
**/
func (in *CF1760D) Run() {
	for t := in.NextInt(); t > 0; t-- {
		nL := in.NextInt()
		arr := make([]int, 0)
		last := -1

		for i := 0; i < nL; i++ {
			val := in.NextInt()
			if last != val {
				arr = append(arr, val)
			}
			last = val
		}
		n := len(arr)

		valley := 0
		for i := 0; i < n; i++ {
			if i == 0 && i+1 < n {
				if arr[i+1] > arr[i] {
					valley++
				}
			} else if i == n-1 && i-1 >= 0 {
				if arr[i-1] > arr[i] {
					valley++
				}
			} else {
				if i-1 >= 0 && i < n && arr[i-1] > arr[i] && arr[i+1] > arr[i] {
					valley++
				}
			}
		}

		//	fmt.Println("Valley ", valley)
		if valley == 1 || len(arr) == 1 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

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

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

package main

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

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

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

		a := make([]int, n + 2)
		a[0] = 1e9 + 7
		a[n+1] = 1e9 + 7
		for i := 1; i <= n; i++ {
			fmt.Fscan(r, &a[i])
		}

		res := "YES"
		cnt := 0

		var on bool
		for i := 1; i <= n && cnt < 2; i++ {
			if a[i] < a[i-1] && a[i] < a[i+1] {
				// fmt.Fprintln(w, "%%%% 1 i", i)
				cnt++
			}
			if a[i] > a[i-1] {
				on = false
				// fmt.Fprintln(w, "%%%% 1 on i", on, i)
			} else if a[i] < a[i-1] {
				on = true
				// fmt.Fprintln(w, "%%%% 2 on i", on, i)
			} else if a[i] < a[i+1] && on {
				// fmt.Fprintln(w, "%%%% 2 i", i)
				cnt++
			}
		}

		// fmt.Fprintln(w, "%%% cnt", cnt)
		if cnt != 1 {
			res = "NO"
		}

		fmt.Fprintln(w, res)

	}

}

package main

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

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

func main() {
	var t, n int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		a := make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a[j])
		}
		s := 0
		for j := 0; j < n; j++ {
			l, r := j-1, j+1
			for l >= 0 && a[l] == a[j] {
				l--
			}
			for r < n && a[j] == a[r] {
				r++
			}
			if l == -1 && r < n && a[j] < a[r] {
				s++
			} else if r == n && l >= 0 && a[j] < a[l] {
				s++
			} else if l >= 0 && r < n && a[j] < a[l] && a[j] < a[r] {
				s++
			}
			if r == n {
				break
			}
			j = r - 1
		}
		if s <= 1 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

const cf = true

func solve() {
	var n int
	fmt.Fscan(in, &n)
	arr := make([]int, n)
	for i := range arr {
		fmt.Fscan(in, &arr[i])
	}
	usedDesc := false
	for i := 1; i < n; i++ {
		if arr[i-1] < arr[i] {
			if !usedDesc {
				usedDesc = true
				continue
			}
		}
		if arr[i-1] > arr[i] {
			if usedDesc {
				fmt.Fprintln(out, "NO")
				return
			}
		}
	}
	fmt.Fprintln(out, "YES")
}

func main() {
	defer out.Flush()
	t := 1
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		solve()
	}
}

func LCM(a, b int) int {
	return a * b / GCD(a, b)
}

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

	return a
}

type SqrtInt interface {
	SignedSqrt | UnsignedSqrt
}

type SignedSqrt interface {
	~int | ~int32 | ~int64
}

type UnsignedSqrt interface {
	~uint | ~uint32 | ~uint64 | ~uintptr
}

func sqrt[T SqrtInt](x T) T {
	l, r := T(0), T(2000000123)
	for l < r {
		mid := (l + r) / 2
		if mid*mid > x {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l - 1
}

func ConvertInt(val string, base, toBase int) (string, error) {
	i, err := strconv.ParseInt(val, base, 64)
	if err != nil {
		return "", err
	}
	return strconv.FormatInt(i, toBase), nil
}

const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1

func reverseStr(s string) string {
	r := []byte(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type Ordered interface {
	Integer | Float | ~string
}

func abs[T Signed](x T) T {
	if x < 0 {
		return -x
	}
	return x
}

func min[T Ordered](x, y T) T {
	if x < y {
		return x
	}
	return y
}

func max[T Ordered](x, y T) T {
	if x > y {
		return x
	}
	return y
}

var (
	in  = getReader()
	out = getWriter()
)

func getReader() *bufio.Reader {
	if cf {
		return bufio.NewReader(os.Stdin)
	} else {
		in, _ := os.Open("input.txt")
		return bufio.NewReader(in)
	}
}

func getWriter() *bufio.Writer {
	if cf {
		return bufio.NewWriter(os.Stdout)
	} else {
		out, _ := os.Create("output.txt")
		return bufio.NewWriter(out)
	}
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"index/suffixarray"
	"log"
	"math"
	"net"
	"os"
	"path"
	"sort"
	"strconv"
	"strings"
	"time"
)

// For Codeforces
func main() {
	io := newStdIO()
	defer io.Flush()
	for T := io.ScanUInt16(); T > 0; T-- {
		solve(&io)
	}
}
func solve(io *IO) {
	n := io.ScanInt32()
	s := make([]int32, n)
	for i := int32(0); i < n; i++ {
		s[i] = io.ScanInt32()
	}

	s = append(s, s[n-1]+1)
	s = append([]int32{s[0] + 1}, s...)
	c := 0
	l := 1
	r := 1
	for {
		for r+1 < len(s) && s[r] == s[r+1] {
			r++
		}
		if s[r] < s[r+1] {
			if c == 1 {
				c++
				goto fin
			} else {
				c++
			}

			for r+1 < len(s) && s[r] <= s[r+1] {
				r++
			}
			l = r
		} else {

			l = r + 1
			r = l
		}
		if r+1 == len(s) {
			break
		}
	}
fin:
	if c == 1 {
		io.PrintLn("YES")
		return
	}
	io.PrintLn("NO")
}
func MaxN(n []int32) int32 {
	m := n[0]
	for i := 1; i < len(n); i++ {
		m = Max(m, n[i])
	}
	return m
}

// #region INTERFACES

// From https://pkg.go.dev/golang.org/x/exp/constraints
type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}
type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}
type Integer interface {
	Signed | Unsigned
}
type Float interface {
	~float32 | ~float64
}
type Complex interface {
	~complex64 | ~complex128
}
type Ordered interface {
	Integer | Float | ~string
}

type Prioritizable[T any] interface {
	PriorTo(x T) bool // If you take this as a relation: if (a,b) in R => (b,a) not in R
}

// #endregion
// #region TYPES WITH METHODS
// #region SingleLinkedList
type singleLinkedListNode[T comparable] struct {
	Value T
	Next  *singleLinkedListNode[T]
}

type SingleLinkedList[T comparable, IndexType Unsigned] struct {
	first  *singleLinkedListNode[T]
	last   *singleLinkedListNode[T]
	length IndexType
}

func NewSingleLinkedList[T comparable, IndexType Unsigned]() *SingleLinkedList[T, IndexType] {
	return &SingleLinkedList[T, IndexType]{
		first:  nil,
		last:   nil,
		length: 0,
	}
}
func (l *SingleLinkedList[T, I]) Len() I { return l.length }

// length > 0
func (l *SingleLinkedList[T, I]) First() T { return l.first.Value }

// length > 0
func (l *SingleLinkedList[T, I]) Last() T { return l.last.Value }

func (l *SingleLinkedList[T, I]) InsertFirst(value T) {
	if l.length == 0 {
		nodeToInsert := &singleLinkedListNode[T]{
			Value: value,
			Next:  l.first,
		}
		l.first = nodeToInsert
		l.last = nodeToInsert
	} else {
		l.first = &singleLinkedListNode[T]{
			Value: value,
			Next:  l.first,
		}
	}
	l.length++
}

func (l *SingleLinkedList[T, I]) InsertLast(value T) {
	if l.length == 0 {
		nodeToInsert := &singleLinkedListNode[T]{
			Value: value,
			Next:  l.first,
		}
		l.first = nodeToInsert
		l.last = nodeToInsert
	} else {
		l.last.Next = &singleLinkedListNode[T]{
			Value: value,
			Next:  nil,
		}
		l.last = l.last.Next
	}
	l.length++
}

// index <= length
func (l *SingleLinkedList[T, I]) InsertAt(index I, value T) {
	if index == 0 {
		l.InsertFirst(value)
		return
	}
	if index == l.length {
		l.InsertLast(value)
		return
	}

	n := l.first
	for index > 1 {
		n = n.Next
		index--
	}
	n.Next = &singleLinkedListNode[T]{
		Value: value,
		Next:  n.Next,
	}
	l.length++
}

func (l *SingleLinkedList[T, I]) Contains(value T) bool {
	tmp := l.first
	for i := I(0); i < l.length; i++ {
		if tmp.Value == value {
			return true
		}
		tmp = tmp.Next
	}
	return false
}
func (l *SingleLinkedList[T, I]) Clear() {
	l.first = nil
	l.last = nil
	l.length = 0
}

// index < length
func (l *SingleLinkedList[T, I]) GetElementAt(index I) T {
	n := l.first
	for index > 0 {
		n = n.Next
		index--
	}
	return n.Value
}

// index < length
func (l *SingleLinkedList[T, I]) SetElementAt(index I, value T) {
	n := l.first
	for index > 0 {
		n = n.Next
		index--
	}
	n.Value = value
}

func (l *SingleLinkedList[T, I]) RemoveFirst() T {
	tmp := l.first
	l.first = l.first.Next
	l.length--
	if l.length == 0 {
		l.last = nil
	}
	return tmp.Value
}
func (l *SingleLinkedList[T, I]) RemoveLast() (value T) {
	value = l.last.Value
	if l.length == 1 {
		l.first = nil
		l.last = nil
		l.length = 0
		return
	}

	tmp := l.first
	for i := I(2); i < l.length; i++ {
		tmp = tmp.Next
	}
	l.last = tmp
	return
}

func (l *SingleLinkedList[T, I]) RemoveAt(index I) T {
	if index == 0 {
		return l.RemoveFirst()
	}
	if index == l.length-1 {
		return l.RemoveLast()
	}

	tmp := l.first
	for i := I(1); i < index; i++ {
		tmp = tmp.Next
	}
	res := tmp.Next.Value
	tmp.Next = tmp.Next.Next
	return res
}

func (l *SingleLinkedList[T, I]) ToSlice() (res []T) {
	res = make([]T, 0, l.length)
	tmp := l.first
	for i := I(0); i < l.length; i++ {
		res = append(res, tmp.Value)
		tmp = tmp.Next
	}
	return
}
func (it *SingleLinkedList[T, I]) String() string {
	return "Qua:: " + fmt.Sprint(it.ToSlice())
}

// #endregion
// #region Queue

type Queue[T comparable, I Unsigned] struct {
	l SingleLinkedList[T, I]
}

func NewQueue[T comparable, I Unsigned]() *Queue[T, I] {
	return &Queue[T, I]{
		l: SingleLinkedList[T, I]{
			first:  nil,
			last:   nil,
			length: 0,
		},
	}
}
func (q *Queue[T, I]) Len() I          { return q.l.length }
func (q *Queue[T, I]) Enqueue(value T) { q.l.InsertLast(value) }
func (q *Queue[T, I]) Dequeue(T) T     { return q.l.RemoveFirst() }
func (q *Queue[T, I]) Preview() T      { return q.l.First() }
func (q *Queue[T, I]) String() string  { return q.l.String() }

// #endregion
// #region Stack

type Stack[T comparable, I Unsigned] struct {
	l SingleLinkedList[T, I]
}

func NewStack[T comparable, I Unsigned]() *Stack[T, I] {
	return &Stack[T, I]{
		l: SingleLinkedList[T, I]{
			first:  nil,
			last:   nil,
			length: 0,
		},
	}
}
func (s *Stack[T, I]) Len() I         { return s.l.length }
func (s *Stack[T, I]) Push(value T)   { s.l.InsertFirst(value) }
func (s *Stack[T, I]) Pop(T) T        { return s.l.RemoveFirst() }
func (s *Stack[T, I]) Preview() T     { return s.l.First() }
func (s *Stack[T, I]) String() string { return s.l.String() }

// #endregion
// #region Heap
type BinaryHeap[T Prioritizable[T], I Signed] struct {
	s []T
}

func NewBinaryHeap[T Prioritizable[T], I Signed](s []T) (h *BinaryHeap[T, I]) {
	h = &BinaryHeap[T, I]{
		s: s,
	}

	for i := (h.Len() - 2) / 2; i >= 0; i-- {
		h.heapifyDown(i)
	}
	return
}
func (h *BinaryHeap[T, I]) Len() I {
	return I(len(h.s))
}
func (h *BinaryHeap[T, I]) Push(value T) {
	h.s = append(h.s, value)
	h.heapifyUp(h.Len() - 1)
}
func (h *BinaryHeap[T, I]) Pop() (res T) {
	res = h.s[0]
	h.s[0] = h.s[h.Len()-1]
	h.s = h.s[:h.Len()-1]
	h.heapifyDown(0)
	return
}

func (h *BinaryHeap[T, I]) heapifyDown(index I) bool {
	origin := index
	for {
		j := index*2 + 2
		if j < h.Len() {
			if h.s[j-1].PriorTo(h.s[j]) {
				j--
			}
		} else {
			if j <= h.Len() && !h.s[j].PriorTo(h.s[index]) {
				h.s[j], h.s[index] = h.s[index], h.s[j]
			}
			break
		}
		if h.s[j].PriorTo(h.s[index]) {
			h.s[j], h.s[index] = h.s[index], h.s[j]
			index = j
		} else {
			break
		}
	}
	return origin != index
}
func (h *BinaryHeap[T, I]) heapifyUp(index I) {
	for {
		parent := (index - 1) / 2
		if parent == index || h.s[parent].PriorTo(h.s[index]) {
			break
		}
		h.s[index], h.s[parent] = h.s[parent], h.s[index]
		index = parent
	}
}

// #endregion

// #endregion

// #region FUNCTIONS
func Max[T Ordered](a, b T) T {
	if a >= b {
		return a
	}
	return b
}
func Min[T Ordered](a, b T) T {
	if a <= b {
		return a
	}
	return b
}
func Abs[T Integer | Float](a T) T {
	if a < 0 {
		return -a
	}
	return a
}
func Swap[T any](a, b *T) {
	*a, *b = *b, *a
}

// At least one != 0
func GCD[T Unsigned](a, b T) T {
	if b < a {
		Swap(&a, &b)
	}
	for {
		if a == 0 {
			return b
		}
		r := (b % a)
		b = a
		a = r
	}
}

// At least one != 0
func LCM[T Unsigned](a, b T) T {
	return (a * b) / GCD(a, b)
}

func First[T any](a T, _ any) T { return a }

// #endregion

// #region IO STUFF
type IO struct {
	r *bufio.Reader
	w *bufio.Writer
}

func newStdIO() IO {
	return IO{
		r: bufio.NewReader(os.Stdin),
		w: bufio.NewWriter(os.Stdout),
	}
}

// Is assumed that input.txt file exists
func newFileIO() IO {
	return IO{
		r: bufio.NewReader(First(os.Open("input.txt"))),
		w: bufio.NewWriter(First(os.OpenFile("output.txt", os.O_CREATE|os.O_RDWR|os.O_TRUNC, os.ModePerm))),
	}
}

func (io *IO) ScanInt8() (x int8)   { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanInt16() (x int16) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanInt32() (x int32) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanInt64() (x int64) { fmt.Fscan(io.r, &x); return }

func (io *IO) ScanUInt8() (x uint8)   { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanUInt16() (x uint16) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanUInt32() (x uint32) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanUInt64() (x uint64) { fmt.Fscan(io.r, &x); return }

func (io *IO) ScanFloat32() (x float32) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanFloat64() (x float64) { fmt.Fscan(io.r, &x); return }

func (io *IO) ScanString() (x string) { fmt.Fscan(io.r, &x); return }

func (io *IO) Print(x ...any)   { fmt.Fprint(io.w, x...) }
func (io *IO) PrintLn(x ...any) { fmt.Fprintln(io.w, x...) }

func (io *IO) Flush() { io.w.Flush() }

// #endregion

// #region KEEP IMPORTS
func D() {
	_ = bufio.Reader{}
	_ = bytes.Buffer{}
	_ = suffixarray.Index{}
	_ = log.Default()
	_ = math.Abs(0)
	_ = net.Dialer{}
	_ = path.ErrBadPattern
	_ = sort.Float64sAreSorted(nil)
	_ = strconv.ErrRange
	_ = strings.Builder{}
	_ = time.ANSIC
	_ = newStdIO()
	_ = newFileIO()
}

// #endregion

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	//输入t
	var t, n int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		nums := make([]int, n)
		right := make([]bool, n)
		left := make([]bool, n)
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &nums[j])
		}
		left[0] = true
		for j := 1; j < n; j++ {
			if nums[j] < nums[j-1] {
				left[j] = true
			}
		}
		right[n-1] = true
		for j := n - 2; j >= 0; j-- {
			if nums[j] < nums[j+1] {
				right[j] = true
			}
		}
		ans := 0
		l := 0
		for r := 0; r < n && l < n; r++ {
			for r < n && nums[r] == nums[l] {
				r++
			}
			r--
			if left[l] && right[r] {
				ans++
			}
			l = r + 1
		}
		// 输出res
		if ans == 1 {
			fmt.Fprint(out, "YES\n")
		} else {
			fmt.Fprint(out, "NO\n")
		}

	}
}

package main

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

func solve(reader *bufio.Reader, writer *bufio.Writer) {
	n := readInt(reader)
	a := readArrayInt(reader)

	var l, r, cnt int
	for i := 0; i < n; i++ {
		if i == 0 || a[i] < a[i-1] {
			l = i
		}
		if i == n-1 || a[i] < a[i+1] {
			r = i
			if l >= 0 && l <= r {
				cnt++
				l = -1
			}
		}
	}
	if cnt == 1 {
		fmt.Fprintln(writer, "YES")
	} else {
		fmt.Fprintln(writer, "NO")
	}
}

func main() {
	reader := bReader(os.Stdin)
	writer := bWriter(os.Stdout)

	t := readInt(reader)

	for t > 0 {
		solve(reader, writer)
		t--
	}

	writer.Flush()
}

func min[T int | int64](a, b T) T {
	if a < b {
		return a
	}

	return b
}

func max[T int | int64](a, b T) T {
	if a > b {
		return a
	}

	return b
}

func abs[T int | int64](a T) T {
	if a < 0 {
		return a * -1
	} else {
		return a
	}
}

func gcd[T int | int64](x, y T) T {
	for y > 0 {
		x, y = y, x%y
	}

	return x
}

func lcm[T int | int64](x, y T) T {
	return x * y / gcd(x, y)
}

func bReader(stdin *os.File) *bufio.Reader {
	return bufio.NewReaderSize(stdin, 16*1024*1024)
}

func bWriter(stdout *os.File) *bufio.Writer {
	return bufio.NewWriterSize(stdout, 16*1024*1024)
}

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

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

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

func readInt(reader *bufio.Reader) int {
	return int(readInt64(reader))
}

func readInt64(reader *bufio.Reader) int64 {
	value, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	return value
}

func readString(reader *bufio.Reader) string {
	return readLine(reader)
}

func readArrayString(reader *bufio.Reader) []string {
	return strings.Split(strings.TrimSpace(readLine(reader)), " ")
}

func readArrayInt(reader *bufio.Reader) []int {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := int(arItemTemp)
		ar = append(ar, arItem)
	}

	return ar
}

func readArrayInt64(reader *bufio.Reader) []int64 {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int64

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := arItemTemp
		ar = append(ar, arItem)
	}

	return ar
}

func readTwoInt(reader *bufio.Reader) (int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1]
}

func readTwoInt64(reader *bufio.Reader) (int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1]
}

func readThreeInt(reader *bufio.Reader) (int, int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1], ar[2]
}

func readThreeInt64(reader *bufio.Reader) (int64, int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1], ar[2]
}

package main

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

var sc = bufio.NewScanner(os.Stdin)

const mod int = 998244353
const N int = 5e5 + 5

func main() {
	sc.Buffer(make([]byte, 500000*1+1), 500000)
	sc.Split(bufio.ScanWords)

	T := nextInt()
	for T > 0 {
		T--
		n := nextInt()
		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = nextInt()
		}
		ans := 0
		for i := 0; i < n; i++ {
			j := i
			for j < n && a[j] == a[i] {
				j++
			}
			j = max(i, j-1)
			if (i == 0 || a[i-1] > a[i]) && (j == n-1 || a[j] < a[j+1]) {
				//fmt.Printf("%d %d\n", i, j)
				ans++
			}
			i = j
		}
		if ans == 1 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func max(args ...int) int {
	res := args[0]
	for _, v := range args {
		if v > res {
			res = v
		}
	}
	return res
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

package main

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

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

// source: _
func solve() {
	n, arr := _readArr()

	a := make([]int, 0, len(arr))
	a = append(a, arr[0])
	for i := 1; i < n; i++ {
		if arr[i] != arr[i-1] {
			a = append(a, arr[i])
		}
	}

	cnt := 0
	na := len(a)
	if na == 1 {
		_print("YES")
		return
	}

	if a[1] > a[0] {
		cnt++
	}
	if a[na-1] < a[na-2] {
		cnt++
	}
	for i := 1; i < na-1; i++ {
		if a[i] < a[i-1] && a[i] < a[i+1] {
			cnt++
		}
	}

	if cnt == 1 {
		_print("YES")
	} else {
		_print("NO")
	}

}

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscanln(in, &t); t > 0; t-- {
		solve()
	}
}

// ====
func _readInt() int {
	var x int
	fmt.Fscan(in, &x)
	return x
}
func _readStr() string {
	var x string
	fmt.Fscan(in, &x)
	return x
}
func _readArr(x ...int) (int, []int) {
	var n int
	if len(x) == 0 {
		fmt.Fscan(in, &n)
	} else {
		n = x[0]
	}
	var v = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &v[i])
	}
	return n, v
}
func _print(x ...any) {
	fmt.Fprintln(out, x...)
}
func _max(x ...int) int {
	mi := 0
	for i := 1; i < len(x); i++ {
		if x[i] > x[mi] {
			mi = i
		}
	}
	return x[mi]
}
func _min(x ...int) int {
	mi := 0
	for i := 1; i < len(x); i++ {
		if x[i] < x[mi] {
			mi = i
		}
	}
	return x[mi]
}
func _sum(x ...int) int {
	res := 0
	for _, i := range x {
		res += i
	}
	return res
}
func _abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}
func _sortStr(x string) string {
	r := []rune(x)
	sort.Slice(r, func(i, j int) bool {
		return r[i] < r[j]
	})
	return string(r)
}
func _reverseInts(x []int) {
	n := len(x)
	for i := 0; i < n/2; i++ {
		x[i], x[n-1-i] = x[n-1-i], x[i]
	}
}
func _reverseStr(s string) string {
	x := []rune(s)
	n := len(x)
	for i := 0; i < n/2; i++ {
		x[i], x[n-1-i] = x[n-1-i], x[i]
	}
	return string(x)
}
func _makeMatrix(n, m int) [][]int {
	x := make([][]int, n)
	for i := range x {
		x[i] = make([]int, m)
	}
	return x
}

package main

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

// https://space.bilibili.com/206214
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

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

		for len(a) > 1 && a[0] >= a[1] {
			a = a[1:]
		}
		for len(a) > 1 && a[0] <= a[1] {
			a = a[1:]
		}
		if len(a) < 2 {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}

	cases := 1
	Fscan(in, &cases)
	for curCase := 1; curCase <= cases; curCase++ {
		solve(curCase)
	}

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

}

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

package main

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

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

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

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

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

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

/**
Run solve the problem CF1760D
Date: 11/21/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1760/D
Problem: CF1760D
**/
func (in *CF1760D) Run() {
	for t := in.NextInt(); t > 0; t-- {
		nL := in.NextInt()
		arr := make([]int, 0)
		last := -1

		for i := 0; i < nL; i++ {
			val := in.NextInt()
			if last != val {
				arr = append(arr, val)
			}
			last = val
		}
		n := len(arr)

		valley := 0
		for i := 0; i < n; i++ {
			if i == 0 && i+1 < n {
				if arr[i+1] > arr[i] {
					valley++
				}
			} else if i == n-1 && i-1 >= 0 {
				if arr[i-1] > arr[i] {
					valley++
				}
			} else {
				if i-1 >= 0 && i < n && arr[i-1] > arr[i] && arr[i+1] > arr[i] {
					valley++
				}
			}
		}

		//	fmt.Println("Valley ", valley)
		if valley == 1 || nL == 1 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

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

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

package main

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

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

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

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

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

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

/**
Run solve the problem CF1760D
Date: 11/21/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1760/D
Problem: CF1760D
**/
func (in *CF1760D) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		arr := make([]int, 0)
		last := -1

		for i := 0; i < n; i++ {
			val := in.NextInt()
			if last != val {
				arr = append(arr, val)
			}
			last = val
		}
		n = len(arr)
		valley := 0
		for i := 2; i < n; i++ {
			if arr[i-2] > arr[i-1] && arr[i-1] < arr[i] {
				//fmt.Println("a")
				valley++
			}
		}

		equals := 0
		for equals < n {
			if arr[equals] == arr[0] {
				equals++
			} else {
				equals--
				break
			}
		}

		if equals < n-1 {
			if arr[equals] < arr[equals+1] {
				//fmt.Println("b", equals, arr[equals], arr[equals+1])
				valley++
			}
		}

		if equals != n {
			equals = n - 1
			for equals > 0 {
				if arr[equals] == arr[n-1] {
					equals--
				} else {
					equals++
					break
				}
			}

			if equals > 0 {
				if arr[equals-1] > arr[equals] {
					//fmt.Println("c", equals, arr[equals], arr[equals-1])
					valley++
				}
			}

		} else {
			valley++
		}
		//	fmt.Println("Valley ", valley)
		if valley == 1 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

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

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

package main

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

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

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

		a := make([]int, n)
		for i := range a {
			fmt.Fscan(r, &a[i])
		}

		res := "YES"
		if n > 1 {
			cnt := 0
			if a[0] < a[1] {
				// fmt.Fprintln(w, "%%%% 1 i", 0)
				cnt++
			}
			if a[n-2] > a[n-1] {
				// fmt.Fprintln(w, "%%%% 2 i", n-1)
				cnt++
			}

			on := true
			for i := 1; i < n-1 && cnt < 2; i++ {
				if a[i] < a[i-1] && a[i] < a[i+1] {
					// fmt.Fprintln(w, "%%%% 3 i", i)
					cnt++
				}
				if a[i] > a[i-1] {
					on = false
					// fmt.Fprintln(w, "%%%% 1 on i", on, i)
				} else if a[i] < a[i-1] {
					on = true
					// fmt.Fprintln(w, "%%%% 2 on i", on, i)
				} else if a[i] < a[i+1] && on {
					// fmt.Fprintln(w, "%%%% 4 i", i)
					cnt++
				}
			}

			// fmt.Fprintln(w, "%%% cnt", cnt)
			if cnt != 1 {
				res = "NO"
			}
		}

		fmt.Fprintln(w, res)

	}

}

package main

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

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

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

		a := make([]int, n)
		for i := range a {
			fmt.Fscan(r, &a[i])
		}

		res := "YES"
		if n > 2 {
			cnt := 0
			if a[0] < a[1] {
				// fmt.Fprintln(w, "%%%% 1 i", 0)
				cnt++
			}
			if a[n-2] > a[n-1] {
				// fmt.Fprintln(w, "%%%% 2 i", n-1)
				cnt++
			}

			on := true
			for i := 1; i < n-1 && cnt < 2; i++ {
				if a[i] < a[i-1] && a[i] < a[i+1] {
					// fmt.Fprintln(w, "%%%% 3 i", i)
					cnt++
				}
				if a[i] > a[i-1] {
					on = false
					// fmt.Fprintln(w, "%%%% 1 on i", on, i)
				} else if a[i] < a[i-1] {
					on = true
					// fmt.Fprintln(w, "%%%% 2 on i", on, i)
				} else if a[i] < a[i+1] && on {
					// fmt.Fprintln(w, "%%%% 4 i", i)
					cnt++
				}
			}

			// fmt.Fprintln(w, "%%% cnt", cnt)
			if cnt != 1 {
				res = "NO"
			}
		}

		fmt.Fprintln(w, res)

	}

}


Two people are playing a game with a string $$$s$$$, consisting of lowercase latin letters. On a player's turn, he should choose two consecutive equal letters in the string and delete them. For example, if the string is equal to "xaax" than there is only one possible turn: delete "aa", so the string will become "xx". A player not able to make a turn loses.Your task is to determine which player will win if both play optimally.

The only line contains the string $$$s$$$, consisting of lowercase latin letters ($$$1 \leq |s| \leq 100\,000$$$), where $$$|s|$$$ means the length of a string $$$s$$$.

If the first player wins, print "Yes". If the second player wins, print "No".

NoteIn the first example the first player is unable to make a turn, so he loses.In the second example first player turns the string into "q", then second player is unable to move, so he loses.

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	s := ""
	fmt.Fscanf(in, "%s\n", &s)
	ans := 0
	st := make([]byte, 0)
	for i := 0; i < len(s); i++ {
		if len(st) > 0 && st[len(st)-1] == s[i] {
			st = st[:len(st)-1]
			ans++
		} else {
			st = append(st, s[i])
		}
	}
	if ans%2 == 0 {
		fmt.Fprintf(out, "No\n")
	} else {
		fmt.Fprintf(out, "Yes\n")
	}
	return
}

package main

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

func min(a,b int)int {
    var res int
    if a<b {
        res=a
    } else {
        res=b;
    }
    return res;
}

func solve(){
    var s string
    var n,i,flag,top int
    flag=0
    var st [100010] int
    top=0
    s=readString()
    n=len(s)
    for i=0;i<n;i++{
        if top==0{
            st[top]=(int)(s[i]-'a')
            top=top+1
        }else if st[top-1]!=(int)(s[i]-'a') {
            st[top]=(int)(s[i]-'a')
            top=top+1
        }else{
            top=top-1
            flag=flag^1
        }
    }
    if flag==0{
        fmt.Println("No")
    }else{
        fmt.Println("Yes")
    }

}

var scanner *bufio.Scanner

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
}

package main

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

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

	str := make([]byte,100100)
	fmt.Fscanf(buf, "%s\n", &str)
	slen := len(string(str))
	sk := make([]byte,slen+10)
	front := 0

	for i:= 0;i < slen;i++{
		if front > 0&&str[i] == sk[front-1]{
			front--
		}else{
			sk[front] = str[i]
			front++
		}
	}
	//fmt.Printf("%d %d\n",slen,front)
	if ((slen-front)/2)%2 == 0{
		fmt.Printf("No\n")
	}else{
		fmt.Printf("Yes\n")
	}
}

package main

import "fmt"

func main() {

	var s string
	fmt.Scanf("%s", &s)

	id := 0
	m := make([]int32, 100010)
	winner := 0

	for i := 0; i < len(s); i++ {
		if id == 0 {
			m[id] = int32(s[i])
			id++
		} else {
			if int32(s[i]) == m[id-1] {
				winner = (winner + 1) % 2
				id--
			} else {
				m[id] = int32(s[i])
				id++
			}

		}
	}

	if winner == 1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

package main

import (
	"fmt"
)

// 1200
// 30.05.2020
// https://codeforces.com/problemset/problem/1104/B

func main() {
	var b []byte
	fmt.Scanln(&b)

	var cnt int
	stack := make([]byte, 50000)
	for _, a := range b {
		if len(stack) > 0 && stack[len(stack)-1] == a {
			stack = stack[:len(stack)-1]
			cnt++
		} else {
			stack = append(stack, a)
		}
	}
	if cnt%2 == 0 {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}