This week Arkady wanted to cook some pancakes (to follow ancient traditions) and make a problem about that. But then he remembered that one can't make a problem about stacking pancakes without working at a specific IT company, so he decided to bake the Napoleon cake instead.To bake a Napoleon cake, one has to bake $$$n$$$ dry layers first, and then put them on each other in one stack, adding some cream. Arkady started with an empty plate, and performed the following steps $$$n$$$ times:   place a new cake layer on the top of the stack;  after the $$$i$$$-th layer is placed, pour $$$a_i$$$ units of cream on top of the stack. When $$$x$$$ units of cream are poured on the top of the stack, top $$$x$$$ layers of the cake get drenched in the cream. If there are less than $$$x$$$ layers, all layers get drenched and the rest of the cream is wasted. If $$$x = 0$$$, no layer gets drenched.  The picture represents the first test case of the example. Help Arkady determine which layers of the cake eventually get drenched when the process is over, and which don't.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 20\,000$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of layers in the cake. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le n$$$) — the amount of cream poured on the cake after adding each layer. 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 $$$n$$$ integers. The $$$i$$$-th of the integers should be equal to $$$1$$$ if the $$$i$$$-th layer from the bottom gets drenched, and $$$0$$$ otherwise.

package main

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

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

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

//https://codeforces.com/problemset/problem/1501/B

func main() {
	defer out.Flush()
	in.Split(bufio.ScanWords)
	in.Buffer(make([]byte, 1024), int(1e+9))
	for t := nextNum(); t > 0; t-- {
		solve1()
	}
}

func solve() {
	n := nextNum()
	a := make([]int, n)
	lo := 0
	for i := 0; i < n; i++ {
		cur := i
		for j := nextNum(); j > 0 && cur >= 0; j-- {
			a[cur] = 1
			if cur <= lo {
				lo = i + 1
				break
			}
			cur--
		}
	}
	for i, v := range a {
		if i == n-1 {
			printf("%d\n", v)
		} else {
			printf("%d ", v)
		}
	}
}

func solve1() {
	n := nextNum()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextNum()
	}
	cur := n
	for i := n - 1; i >= 0; i-- {
		if a[i] > 0 {
			cur = min(cur, max(i-a[i]+1, 0))
			if cur == 0 {
				for j := i; j >= 0; j-- {
					a[j] = 1
				}
				break
			}
		}
		if i < cur {
			a[i] = 0
		} else {
			a[i] = 1
		}
	}

	for i, v := range a {
		if i == n-1 {
			printf("%d\n", v)
		} else {
			printf("%d ", v)
		}
	}
}

func nextNum() int {
	in.Scan()
	var r, f int
	f = 1
	for _, c := range in.Bytes() {
		if c == '-' {
			f = -1
			continue
		}
		r *= 10
		r += int(c - '0')
	}
	return r * f
}

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
}

package main

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

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

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

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

func main() {
	defer writer.Flush()
	var t, n int
	scan(&t)
	out := make([][]int, t)

	for i := 0; i < t; i++ {
		scan(&n)
		a := make([]int, n)
		for j := 0; j < n; j++ {
			scan(&a[j])
		}
		ans := make([]int, n)
		med := 0
		for j := n - 1; j >= 0; j-- {
			med = max(med, a[j])
			if med > 0 {
				ans[j] = 1
			} else {
				ans[j] = 0
			}
			med--
		}
		out[i] = ans
	}
	for i := 0; i < t; i++ {
		for j := 0; j < len(out[i]); j++ {
			fmt.Printf("%d ", out[i][j])
		}
		fmt.Println()
	}
}

package main

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

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

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

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

func main() {
	//reader := bufio.NewReader(os.Stdin)
	//t, _ := reader.ReadString('\n')
	var t, n int
	scan(&t)
	out := make([][]int, t)

	for i := 0; i < t; i++ {
		scan(&n)
		a := make([]int, n)
		for j := 0; j < n; j++ {
			scan(&a[j])
		}
		ans := make([]int, n)
		med := 0
		for j := n - 1; j >= 0; j-- {
			med = max(med, a[j])
			if med > 0 {
				ans[j] = 1
			} else {
				ans[j] = 0
			}
			med--
		}
		out[i] = ans
	}
	for i := 0; i < t; i++ {
		for j := 0; j < len(out[i]); j++ {
			fmt.Printf("%d ", out[i][j])
		}
		fmt.Println("")
	}
}

package main

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

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

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

func main() {
	defer out.Flush()
	in.Split(bufio.ScanWords)
	in.Buffer(make([]byte, 1024), int(1e+9))
	for t := nextNum(); t > 0; t-- {
		solve()
	}
}

func solve() {
	n := nextNum()
	arr := make([]int, n + 2)
	for i := 1; i <= n; i++ {
		num := nextNum()
		if num == 0 {
			continue
		}
		arr[i]++
		if i - num > 0 {
			arr[i - num]--
		}
	}
	for i := n; i > 0; i-- {
		arr[i] = arr[i + 1] + arr[i]
	}
	for i := 1; i <= n; i++ {
		var res = 0
		if arr[i] > 0 {
			res = 1
		}
		arr[i] = 0
		if i == n {
			printf("%d\n", res)
		} else {
			printf("%d ", res)
		}
	}

}

func nextNum() int {
	in.Scan()
	var r, f int
	f = 1
	for _, c := range in.Bytes() {
		if c == '-' {
			f = -1
			continue
		}
		r *= 10
		r += int(c - '0')
	}
	return r * f
}

// 00
package main

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

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}
func write_int(f *bufio.Writer, a int) {
	f.Write([]byte(strconv.Itoa(a)))
}
func write_string(f *bufio.Writer, a string) {
	f.Write([]byte(a))
}

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n int
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		ans := make([]int, n)
		curr := n
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		for i := n - 1; i >= 0; i-- {
			curr = min(curr, i-a[i]+1)
			if curr <= i {
				ans[i] = 1
			} else {
				ans[i] = 0
			}
		}
		for i := 0; i < n; i++ {
			write_int(f, ans[i])
			if i == n-1 {
				write_string(f, "\n")
			} else {
				write_string(f, " ")
			}
		}
	}
}

package main

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

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)

	var b strings.Builder

	for i := 0; i < t; i++ {
		var n int
		scanf("%d\n", &n)

		a := make([]int, n)

		for j := 0; j < n; j++ {
			scanf("%d", &a[j])
		}
		scanf("\n")

		cream := 0
		for j := n - 1; j >= 0; j-- {
			cream = max(cream, a[j])
			if cream > 0 {
				a[j] = 1
				cream--
			}
		}

		for j := 0; j < n; j++ {
			fmt.Fprintf(&b, "%d ", a[j])
		}
		fmt.Fprintf(&b, "\n")
	}

	printf(b.String())
}

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

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

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

package main

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

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

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

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

func sint() int { // ~[-2e9, 2e9]
	s := sstring()
	i := 0
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int(r - '0')
	}
	return i
}

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

func sint64() int64 { // ~[-9e18, 9e18]
	s := sstring()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func sint64s(n int64) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = sint64()
	}
	return a
}

func sstring() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

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

type Layer struct {
	drenched bool
	prev     int64
}

func (n Layer) String() string {
	if n.drenched {
		return "1"
	}
	return "0"
}

func sol(n int64, a []int64) []Layer {
	ret := make([]Layer, n)
	for i := range ret {
		ret[i].prev = int64(i - 1)
	}
	var f func(int64, int64) int64
	f = func(curr, target int64) int64 {
		if curr < 0 {
			return -1
		}
		if curr < target {
			panic("something went wrong")
		}
		ret[curr].drenched = true
		if target == curr {
			return ret[curr].prev
		}
		if ret[curr].prev < target {
			return ret[curr].prev
		}
		prev := f(ret[curr].prev, target)
		ret[curr].prev = prev
		return prev
	}
	for i := range a {
		if a[i] == 0 {
			continue
		}
		curr := int64(i)
		target := curr - a[i] + 1
		f(curr, target)
	}
	return ret
}

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n := 0, 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n)
		o, p := make([]int, n), make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &o[j])
		}
		c := 0
		for j := n - 1; j >= 0; j-- {
			if c == 0 && o[j] == 0 {
				p[j] = 0
			} else {
				p[j] = 1
				if o[j] > c {
					c = o[j]
				}
				c--
			}
		}
		for j := 0; j < n; j++ {
			fmt.Fprint(w, p[j], " ")
		}
		fmt.Fprintln(w, "")
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

var fields []string

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

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

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

	if err != nil {
		panic(err)
	}

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

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

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

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

	if err != nil {
		panic(err)
	}

	return n
}

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

	if err != nil {
		panic(err)
	}

	return n
}

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

		for i := range a {
			a[i] = ScanInt()
		}

		for i, carry := n-1, 0; i >= 0; i-- {
			if a[i] > carry {
				carry = a[i]
			}

			if carry > 0 {
				carry--
				a[i] = 1
			} else {
				a[i] = 0
			}
		}

		fmt.Println(strings.Trim(fmt.Sprint(a), "[]"))
	}
}

package main

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

func R(s string) (a string) {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < j; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	a = string(r)
	return
}

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

func yes() {
	p("YES")
}

func no() {
	p("NO")
}

func remove(slice []int, s int) []int {
	return append(slice[:s], slice[s+1:]...)
}

func dch(s []rune, index int) []rune {
	return append(s[0:index], s[index+1:]...)
}

func p(a ...interface{})            { fmt.Fprint(writer, a...) }
func pln(a ...interface{})          { fmt.Fprintln(writer, a...) }
func s(a ...interface{})            { fmt.Fscan(reader, a...) }
func pf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func sf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {
	defer writer.Flush()
	////////////////
	c := 0
	s(&c)
	for c != 0 {
		solve()
		c--
	}
	////////////////
}

func solve() {
	n := 0
	s(&n)
	m := make([]int, n)
	m1 := make([]int, n)
	for i := n-1; i >= 0; i--{
		s(&m[i])
	}
	t := 0
	for i := 0; i < n; i++ {
		if t == 0 && m[i] == 0 {
			continue
		}
		if m[i] > t {
			t = m[i]
		}
		if t != 0 {
			m1[i] = 1
			t--
		}
	}
	for i :=  n-1; i >= 0; i-- {
		p(m1[i], " ")
	}
	pln()
}

package main

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

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

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

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

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

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

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

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

	ans := make([]int, n)

	st := []int{}
	for i := 0; i < n; i++ {
		st = append(st, i)
	}

	for i := n - 1; i >= 0; i-- {
		for len(st) > 0 {
			top := st[len(st)-1]
			if top > i {
				st = st[:len(st)-1]
			} else {
				break
			}
		}

		for len(st) > 0 {
			top := st[len(st)-1]
			if top > i-a[i] {
				ans[top] = 1
				st = st[:len(st)-1]
			} else {
				break
			}
		}
	}

	for i := range ans {
		printf("%d ", ans[i])
	}
	printf("\n")
}

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

	ans := 0
	prev := 0

	for i := range a {
		ans += a[i] - prev + tm[i]
		if i == n-1 {
			break
		}

		need := (b[i] - a[i] + 1) / 2
		stay := 0
		if ans < b[i] {
			stay = b[i] - ans
			ans = b[i]
		}
		if stay < need {
			ans += need - stay
		}

		prev = b[i]
	}

	printf("%d\n", ans)
}

package main

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

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

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

//https://codeforces.com/problemset/problem/1501/B

func main() {
	defer out.Flush()
	in.Split(bufio.ScanWords)
	in.Buffer(make([]byte, 1024), int(1e+9))
	for t := nextNum(); t > 0; t-- {
		solve1()
	}
}

func solve() {
	n := nextNum()
	a := make([]int, n)
	lo := 0
	for i := 0; i < n; i++ {
		cur := i
		for j := nextNum(); j > 0 && cur >= 0; j-- {
			a[cur] = 1
			if cur <= lo {
				lo = i + 1
				break
			}
			cur--
		}
	}
	for i, v := range a {
		if i == n-1 {
			printf("%d\n", v)
		} else {
			printf("%d ", v)
		}
	}
}

func solve1() {
	n := nextNum()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextNum()
	}
	cur := n
	for i := n - 1; i > 0; i-- {
		if a[i] > 0 {
			cur = min(cur, max(i-a[i]+1, 0))
			if cur == 0 {
				for j := i; j >= 0; j-- {
					a[j] = 1
				}
				break
			}
		}
		if i < cur {
			a[i] = 0
		} else {
			a[i] = 1
		}
	}

	for i, v := range a {
		if i == n-1 {
			printf("%d\n", v)
		} else {
			printf("%d ", v)
		}
	}
}

func nextNum() int {
	in.Scan()
	var r, f int
	f = 1
	for _, c := range in.Bytes() {
		if c == '-' {
			f = -1
			continue
		}
		r *= 10
		r += int(c - '0')
	}
	return r * f
}

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
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scanf("%d", &t)
	var arr [200007]int = [200007]int{}
	for ; t > 0; t-- {
		var n int
		fmt.Scanf("%d", &n)
		for i := 1; i <= n; i++ {
			var num int
			fmt.Scanf("%d", &num)
			if num == 0 {
				continue
			}
			arr[i]++
			if i - num > 0 {
				arr[i - num]--
			}
		}
		for i := n; i > 0; i-- {
			arr[i] = arr[i + 1] + arr[i]
		}
		for i := 1; i <= n; i++ {
			var res = 0
			if arr[i] > 0 {
				res = 1
			}
			arr[i] = 0
			if i == n {
				fmt.Printf("%d\n", res)
			} else {
				fmt.Printf("%d ", res)
			}
		}
	}
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scanf("%d", &t)
	var arr [200007]int = [200007]int{}
	for ; t > 0; t-- {
		var n int
		fmt.Scanf("%d", &n)
		for i := 1; i <= n; i++ {
			var num int
			fmt.Scanf("%d", &num)
			if num == 0 {
				continue
			}
			arr[i]++
			if i - num > 0 {
				arr[i - num]--
			}
		}
		for i := n; i > 0; i-- {
			arr[i] = arr[i + 1] + arr[i]
		}
		for i := 1; i <= n; i++ {
			var res = 0
			if arr[i] > 0 {
				res = 1
			}
			arr[i] = 0
			if i == n {
				fmt.Println(res)
			} else {
				fmt.Printf("%d ", res)
			}
		}
	}
}

package main

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

func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)

	for i := 0; i < t; i++ {
		var n int
		scanf("%d\n", &n)

		a := make([]int, n)

		for j := 0; j < n; j++ {
			scanf("%d", &a[j])
		}

		cream := 0
		for j := n - 1; j >= 0; j-- {
			cream = max(cream, a[j])
			if cream > 0 {
				a[j] = 1
				cream--
			}
		}

		for j := 0; j < n; j++ {
			printf("%d ", a[j])
		}
		printf("\n")
	}
}

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

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

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


You are given two strings $$$s$$$ and $$$t$$$. The string $$$s$$$ consists of lowercase Latin letters and at most one wildcard character '*', the string $$$t$$$ consists only of lowercase Latin letters. The length of the string $$$s$$$ equals $$$n$$$, the length of the string $$$t$$$ equals $$$m$$$.The wildcard character '*' in the string $$$s$$$ (if any) can be replaced with an arbitrary sequence (possibly empty) of lowercase Latin letters. No other character of $$$s$$$ can be replaced with anything. If it is possible to replace a wildcard character '*' in $$$s$$$ to obtain a string $$$t$$$, then the string $$$t$$$ matches the pattern $$$s$$$.For example, if $$$s=$$$"aba*aba" then the following strings match it "abaaba", "abacaba" and "abazzzaba", but the following strings do not match: "ababa", "abcaaba", "codeforces", "aba1aba", "aba?aba".If the given string $$$t$$$ matches the given string $$$s$$$, print "YES", otherwise print "NO".

The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 2 \cdot 10^5$$$) — the length of the string $$$s$$$ and the length of the string $$$t$$$, respectively. The second line contains string $$$s$$$ of length $$$n$$$, which consists of lowercase Latin letters and at most one wildcard character '*'. The third line contains string $$$t$$$ of length $$$m$$$, which consists only of lowercase Latin letters.

Print "YES" (without quotes), if you can obtain the string $$$t$$$ from the string $$$s$$$. Otherwise print "NO" (without quotes).

NoteIn the first example a wildcard character '*' can be replaced with a string "force". So the string $$$s$$$ after this replacement is "codeforces" and the answer is "YES".In the second example a wildcard character '*' can be replaced with an empty string. So the string $$$s$$$ after this replacement is "vkcup" and the answer is "YES".There is no wildcard character '*' in the third example and the strings "v" and "k" are different so the answer is "NO".In the fourth example there is no such replacement of a wildcard character '*' that you can obtain the string $$$t$$$ so the answer is "NO".

package main

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

func main()  {

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

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

	var s, t string
	fmt.Fscanf(in, "%s\n%s\n", &s, &t)

	starIndex := strings.Index(s, "*")

	if starIndex == -1 {

		if len(s) != len(t) {
			fmt.Fprintln(out, "NO")
			return
		}

		for i := 0; i < len(s); i++ {
			if s[i] != t[i] {
				fmt.Fprintln(out, "NO")
				return
			}
		}

		fmt.Fprintln(out, "YES")
		return

	}

	if len(t) < len(s) - 1 {
		fmt.Fprintln(out, "NO")
		return
	}

	for i := 0; i < starIndex; i++ {
		if s[i] != t[i] {
			fmt.Fprintln(out, "NO")
			return
		}
	}

	for i := starIndex + 1; i < len(s); i++ {
		if s[i] != t[len(t) + i - len(s)] {
			fmt.Fprintln(out, "NO")
			return
		}
	}

	fmt.Fprintln(out, "YES")

}

package main

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

func main() {
	r := bufio.NewReaderSize(os.Stdin, 1024*1024)
	lens := readInts(r, 2)
	t := readString(r, lens[0])
	s := readString(r, lens[1])

	if check(t, s) {
		fmt.Print("YES")
	} else {
		fmt.Print("NO")
	}
}

func check(t, s string) bool {
	bits := strings.Split(t, "*")
	if len(bits) > 2 {
		return false
	}
	if len(bits) == 1 {
		return t == s
	}
	if len(s) < len(bits[0]) + len(bits[1]) {
		return false
	}

	return bits[0] == s[:len(bits[0])] && bits[1] == s[len(s)-len(bits[1]):]
}

func readString(reader *bufio.Reader, l int) string {
	sTemp := readLine(reader)
	if len(sTemp) < l {
		l = len(sTemp)
	}
	return sTemp[:l]
}

func readInts(reader *bufio.Reader, n int) []int {
	tmpInts := strings.Split(readLine(reader), " ")

	var result []int
	for i := 0; i < n; i++ {
		tmpInt, err := strconv.ParseInt(tmpInts[i], 10, 64)
		checkError(err)
		result = append(result, int(tmpInt))
	}
	return result
}

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

package main

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

func main() {
	r := bufio.NewReaderSize(os.Stdin, 1024*1024)
	lens := readInts(r, 2)
	t := readString(r, lens[0])
	s := readString(r, lens[1])

	if check(t, s) {
		fmt.Print("YES")
	} else {
		fmt.Print("NO")
	}
}

func check(t, s string) bool {
	if len(s) < len(t)-1 {
		return false
	}

	i := 0
	for ; i < len(t); i++ {
		if t[i] == '*' {
			break
		}

		if i >= len(s) || t[i] != s[i] {
			return false
		}
	}

	if i == len(t) {
		return i == len(s)
	}

	for j := 1; len(t) - j > i; j++ {
		if t[len(t) - j] != s[len(s) - j] {
			return false
		}
	}

	return true
}

func readString(reader *bufio.Reader, l int) string {
	sTemp := readLine(reader)
	if len(sTemp) < l {
		l = len(sTemp)
	}
	return sTemp[:l]
}

func readInts(reader *bufio.Reader, n int) []int {
	tmpInts := strings.Split(readLine(reader), " ")

	var result []int
	for i := 0; i < n; i++ {
		tmpInt, err := strconv.ParseInt(tmpInts[i], 10, 64)
		checkError(err)
		result = append(result, int(tmpInt))
	}
	return result
}

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

package main

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

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

	ns, _ := r.ReadString(' ')
	n, _ := strconv.Atoi(ns[:len(ns)-1])

	ms, _ := r.ReadString('\n')
	m, _ := strconv.Atoi(ms[:len(ms)-1])

	ts, _ := r.ReadString('\n')
	t := ts[:n]

	ss, _ := r.ReadString('\n')
	s := ss[:m]

	if check(t, s) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}

func check(t string, s string) bool {
	if t == s {
		return true
	}

	if len(s) < len(t)-1 {
		return false
	}

	i := 0
	for ; i < len(t); i++ {
		if t[i] == '*' {
			break
		}

		if t[i] != s[i] {
			return false
		}
	}

	for j := 1; len(t) - j > i; j++ {
		if t[len(t) - j] != s[len(s) - j] {
			return false
		}
	}

	return true
}

package main

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

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

	ns, _ := r.ReadString(' ')
	n, _ := strconv.Atoi(ns[:len(ns)-1])

	ms, _, _ := r.ReadLine()
	m, _ := strconv.Atoi(string(ms))

	ts, _, _ := r.ReadLine()
	t := string(ts[:n])

	ss, _, _ := r.ReadLine()
	s := string(ss[:m])

	fmt.Println(t, s)

	if check(t, s) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}

func check(t string, s string) bool {
	if t == s {
		return true
	}

	if len(s) < len(t)-1 {
		return false
	}

	i := 0
	for ; i < len(t); i++ {
		if t[i] == '*' {
			break
		}

		if t[i] != s[i] {
			return false
		}
	}

	for j := 1; len(t) - j > i; j++ {
		if t[len(t) - j] != s[len(s) - j] {
			return false
		}
	}

	return true
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	lens := readInts(r, 2)
	t := readString(r, lens[0])
	s := readString(r, lens[1])

	if check(t, s) {
		fmt.Print("YES")
	} else {
		fmt.Print("NO")
	}
}

func check(t, s string) bool {
	bits := strings.Split(t, "*")
	if len(bits) > 2 {
		return false
	}
	if len(bits) == 1 {
		return t == s
	}
	if len(s) < len(bits[0]) + len(bits[1]) {
		return false
	}

	return bits[0] == s[:len(bits[0])] && bits[1] == s[len(s)-len(bits[1]):]
}

func readString(reader *bufio.Reader, l int) string {
	sTemp := readLine(reader)
	if len(sTemp) < l {
		l = len(sTemp)
	}
	return sTemp[:l]
}

func readInts(reader *bufio.Reader, n int) []int {
	tmpInts := strings.Split(readLine(reader), " ")

	var result []int
	for i := 0; i < n; i++ {
		tmpInt, err := strconv.ParseInt(tmpInts[i], 10, 64)
		checkError(err)
		result = append(result, int(tmpInt))
	}
	return result
}

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

package main

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

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

	ns, _ := r.ReadString(' ')
	n, _ := strconv.Atoi(ns[:len(ns)-1])

	ms, _, _ := r.ReadLine()
	m, _ := strconv.Atoi(string(ms))

	ts, _, _ := r.ReadLine()
	t := string(ts[:n])

	ss, _, _ := r.ReadLine()
	s := string(ss[:m])

	fmt.Println(t, s)

	if check(t, s) {
		fmt.Print("YES")
	} else {
		fmt.Print("NO")
	}

}

func check(t string, s string) bool {
	if t == s {
		return true
	}

	if len(s) < len(t)-1 {
		return false
	}

	i := 0
	for ; i < len(t); i++ {
		if t[i] == '*' {
			break
		}

		if t[i] != s[i] {
			return false
		}
	}

	for j := 1; len(t) - j > i; j++ {
		if t[len(t) - j] != s[len(s) - j] {
			return false
		}
	}

	return true
}


Let's define a function $$$f(x)$$$ ($$$x$$$ is a positive integer) as follows: write all digits of the decimal representation of $$$x$$$ backwards, then get rid of the leading zeroes. For example, $$$f(321) = 123$$$, $$$f(120) = 21$$$, $$$f(1000000) = 1$$$, $$$f(111) = 111$$$.Let's define another function $$$g(x) = \dfrac{x}{f(f(x))}$$$ ($$$x$$$ is a positive integer as well).Your task is the following: for the given positive integer $$$n$$$, calculate the number of different values of $$$g(x)$$$ among all numbers $$$x$$$ such that $$$1 \le x \le n$$$.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \le n < 10^{100}$$$). This integer is given without leading zeroes.

For each test case, print one integer — the number of different values of the function $$$g(x)$$$, if $$$x$$$ can be any integer from $$$[1, n]$$$.

NoteExplanations for the two first test cases of the example:  if $$$n = 4$$$, then for every integer $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$;  if $$$n = 37$$$, then for some integers $$$x$$$ such that $$$1 \le x \le n$$$, $$$\dfrac{x}{f(f(x))} = 1$$$ (for example, if $$$x = 23$$$, $$$f(f(x)) = 23$$$,$$$\dfrac{x}{f(f(x))} = 1$$$); and for other values of $$$x$$$, $$$\dfrac{x}{f(f(x))} = 10$$$ (for example, if $$$x = 30$$$, $$$f(f(x)) = 3$$$, $$$\dfrac{x}{f(f(x))} = 10$$$). So, there are two different values of $$$g(x)$$$.

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

package main

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

var (
	t int

	N []rune
)

func main() {
	defer stdout.Flush()

	t = readi()
	for tc := 0; tc < t; tc++ {
		N = readrs()
		printf("%d\n", len(N))
	}
}

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

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

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

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

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

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

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

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

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

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

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

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

	return s
}

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

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

	if e == 0 {
		return 1
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

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

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

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

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

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

	return res
}

package main

import (
	"fmt"
)

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

package main

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

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

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

	for ; t > 0; t-- {
		fmt.Fscan(in, &n)
		fmt.Println(len([]rune(n)))
	}
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var out bytes.Buffer

func main() {
	var t int
	fmt.Fscan(reader, &t)

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

		fmt.Fprintln(&out, len(n))
	}

	fmt.Println(out.String())
}

package main

import (
	"fmt"
)

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


Alice has a very important message M consisting of some non-negative integers that she wants to keep secret from Eve. Alice knows that the only theoretically secure cipher is one-time pad. Alice generates a random key K of the length equal to the message's length. Alice computes the bitwise xor of each element of the message and the key (, where  denotes the bitwise XOR operation) and stores this encrypted message A. Alice is smart. Be like Alice.For example, Alice may have wanted to store a message M = (0, 15, 9, 18). She generated a key K = (16, 7, 6, 3). The encrypted message is thus A = (16, 8, 15, 17).Alice realised that she cannot store the key with the encrypted message. Alice sent her key K to Bob and deleted her own copy. Alice is smart. Really, be like Alice.Bob realised that the encrypted message is only secure as long as the key is secret. Bob thus randomly permuted the key before storing it. Bob thinks that this way, even if Eve gets both the encrypted message and the key, she will not be able to read the message. Bob is not smart. Don't be like Bob.In the above example, Bob may have, for instance, selected a permutation (3, 4, 1, 2) and stored the permuted key P = (6, 3, 16, 7).One year has passed and Alice wants to decrypt her message. Only now Bob has realised that this is impossible. As he has permuted the key randomly, the message is lost forever. Did we mention that Bob isn't smart?Bob wants to salvage at least some information from the message. Since he is not so smart, he asks for your help. You know the encrypted message A and the permuted key P. What is the lexicographically smallest message that could have resulted in the given encrypted text?More precisely, for given A and P, find the lexicographically smallest message O, for which there exists a permutation π such that  for every i.Note that the sequence S is lexicographically smaller than the sequence T, if there is an index i such that Si < Ti and for all j < i the condition Sj = Tj holds.

The first line contains a single integer N (1 ≤ N ≤ 300000), the length of the message.  The second line contains N integers A1, A2, ..., AN (0 ≤ Ai < 230) representing the encrypted message. The third line contains N integers P1, P2, ..., PN (0 ≤ Pi < 230) representing the permuted encryption key.

Output a single line with N integers, the lexicographically smallest possible message O. Note that all its elements should be non-negative.

NoteIn the first case, the solution is (10, 3, 28), since ,  and . Other possible permutations of key yield messages (25, 6, 10), (25, 3, 15), (10, 21, 10), (15, 21, 15) and (15, 6, 28), which are all lexicographically larger than the solution.

package main

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

const (
	AlphaSize = 2
	MaxDigits = 30
)

var powers [MaxDigits + 1]int

type trie struct {
	count int
	alpha [AlphaSize]*trie
}

func NewTrie() *trie {
	return &trie{
		count: 0,
	}
}

func (t *trie) insert(num int) {
	t.count++
	node := t
	for i := MaxDigits; i >= 0; i-- {
		a := (num >> uint(i)) & 1
		if node.alpha[a] == nil {
			node.alpha[a] = &trie{}
		}
		node.alpha[a].count++
		node = node.alpha[a]
	}
}

func (t *trie) pop(num int) int {
	t.count--
	node := t
	found := 0
	for i := MaxDigits; i >= 0; i-- {
		a := (num >> uint(i)) & 1
		b := a
		if node.alpha[a] == nil || node.alpha[a].count == 0 {
			b = 1 - a
		}
		node = node.alpha[b]
		node.count--
		found += b * powers[i]
	}
	return found
}

func init() {
	powers[0] = 1
	for i := 1; i <= MaxDigits; i++ {
		powers[i] = 2 * powers[i-1]
	}
}

var n int
var a []int
var root *trie

func main() {
	inBuf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(inBuf, "%d\n", &n)
	a = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(inBuf, "%d", &a[i])
	}
	fmt.Fscanf(inBuf, "\n")
	root = NewTrie()
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Fscanf(inBuf, "%d", &tmp)
		root.insert(tmp)
	}
	outBuf := bufio.NewWriter(os.Stdout)
	defer func() { outBuf.Flush() }()
	for i := 0; i < n; i++ {
		fmt.Fprintf(outBuf, "%d ", a[i] ^ root.pop(a[i]))
	}
}


Recently Maxim has found an array of n integers, needed by no one. He immediately come up with idea of changing it: he invented positive integer x and decided to add or subtract it from arbitrary array elements. Formally, by applying single operation Maxim chooses integer i (1 ≤ i ≤ n) and replaces the i-th element of array ai either with ai + x or with ai - x. Please note that the operation may be applied more than once to the same position.Maxim is a curious minimalis, thus he wants to know what is the minimum value that the product of all array elements (i.e. ) can reach, if Maxim would apply no more than k operations to it. Please help him in that.

The first line of the input contains three integers n, k and x (1 ≤ n, k ≤ 200 000, 1 ≤ x ≤ 109) — the number of elements in the array, the maximum number of operations and the number invented by Maxim, respectively. The second line contains n integers a1, a2, ..., an () — the elements of the array found by Maxim.

Print n integers b1, b2, ..., bn in the only line — the array elements after applying no more than k operations to the array. In particular,  should stay true for every 1 ≤ i ≤ n, but the product of all array elements should be minimum possible. If there are multiple answers, print any of them.

package main

import (
	"bufio"
	"container/heap"
	. "fmt"
	"io"
	"os"
)

type pair struct {
	v int64
	i int
}
type hp []pair

func (h hp) Len() int            { return len(h) }
func (h hp) Less(i, j int) bool  { return h[i].v < h[j].v }
func (h hp) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *hp) Push(v interface{}) { *h = append(*h, v.(pair)) }
func (h *hp) Pop() interface{}   { a := *h; v := a[len(a)-1]; *h = a[:len(a)-1]; return v }
func (h *hp) push(v pair)        { heap.Push(h, v) }
func (h *hp) pop() pair          { return heap.Pop(h).(pair) }

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

	var n, k, x int64
	Fscan(in, &n, &k, &x)
	sign, minI := int64(1), 0
	a := make([]int64, n)
	for i := range a {
		Fscan(in, &a[i])
		if a[i] < 0 {
			sign = -sign
		}
		if abs(a[i]) < abs(a[minI]) {
			minI = i
		}
	}

	if sign > 0 {
		if abs(a[minI]) >= k*x {
			for i, v := range a {
				if i == minI {
					if v < 0 {
						v += k * x
					} else {
						v -= k * x
					}
				}
				Fprint(out, v, " ")
			}
			return
		}
		c := abs(a[minI])/x + 1
		if a[minI] < 0 {
			a[minI] += c * x
		} else {
			a[minI] -= c * x
		}
		k -= c
	}
	h := make(hp, n)
	for i, v := range a {
		h[i] = pair{abs(v), i}
	}
	heap.Init(&h)
	for ; k > 0; k-- {
		p := h.pop()
		h.push(pair{p.v + x, p.i})
	}
	ans := make([]interface{}, n)
	for _, p := range h {
		if a[p.i] < 0 {
			ans[p.i] = -p.v
		} else {
			ans[p.i] = p.v
		}
	}
	Fprint(out, ans...)
}

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

package main

import (
	"bufio"
	"container/heap"
	. "fmt"
	"io"
	"os"
)

type pair struct {
	v int64
	i int
}
type hp []pair

func (h hp) Len() int            { return len(h) }
func (h hp) Less(i, j int) bool  { return h[i].v < h[j].v }
func (h hp) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *hp) Push(v interface{}) { *h = append(*h, v.(pair)) }
func (h *hp) Pop() interface{}   { a := *h; v := a[len(a)-1]; *h = a[:len(a)-1]; return v }

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

	var n, k, x int64
	Fscan(in, &n, &k, &x)
	sign, minI := int64(1), 0
	a := make([]int64, n)
	for i := range a {
		Fscan(in, &a[i])
		if a[i] < 0 {
			sign = -sign
		}
		if abs(a[i]) < abs(a[minI]) {
			minI = i
		}
	}

	if sign > 0 {
		if abs(a[minI]) >= k*x {
			for i, v := range a {
				if i == minI {
					if v < 0 {
						v += k * x
					} else {
						v -= k * x
					}
				}
				Fprint(out, v, " ")
			}
			return
		}
		c := abs(a[minI])/x + 1
		if a[minI] < 0 {
			a[minI] += c * x
		} else {
			a[minI] -= c * x
		}
		k -= c
	}
	h := make(hp, n)
	for i, v := range a {
		h[i] = pair{abs(v), i}
	}
	heap.Init(&h)
	for ; k > 0; k-- {
		p := h[0]
		p.v += x
		h[0] = p
		heap.Fix(&h, 0)
	}
	ans := make([]interface{}, n)
	for _, p := range h {
		if a[p.i] < 0 {
			ans[p.i] = -p.v
		} else {
			ans[p.i] = p.v
		}
	}
	Fprint(out, ans...)
}

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

package main

import (
	"bufio"
	"container/heap"
	. "fmt"
	"io"
	"os"
)

type pair struct {
	v int64
	i int
}
type hp []pair

func (h hp) Len() int            { return len(h) }
func (h hp) Less(i, j int) bool  { return h[i].v < h[j].v }
func (h hp) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *hp) Push(v interface{}) { *h = append(*h, v.(pair)) }
func (h *hp) Pop() interface{}   { a := *h; v := a[len(a)-1]; *h = a[:len(a)-1]; return v }

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

	var n, k, x int64
	Fscan(in, &n, &k, &x)
	sign, minI := int64(1), 0
	a := make([]int64, n)
	for i := range a {
		Fscan(in, &a[i])
		if a[i] < 0 {
			sign = -sign
		}
		if abs(a[i]) < abs(a[minI]) {
			minI = i
		}
	}

	if sign > 0 {
		if abs(a[minI]) >= k*x {
			for i, v := range a {
				if i == minI {
					if v < 0 {
						v += k * x
					} else {
						v -= k * x
					}
				}
				Fprint(out, v, " ")
			}
			return
		}
		c := abs(a[minI])/x + 1
		if a[minI] < 0 {
			a[minI] += c * x
		} else {
			a[minI] -= c * x
		}
		k -= c
	}
	h := make(hp, n)
	for i, v := range a {
		h[i] = pair{abs(v), i}
	}
	heap.Init(&h)
	for ; k > 0; k-- {
		h[0].v += x
		heap.Fix(&h, 0)
	}
	ans := make([]interface{}, n)
	for _, p := range h {
		if a[p.i] < 0 {
			ans[p.i] = -p.v
		} else {
			ans[p.i] = p.v
		}
	}
	Fprint(out, ans...)
}

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

package main

import (
	"bufio"
	"container/heap"
	. "fmt"
	"io"
	"os"
)

type pair struct {
	v int64
	i int
}
type hp []pair

func (h hp) Len() int            { return len(h) }
func (h hp) Less(i, j int) bool  { return h[i].v < h[j].v }
func (h hp) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *hp) Push(v interface{}) { *h = append(*h, v.(pair)) }
func (h *hp) Pop() interface{}   { a := *h; v := a[len(a)-1]; *h = a[:len(a)-1]; return v }
func (h *hp) push(v pair)        { heap.Push(h, v) }
func (h *hp) pop() pair          { return heap.Pop(h).(pair) }

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

	var n, k, x int64
	Fscan(in, &n, &k, &x)
	sign, minI := int64(1), 0
	a := make([]int64, n)
	for i := range a {
		Fscan(in, &a[i])
		if a[i] < 0 {
			sign = -sign
		}
		if abs(a[i]) < abs(a[minI]) {
			minI = i
		}
	}

	if sign > 0 {
		if abs(a[minI]) >= k*x {
			for i, v := range a {
				if i == minI {
					v -= sign * k * x
				}
				Fprint(out, v, " ")
			}
			return
		}
		c := abs(a[minI])/x + 1
		a[minI] -= sign * c * x
		k -= c
	}
	h := make(hp, n)
	for i, v := range a {
		h[i] = pair{abs(v), i}
	}
	heap.Init(&h)
	for ; k > 0; k-- {
		p := h.pop()
		h.push(pair{p.v + x, p.i})
	}
	ans := make([]interface{}, n)
	for _, p := range h {
		if a[p.i] < 0 {
			ans[p.i] = -p.v
		} else {
			ans[p.i] = p.v
		}
	}
	Fprint(out, ans...)
}

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

package main

import (
	"bufio"
	"container/heap"
	. "fmt"
	"io"
	"os"
)

type pair struct {
	v int64
	i int
}
type hp []pair

func (h hp) Len() int            { return len(h) }
func (h hp) Less(i, j int) bool  { return h[i].v < h[j].v }
func (h hp) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *hp) Push(v interface{}) { *h = append(*h, v.(pair)) }
func (h *hp) Pop() interface{}   { a := *h; v := a[len(a)-1]; *h = a[:len(a)-1]; return v }
func (h *hp) push(v pair)        { heap.Push(h, v) }
func (h *hp) pop() pair          { return heap.Pop(h).(pair) }

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

	var n, k, x int64
	Fscan(in, &n, &k, &x)
	minI := 0
	a := make([]int64, n)
	for i := range a {
		Fscan(in, &a[i])
		if a[i] < a[minI] {
			minI = i
		}
	}

	if a[minI] >= k*x {
		for i, v := range a {
			if i == minI {
				v -= k * x
			}
			Fprint(out, v, " ")
		}
		return
	}
	if a[minI] >= 0 {
		c := a[minI]/x + 1
		a[minI] -= c * x
		k -= c
	}
	h := make(hp, n)
	for i, v := range a {
		h[i] = pair{abs(v), i}
	}
	heap.Init(&h)
	for ; k > 0; k-- {
		p := h.pop()
		h.push(pair{p.v + x, p.i})
	}
	ans := make([]interface{}, n)
	for _, p := range h {
		if a[p.i] < 0 {
			ans[p.i] = -p.v
		} else {
			ans[p.i] = p.v
		}
	}
	Fprint(out, ans...)
}

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


$$$n$$$ heroes fight against each other in the Arena. Initially, the $$$i$$$-th hero has level $$$a_i$$$.Each minute, a fight between two different heroes occurs. These heroes can be chosen arbitrarily (it's even possible that it is the same two heroes that were fighting during the last minute).When two heroes of equal levels fight, nobody wins the fight. When two heroes of different levels fight, the one with the higher level wins, and his level increases by $$$1$$$.The winner of the tournament is the first hero that wins in at least $$$100^{500}$$$ fights (note that it's possible that the tournament lasts forever if no hero wins this number of fights, then there is no winner). A possible winner is a hero such that there exists a sequence of fights that this hero becomes the winner of the tournament.Calculate the number of possible winners among $$$n$$$ heroes.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 500$$$) — the number of test cases. Each test case consists of two lines. The first line contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the number of heroes. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 100$$$), where $$$a_i$$$ is the initial level of the $$$i$$$-th hero.

For each test case, print one integer — the number of possible winners among the given $$$n$$$ heroes.

NoteIn the first test case of the example, the only possible winner is the first hero.In the second test case of the example, each fight between the heroes results in nobody winning it, so the tournament lasts forever and there is no winner.

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1487A(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var T, n, v int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		mi, c := 101, 0
		for i := 0; i < n; i++ {
			if Fscan(in, &v); v < mi {
				mi, c = v, n-1
			} else if v == mi {
				c--
			}
		}
		Fprintln(out, c)
	}
}

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

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		list:= make([]int,n)
		var smallest int
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
			if j == 0 {
				smallest = list[j]
			} else {
				if list[j] < smallest {
					smallest= list[j]
				}
			}
		}
		var counter int
		for j:=0;j<n;j++{
			if list[j] > smallest {
				counter++
			}
		}
		fmt.Fprintln(out,counter)
	}
}

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n := 0, 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n)
		o, p, min, tot := []int{}, 0, 10000, 0
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &p)
			o = append(o, p)
			if p < min {
				min = p
			}
		}
		for j := 0; j < n; j++ {
			if min == o[j] {
				tot++
			}
		}
		fmt.Fprintln(w, n-tot)
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1487A
Date: 8/11/21
User: pepradere
URL: https://codeforces.com/problemset/problem/1487/A
Problem: CF1487A
**/
func (in *CF1487A) Run() {
	t := in.NextInt()
	for ; t > 0; t-- {
		n := in.NextInt()
		arr := make([]int, 101)
		for i := 0; i < n; i++ {
			num := in.NextInt()
			arr[num]++
		}

		find := false
		sol := 0
		for i := 0; i < 101; i++ {
			if find && arr[i] > 0 {
				sol += arr[i]
			}
			if arr[i] > 0 {
				find = true
			}
		}

		fmt.Println(sol)

	}
}

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

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

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	t, n   int
)

func solve(n int, a []int) int {
	var (
		m = 101
		c int
	)
	for _, x := range a {
		if x < m {
			m = x
		}
	}
	for _, x := range a {
		if x == m {
			c++
		}
	}
	return n - c
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		fmt.Println(solve(n, a))
	}
}

package main

import "fmt"

func main() {
	t := 0
	fmt.Scan(&t)
	for ; t > 0; t-- {
		n := 0
		fmt.Scan(&n)
		min_num, min_cnt := 105, 1
		for i := 0; i < n; i++ {
			x := 0
			fmt.Scan(&x)
			if x < min_num {
				min_num, min_cnt = x, 1
			} else if x == min_num {
				min_cnt++
			}
		}
		fmt.Println(n - min_cnt)
	}
}

package main

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

var bytes []byte

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

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

	b := nextByte()

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

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

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

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

func ScanString() string {
	builder := strings.Builder{}

	for b := nextByte(); b != '\r'; b = nextByte() {
		if b != '\n' {
			builder.WriteByte(b)
		}
	}

	return builder.String()
}

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

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

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

func main() {
	for t := scanInt(); t > 0; t-- {
		n := scanInt()
		min, cnt := math.MaxInt32, 0

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

			if a < min {
				min, cnt = a, i
			} else if a > min {
				cnt++
			}
		}

		fmt.Println(cnt)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var t, n int
	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])
		}
		min := findMin(a)
		c := countMin(a, min)
		fmt.Println(n - c)
	}
}

func findMin(a []int) int {
	min := math.MaxInt16
	n := len(a)
	for j := 0; j < n; j++ {
		if min > a[j] {
			min = a[j]
		}
	}
	return min
}

func countMin(a []int, min int) int {
	c := 0
	n := len(a)
	for j := 0; j < n; j++ {
		if min == a[j] {
			c++
		}
	}
	return c
}

package main

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

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

	tc := readNum(reader)

	var buf bytes.Buffer

	for tc > 0 {
		tc--
		n := readNum(reader)
		A := readNNums(reader, n)
		res := solve(n, A)
		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
}

func solve(n int, A []int) int {
	sort.Ints(A)

	i := 1
	for i < n && A[i] == A[0] {
		i++
	}
	return n - i
}

package main

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

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

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	t := getI()
	forEach(t, func(i int64) {
		heroes := getI()
		levels := getInts(heroes)
		sortInts(levels)
		idx := upperBound(levels, levels[0])
		out(len(levels) - idx)
	})
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

package main

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

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

	var T, n, v int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		mi, c := 101, 0
		for i := 0; i < n; i++ {
			if Fscan(in, &v); v < mi {
				mi, c = v, n-1
			} else if v == mi {
				c--
			}
		}
		Fprintln(out, c)
	}
}

package main

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

var in = bufio.NewReader(os.Stdin)

func solve() {
	var n int
	fmt.Fscan(in, &n)
	arr := make([]int, n)
	for i := 0; i < len(arr); i++ {
		fmt.Fscan(in, &arr[i])
	}
	sort.Ints(arr)
	i := 1
	found := false
	for i < len(arr) {
		if arr[i-1] < arr[i] {
			found = true
			break
		}
		i++
	}
	if found == true {
		t := len(arr) - i
		fmt.Println(t)
	} else {
		fmt.Println(0)
	}

}

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

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

func main()  {
	s:=bufio.NewScanner(os.Stdin)
	s.Scan()
	l,_:=strconv.Atoi(s.Text())
	for i:=0; i<l;i++{
		s.Scan()
		s.Scan()
		str:=strings.Split(strings.Trim(strings.Trim(s.Text(), "\n"), "\r")," ")
		var m []int
		for j:=0; j<len(str); j++{
			p,_ := strconv.Atoi(str[j])
			m=append(m, p)
		}
		fmt.Println(fn(m))
	}
}

func fn(a []int)(res int){
	min:=101
	for i:=0; i<len(a); i++{
		if a[i] < min{
			min = a[i]
		}
	}
	for i:=0; i<len(a); i++{
		if a[i] > min{
			res++
		}
	}
	return res
}

package main

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

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

	for tc := 0; tc < tcs; tc++ {
		var n int
		_, _ = fmt.Fscan(in, &n)
		arr := make([]int, n)
		hash := make([]int, 101)

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

		found := 0
		for i := 0; i < 101; i++ {
			if hash[i] > 0 {
				found = hash[i]
				break
			}
		}

		fmt.Println(n - found)
	}
}

package main

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

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

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

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

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

		}
		return initial
	}
}

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

}

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

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

		ARRAY := make([]int, n)

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

		sort.Ints(ARRAY)
		indesxx := 0
		for i := 1; i < n; i++ {
			if ARRAY[i] > ARRAY[0] {
				indesxx = i
				break
			}
		}
		if indesxx == 0 {
			fmt.Println(0)
		} else {
			fmt.Println(n - indesxx)
		}

	}

}

package main

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

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

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

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

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

func sint64s(n int64) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = sint64()
	}
	return a
}

func sstring() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		a := sint64s(n)
		printf("%d\n", sol(n, a))
	}
}

func sol(n int64, a []int64) int64 {
	sort.Slice(a, func(il, ir int) bool {
		return a[il] < a[ir]
	})
	for i := 1; i < len(a); i++ {
		if a[i-1] != a[i] {
			return int64(len(a) - i)
		}
	}
	return 0
}

package main

import (
	"fmt"
	"log"
	"os"
	"strings"
)

type bufferedReader struct {
	buf     [4096]byte
	ptr, sz int
	eof     bool
	ended   bool
	in      *os.File
}

func newReader(in *os.File) bufferedReader {
	var tmp [4096]byte
	return bufferedReader{tmp, 0, 0, false, false, in}
}

func (r *bufferedReader) isEof() bool {
	return r.eof
}

func (r *bufferedReader) load() {
	if r.ended {
		r.eof = true
		return
	}
	sz, err := r.in.Read(r.buf[:])
	r.sz = sz
	if sz < 4096 {
		r.ended = true
	}
	if err != nil {
		log.Fatal(err)
	}
	r.ptr = 0
}

func (r *bufferedReader) getChar() byte {
	if r.ptr == r.sz && !r.eof {
		r.load()
	}
	if r.ptr == r.sz || r.eof {
		r.eof = true
		return 0
	}
	r.ptr += 1
	return r.buf[r.ptr-1]
}

func (r *bufferedReader) skipNonIntChars() {
	for {
		c := r.getChar()
		if r.eof {
			break
		}
		if (c >= 48 && c <= 57) || (c == 45) {
			r.ptr -= 1
			break
		}
	}
}

func (r *bufferedReader) skipWhitespace() {
	for {
		c := r.getChar()
		if r.eof {
			break
		}
		if c != ' ' && c != '\n' && c != '\t' && c != '\r' {
			r.ptr -= 1
			break
		}
	}
}

func (r *bufferedReader) readInt() int {
	r.skipNonIntChars()
	var ans int = 0
	var neg bool = false
	fst := r.getChar()
	if fst == 45 {
		neg = true
	} else {
		ans = int(fst) - 48
	}
	for {
		c := r.getChar()
		if r.eof {
			break
		}
		if c >= 48 && c <= 57 {
			ans = ans*10 + int(c-48)
		} else {
			r.ptr -= 1
			break
		}
	}
	if neg {
		ans = -ans
	}
	return ans
}

func (r *bufferedReader) readString() string {
	r.skipWhitespace()
	sz := 0
	capacity := 2
	s := make([]byte, 2)
	for {
		c := r.getChar()
		if r.eof {
			break
		}
		if c == ' ' || c == '\n' || c == '\t' || c == '\r' {
			r.ptr--
			break
		}
		if sz == capacity {
			capacity <<= 1
			s1 := make([]byte, capacity)
			for i := 0; i < sz; i++ {
				s1[i] = s[i]
			}
			s = s1
		}
		s[sz] = c
		sz++
	}
	return string(s[:sz])
}

func main() {
	var in bufferedReader
	hostname, err := os.Hostname()
	if err != nil {
		log.Fatal(err)
	}
	if strings.HasSuffix(hostname, "lenovo") {
		file, _ := os.Open("input.txt")
		in = newReader(file)
	} else {
		in = newReader(os.Stdin)
	}
	T := in.readInt()
	for t := 0; t < T; t++ {
		n := in.readInt()
		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = in.readInt()
		}
		mi := 1488
		for i := 0; i < n; i++ {
			if a[i] < mi {
				mi = a[i]
			}
		}
		ans := 0
		for i := 0; i < n; i++ {
			if a[i] != mi {
				ans++
			}
		}
		fmt.Printf("%d\n", ans)
	}
}


A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and ai < aj. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3).You are given a permutation a of size n and m queries to it. Each query is represented by two indices l and r denoting that you have to reverse the segment [l, r] of the permutation. For example, if a = [1, 2, 3, 4] and a query l = 2, r = 4 is applied, then the resulting permutation is [1, 4, 3, 2].After each query you have to determine whether the number of inversions is odd or even.

The first line contains one integer n (1 ≤ n ≤ 1500) — the size of the permutation.  The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ n) — the elements of the permutation. These integers are pairwise distinct. The third line contains one integer m (1 ≤ m ≤ 2·105) — the number of queries to process. Then m lines follow, i-th line containing two integers li, ri (1 ≤ li ≤ ri ≤ n) denoting that i-th query is to reverse a segment [li, ri] of the permutation. All queries are performed one after another.

Print m lines. i-th of them must be equal to odd if the number of inversions in the permutation after i-th query is odd, and even otherwise.

NoteThe first example:  after the first query a = [2, 1, 3], inversion: (2, 1);  after the second query a = [2, 3, 1], inversions: (3, 1), (3, 2). The second example:  a = [1, 2, 4, 3], inversion: (4, 3);  a = [3, 4, 2, 1], inversions: (3, 1), (4, 1), (3, 2), (4, 2), (4, 3);  a = [1, 2, 4, 3], inversion: (4, 3);  a = [1, 4, 2, 3], inversions: (3, 2), (4, 2).

package main

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

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

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

func toInt(buf []byte) (o int) {
	for _, v := range buf {
		o = o*10 + int(v-'0')
	}
	return
}

type pair struct {
	first int
	second uint8
}

type pairs []pair

func (a pairs) Len() int {return len(a)}
func (a pairs) Swap(i,j int) {a[i], a[j] = a[j], a[i]}
func (a pairs) Less(i,j int) bool {
	return a[i].first < a[j].first
	if a[i].first > a[j].first {
		return false
	}
	return a[i].second <= a[j].second
}

var a,cnt [1500]int

func main() {
	in := bufio.NewReader(os.Stdin)
	//in, _ := os.Open("a.txt")
	var n,ans,m int
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; i < n; i++ {
		if i == n - 1 {
			fmt.Fscanf(in, "%d\n", &a[i])
		} else {
			fmt.Fscanf(in, "%d ", &a[i])
		}
		a[i]--
		cnt[a[i]]++
		for j := a[i] + 1; j < n; j++ {
			ans += cnt[j]
		}
	}
	ans %= 2
	fmt.Fscanf(in, "%d\n", &m)
	for i := 0; i < m; i++ {
		var l,r int
		fmt.Fscanf(in, "%d %d\n", &l, &r)
		r -= l
		r *= r + 1
		r /= 2
		if r % 2 == 1 {
			ans ^= 1
		}
		if ans == 1 {
			fmt.Println("odd")
		} else {
			fmt.Println("even")
		}
	}
}

package main

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

func main() {
	fsc := NewFastScanner()
	N := fsc.NextInt()
	A := fsc.NextIntArray()
	M := fsc.NextInt()
	result := 0
	for i := 0; i < N; i++ {
		for j := 0; j < i; j++ {
			if A[i] < A[j] {
				result++
			}
		}
	}
	result = result % 2
	for i := 0; i < M; i++ {
		l, r := fsc.NextInt(), fsc.NextInt()
		cnt := r - l + 1
		res := cnt * (cnt - 1) / 2
		result = (result + res) % 2
		if result%2 == 0 {
			fmt.Println("even")
		} else {
			fmt.Println("odd")
		}
	}
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

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

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

	return result
}

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

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

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

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

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

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}

package main

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

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

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

func toInt(buf []byte) (o int) {
	for _, v := range buf {
		o = o*10 + int(v-'0')
	}
	return
}

type pair struct {
	first int
	second uint8
}

type pairs []pair

func (a pairs) Len() int {return len(a)}
func (a pairs) Swap(i,j int) {a[i], a[j] = a[j], a[i]}
func (a pairs) Less(i,j int) bool {
	return a[i].first < a[j].first
	if a[i].first > a[j].first {
		return false
	}
	return a[i].second <= a[j].second
}

var a,cnt [1500]int

func main() {
	in := bufio.NewReader(os.Stdin)
	//in, _ := os.Open("a.txt")
	var n,ans,m int
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d", &a[i])
		a[i]--
		cnt[a[i]]++
		for j := a[i] + 1; j < n; j++ {
			ans += cnt[j]
		}
	}
	ans %= 2
	fmt.Fscanf(in, "%d\n", &m)
	for i := 0; i < m; i++ {
		var l,r int
		fmt.Fscanf(in, "%d %d\n", &l, &r)
		r -= l
		r *= r + 1
		r /= 2
		if r % 2 == 1 {
			ans ^= 1
		}
		if ans == 1 {
			fmt.Println("odd")
		} else {
			fmt.Println("even")
		}
	}
}