A has a string consisting of some number of lowercase English letters 'a'. He gives it to his friend B who appends some number of letters 'b' to the end of this string. Since both A and B like the characters 'a' and 'b', they have made sure that at this point, at least one 'a' and one 'b' exist in the string.B now gives this string to C and he appends some number of letters 'c' to the end of the string. However, since C is a good friend of A and B, the number of letters 'c' he appends is equal to the number of 'a' or to the number of 'b' in the string. It is also possible that the number of letters 'c' equals both to the number of letters 'a' and to the number of letters 'b' at the same time.You have a string in your hands, and you want to check if it is possible to obtain the string in this way or not. If it is possible to obtain the string, print "YES", otherwise print "NO" (without the quotes).

The first and only line consists of a string $$$S$$$ ($$$ 1 \le |S| \le 5\,000 $$$). It is guaranteed that the string will only consist of the lowercase English letters 'a', 'b', 'c'.

Print "YES" or "NO", according to the condition.

NoteConsider first example: the number of 'c' is equal to the number of 'a'. Consider second example: although the number of 'c' is equal to the number of the 'b', the order is not correct.Consider third example: the number of 'c' is equal to the number of 'b'.

package main

import (
	"fmt"
	"regexp"
)

var pattern = regexp.MustCompile("^(a+)(b+)(c+)$")

func main() {
	var s []byte
	fmt.Scan(&s)
	r := pattern.FindSubmatch(s)
	if r != nil && (len(r[1]) == len(r[3]) || len(r[2]) == len(r[3])) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

package main

import "fmt"

func Resolve(input string) string {
	var a, b, c int

	for _, char := range input {
		switch char {
		case 'a':
			if (b != 0) || (c != 0) {
				return "NO"
			}
			a += 1
		case 'b':
			if (a == 0) || (c != 0) {
				return "NO"
			}
			b += 1
		case 'c':
			if (a == 0) || (b == 0) {
				return "NO"
			}
			c += 1
		default:
			panic("got invalid character")
		}
	}

	if (b == 0) || (a == 0) {
		return "NO"
	}

	if (c == a) || (c == b) {
		return "YES"
	}

	return "NO"
}

func main() {
	var input string
	fmt.Scanln(&input)

	fmt.Println(Resolve(input))
}

// You can edit this code!
// Click here and start typing.
package main

import (
	"fmt"
	"os"
)

func main() {
	var s string
	fmt.Scan(&s)
	for i := 0; i < len(s)-1; i++ {
		if s[i] > s[i+1] {
			fmt.Print("NO\n")
			os.Exit(0)
		}
	}
	var cnt [26]int
	for i := 0; i < len(s); i++ {
		cnt[s[i]-'a']++
	}
	if cnt[0] > 0 && cnt[1] > 0 && (cnt[2] == cnt[0] || cnt[2] == cnt[1]) {
		fmt.Print("YES\n")
	} else {
		fmt.Print("NO\n")
	}
}

package main

import "fmt"

func solve()  {
	var s string
	fmt.Scan(&s)
	var a, b, c = 0, 0, 0
	i, l := 0, len(s)
	for i < l && s[i] == 'a'{
		i++
		a++
	}
	for i < l && s[i] == 'b' {
		i++
		b++
	}
	for i < l && s[i] == 'c' {
		i++
		c++
	}
	if i != l || a == 0 || b == 0 || c == 0 || (a != c && b != c) {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}

func main() {
	solve()
}

package main

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

func solve() {
	s := readString()
	cnt := make([]int, 26)
	for i := 0; i < len(s); i++ {
		cnt[s[i]-'a']++
	}
	s = regexp.MustCompile("a+").ReplaceAllString(s, "a")
	s = regexp.MustCompile("b+").ReplaceAllString(s, "b")
	s = regexp.MustCompile("c+").ReplaceAllString(s, "c")
	if len(s) == 3 && s[0] == 'a' && s[1] == 'b' && s[2] == 'c' && (cnt[0] == cnt[2] || cnt[1] == cnt[2]) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

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 abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

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

// IO

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

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

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

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

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

package main

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

func Init() {
}

func Solve(io *FastIO) {
	S := io.NextLine()

	A := 0
	B := 0
	C := 0
	for _, c := range S {
	  if c == 'a' {
	    if B > 0 || C > 0 {
	      io.Println("NO")
	      return
	    }
      A++
	  } else if c == 'b' {
	    if A == 0 || C > 0 {
	      io.Println("NO")
	      return
	    }
	    B++
	  } else if c == 'c' {
	    if A == 0 || B == 0 {
	      io.Println("NO")
	      return
	    }
	    C++
	  }
	}
	if A > 0 && B > 0 && (C == A || C == B) {
	  io.Println("YES")
	} else {
	  io.Println("NO")
	}
}

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

func IsLineBreakChar(c byte) bool {
	switch c {
		case 0, '\n', '\r':
			return true
		default:
			return false
	}
}

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

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

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

	input, err := inputReader.ReadString('\n')
	if err != nil {
		panic(err)
	}

	input = strings.Trim(input, "\n\r")

	fmt.Print(Solve(input))
}

func Solve(input string) string {
	inputLen := len(input)
	currentIndex := 0
	countA := 0
	countB := 0
	countC := 0

	for currentIndex < inputLen && input[currentIndex] == 'a' {
		countA++
		currentIndex++
	}

	if countA == 0 {
		return "NO"
	}

	for currentIndex < inputLen && input[currentIndex] == 'b' {
		countB++
		currentIndex++
	}

	if countB == 0 {
		return "NO"
	}

	for currentIndex < inputLen && input[currentIndex] == 'c' {
		countC++
		currentIndex++
	}

	if countC == 0 {
		return "NO"
	}

	if currentIndex != inputLen {
		return "NO"
	}

	if countA == countC || countB == countC {
		return "YES"
	}

	return "NO"
}

package main

import "fmt"

func main() {
	var s string
	fmt.Scanln(&s)

	t := map[int32]int{}

	n := 'a'
	b := true
	for k,v := range s{
		AGAIN:
			if v == n {
				t[v]++
			}else if k != 0 && v > n {
				n++
				goto AGAIN
			}else{
				fmt.Print("NO")
				b = false
				break
			}
	}
	if b {
		if (t['c'] == t['a'] || t['c'] == t['b']) && len(s) > 0 && t['c'] != 0 && t['b'] != 0 && t['c'] != 0{
			fmt.Print("YES")
		}else {
			fmt.Print("NO")
		}
	}
}

package main

import (
    "fmt"
)

func main() {
    var s string
    fmt.Scanf("%s", &s)
    length := len(s)
    na := 0
    nb := 0
    nc := 0
    flag := true
    for i := 0; i < length; i++ {
        if s[i] == 'a' && nb == 0 && nc == 0{
            na++
        }else if s[i] == 'b' && na != 0 && nc == 0{
            nb++
        }else if s[i] == 'c' && na != 0 && nb !=0{
            nc++
        }else{
            flag = false
        }
    }
    if flag && nc != 0 && (nc == na || nc == nb){
        fmt.Println("YES")
    }else{
        fmt.Println("NO")
    }
}

package main

import (
    "fmt"
)

func main() {
    var s string
    fmt.Scanf("%s", &s)
    length := len(s)
    na := 0
    nb := 0
    nc := 0
    flag := true
    for i := 0; i < length; i++ {
        if s[i] == 'a' && nb == 0 && nc == 0{
            na++
        }else if s[i] == 'b' && nc == 0{
            nb++
        }else if s[i] == 'c'{
            nc++
        }else{
            flag = false
        }
    }
    if flag {
        fmt.Println("YES")
    }else{
        fmt.Println("NO")
    }
}

package main

import (
    "fmt"
)

func main() {
    var s string
    fmt.Scanf("%s", &s)
    length := len(s)
    na := 0
    nb := 0
    nc := 0
    flag := true
    for i := 0; i < length; i++ {
        if s[i] == 'a' && nb == 0 && nc == 0{
            na++
        }else if s[i] == 'b' && na != 0 && nc == 0{
            nb++
        }else if s[i] == 'c' && na != 0 && nc ==0{
            nc++
        }else{
            flag = false
        }
    }
    if flag && (nc == na || nc == nb){
        fmt.Println("YES")
    }else{
        fmt.Println("NO")
    }
}

package main

import "fmt"

func main() {
	var s []byte
	fmt.Scan(&s)
	var a, b, c int
	for _, s := range s {
		switch s {
		case 'a':
			if b != 0 || c != 0 {
				fmt.Println("NO")
				return
			}
			a++
		case 'b':
			if a == 0 || c != 0 {
				fmt.Println("NO")
				return
			}
			b++
		case 'c':
			if a == 0 || b == 0 {
				fmt.Println("NO")
				return
			}
			c++
		}
	}
	if a == c || b == c {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

package main

import (
	"fmt"
	"regexp"
)

var pattern = regexp.MustCompile("^(a+)(b+)(c+)$")

func main() {
	var s []byte
	fmt.Scan(&s)
	r := pattern.FindSubmatch(s)
	if r != nil && (len(r[1]) == len(r[2]) || len(r[1]) == len(r[3])) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

package main

import "fmt"

var (
	a int
	b int
	c int
)

func Resolve(input string) string {
	for _, char := range input {
		switch char {
		case 'a':
			a += 1
		case 'b':
			b += 1
		case 'c':
			c += 1
		default:
			panic("got invalid character")
		}
	}

	if (c == a) || (c == b) {
		return "YES"
	}

	return "NO"

	return "YES"
}

func main() {
	var input string
	fmt.Scanln(&input)

	fmt.Println(Resolve(input))
}

package main

import "fmt"

func Resolve(input string) string {
	var a, b, c int

	for _, char := range input {
		switch char {
		case 'a':
			if (b != 0) || (c != 0) {
				return "NO"
			}
			a += 1
		case 'b':
			if (a == 0) || (c != 0) {
				return "NO"
			}
			b += 1
		case 'c':
			if (a == 0) || (b == 0) {
				return "NO"
			}
			c += 1
		default:
			panic("got invalid character")
		}
	}

	if (c == a) || (c == b) {
		return "YES"
	}

	return "NO"

	return "YES"
}

func main() {
	var input string
	fmt.Scanln(&input)

	fmt.Println(Resolve(input))
}

// You can edit this code!
// Click here and start typing.
package main

import (
	"fmt"
	"os"
)

func main() {
	var s string
	fmt.Scan(&s)
	for i := 0; i < len(s)-1; i++ {
		if s[i] > s[i+1] {
			fmt.Print("NO\n")
			os.Exit(0)
		}
	}
	var cnt [26]int
	for i := 0; i < len(s); i++ {
		cnt[s[i]-'a']++
	}
	if cnt[2] == cnt[0] || cnt[2] == cnt[1] {
		fmt.Print("YES\n")
	} else {
		fmt.Print("NO\n")
	}
}

// You can edit this code!
// Click here and start typing.
package main

import (
	"fmt"
	"os"
)

func main() {
	var s string
	fmt.Scan(&s)
	for i := 0; i < len(s)-1; i++ {
		if s[i] > s[i+1] {
			fmt.Print("NO\n")
			os.Exit(0)
		}
	}
	var cnt [26]int
	for i := 0; i < len(s); i++ {
		cnt[s[i]-'a']++
	}
	if cnt[2] == cnt[0] || cnt[2] == cnt[1] || cnt[2] == cnt[0]+cnt[1] {
		fmt.Print("YES\n")
	} else {
		fmt.Print("NO\n")
	}
}

package main

import (
	"fmt"
	"regexp"
)

func main() {
	var s string
	fmt.Scan(&s)
	part, _ := regexp.Compile("ab+c")
	ret := part.FindString(s)
	if ret != "" {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	if strings.Contains(s, "abc") {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

package main

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

func solve() {
	s := readString()
	s = regexp.MustCompile("a+").ReplaceAllString(s, "a")
	s = regexp.MustCompile("b+").ReplaceAllString(s, "b")
	s = regexp.MustCompile("c+").ReplaceAllString(s, "c")
	if len(s) == 3 && s[0] == 'a' && s[1] == 'b' && s[2] == 'c' {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

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 abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

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

// IO

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

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

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

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

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

package main

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

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

	input, err := inputReader.ReadString('\n')
	if err != nil {
		panic(err)
	}

	fmt.Println([]byte(input))

	input = strings.Trim(input, "\n ")

	fmt.Print(Solve(input))
}

func Solve(input string) string {
	inputLen := len(input)
	currentIndex := 0
	countA := 0
	countB := 0
	countC := 0

	for currentIndex < inputLen && input[currentIndex] == 'a' {
		countA++
		currentIndex++
	}

	if countA == 0 {
		return "NO"
	}

	for currentIndex < inputLen && input[currentIndex] == 'b' {
		countB++
		currentIndex++
	}

	if countB == 0 {
		return "NO"
	}

	for currentIndex < inputLen && input[currentIndex] == 'c' {
		countC++
		currentIndex++
	}

	if countC == 0 {
		return "NO"
	}

	if currentIndex != inputLen {
		return "NO"
	}

	if countA == countC || countB == countC {
		return "YES"
	}

	return "NO"
}

package main

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

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

	input, err := inputReader.ReadString('\n')
	if err != nil {
		panic(err)
	}

	fmt.Print(Solve(input))
}

func Solve(input string) string {
	inputLen := len(input)
	currentIndex := 0
	countA := 0
	countB := 0
	countC := 0

	for currentIndex < inputLen && input[currentIndex] == 'a' {
		countA++
		currentIndex++
	}

	if countA == 0 {
		return "NO"
	}

	for currentIndex < inputLen && input[currentIndex] == 'b' {
		countB++
		currentIndex++
	}

	if countB == 0 {
		return "NO"
	}

	for currentIndex < inputLen && input[currentIndex] == 'c' {
		countC++
		currentIndex++
	}

	if countC == 0 {
		return "NO"
	}

	if currentIndex != inputLen {
		return "NO"
	}

	if countA == countC || countB == countC {
		return "YES"
	}

	return "NO"
}

package main

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

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

	input, err := inputReader.ReadString('\n')
	if err != nil {
		panic(err)
	}

	input = strings.Trim(input, "\n")

	fmt.Print(Solve(input))
}

func Solve(input string) string {
	inputLen := len(input)
	currentIndex := 0
	countA := 0
	countB := 0
	countC := 0

	for currentIndex < inputLen && input[currentIndex] == 'a' {
		countA++
		currentIndex++
	}

	if countA == 0 {
		return "NO"
	}

	for currentIndex < inputLen && input[currentIndex] == 'b' {
		countB++
		currentIndex++
	}

	if countB == 0 {
		return "NO"
	}

	for currentIndex < inputLen && input[currentIndex] == 'c' {
		countC++
		currentIndex++
	}

	if countC == 0 {
		return "NO"
	}

	if currentIndex != inputLen {
		return "NO"
	}

	if countA == countC || countB == countC {
		return "YES"
	}

	return "NO"
}

package main

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

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

	input, err := inputReader.ReadString('\n')
	if err != nil {
		panic(err)
	}

	fmt.Print(Solve(input))
}

func Solve(input string) string {
	inputLen := len(input)
	currentIndex := 0
	countA := 0
	countB := 0
	countC := 0

	for currentIndex < inputLen && input[currentIndex] == 'a' {
		countA++
		currentIndex++
	}

	if countA == 0 {
		return "NO"
	}

	for currentIndex < inputLen && input[currentIndex] == 'b' {
		countB++
		currentIndex++
	}

	if countB == 0 {
		return "NO"
	}

	for currentIndex < inputLen && input[currentIndex] == 'c' {
		countC++
		currentIndex++
	}

	if countC == 0 {
		return "NO"
	}

	if countA == countC || countB == countC {
		return "YES"
	}

	return "NO"
}

package main

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

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

	input, err := inputReader.ReadString('\n')
	if err != nil {
		panic(err)
	}

	input = strings.Trim(input, "\n")

	fmt.Print(Solve(input))
}

func Solve(input string) string {
	inputLen := len(input)
	currentIndex := 0
	countA := 0
	countB := 0
	countC := 0

	for currentIndex < inputLen && input[currentIndex] == 'a' {
		countA++
		currentIndex++
	}

	if countA == 0 {
		return "NO"
	}

	for currentIndex < inputLen && input[currentIndex] == 'b' {
		countB++
		currentIndex++
	}

	if countB == 0 {
		return "NO"
	}

	for currentIndex < inputLen && input[currentIndex] == 'c' {
		countC++
		currentIndex++
	}

	if countC == 0 {
		return "NO"
	}

	if currentIndex != inputLen {
		return "NO"
	}

	if countA == countC || countB == countC {
		return "YES"
	}

	return "NO"
}

package main

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

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

	input, err := inputReader.ReadString('\n')
	if err != nil {
		panic(err)
	}

	input = strings.Trim(input, "\n ")

	fmt.Print(Solve(input))
}

func Solve(input string) string {
	inputLen := len(input)
	currentIndex := 0
	countA := 0
	countB := 0
	countC := 0

	for currentIndex < inputLen && input[currentIndex] == 'a' {
		countA++
		currentIndex++
	}

	if countA == 0 {
		return "NO"
	}

	for currentIndex < inputLen && input[currentIndex] == 'b' {
		countB++
		currentIndex++
	}

	if countB == 0 {
		return "NO"
	}

	for currentIndex < inputLen && input[currentIndex] == 'c' {
		countC++
		currentIndex++
	}

	if countC == 0 {
		return "NO"
	}

	if currentIndex != inputLen {
		return "NO"
	}

	if countA == countC || countB == countC {
		return "YES"
	}

	return "NO"
}

package main

import "fmt"

func main() {
	var s string
	fmt.Scanln(&s)

	t := map[int32]int{}

	n := 'a'
	b := true
	for k,v := range s{
		AGAIN:
			if v == n {
				t[v]++
			}else if k != 0 && v > n {
				n++
				goto AGAIN
			}else{
				fmt.Print("NO")
				b = false
				break
			}
	}
	if b {
		if (t['c'] == t['a'] || t['c'] == t['b']) && len(t) > 0 {
			fmt.Print("YES")
		}else {
			fmt.Print("NO")
		}
	}
}

package main

import "fmt"

func main() {
	var s string
	fmt.Scanln(&s)

	t := map[int32]int{}

	n := 'a'
	b := true
	for k,v := range s{
		AGAIN:
			if v == n {
				t[v]++
			}else if k != 0 && v > n {
				n++
				goto AGAIN
			}else{
				fmt.Print("NO")
				b = false
				break
			}
	}
	if b {
		if t['c'] == t['a'] || t['c'] == t['b'] {
			fmt.Print("YES")
		}else {
			fmt.Print("NO")
		}
	}
}

package main

import "fmt"

func main() {
	var s string
	fmt.Scanln(&s)

	t := map[int32]int{}

	n := 'a'
	b := true
	for k,v := range s{
		AGAIN:
			if v == n {
				t[v]++
			}else if k != 0 && v > n {
				n++
				goto AGAIN
			}else{
				fmt.Print("NO")
				b = false
				break
			}
	}
	if b {
		if (t['c'] == t['a'] || t['c'] == t['b']) && len(s) > 0 && t['c'] != 0{
			fmt.Print("YES")
		}else {
			fmt.Print("NO")
		}
	}
}

package main

import (
    "fmt"
)

func main() {
    var s string
    fmt.Scanf("%s", &s)
    length := len(s)
    na := 0
    nb := 0
    nc := 0
    flag := true
    for i := 0; i < length; i++ {
        if s[i] == 'a' && nb == 0 && nc == 0{
            na++
        }else if s[i] == 'b' && na != 0 && nc == 0{
            nb++
        }else if s[i] == 'c' && na != 0 && nb !=0{
            nc++
        }else{
            flag = false
        }
    }
    if flag && (nc == na || nc == nb){
        fmt.Println("YES")
    }else{
        fmt.Println("NO")
    }
}


A tree is an undirected connected graph without cycles.You are given a tree of $$$n$$$ vertices. Find the number of ways to choose exactly $$$k$$$ vertices in this tree (i. e. a $$$k$$$-element subset of vertices) so that all pairwise distances between the selected vertices are equal (in other words, there exists an integer $$$c$$$ such that for all $$$u, v$$$ ($$$u \ne v$$$, $$$u, v$$$ are in selected vertices) $$$d_{u,v}=c$$$, where $$$d_{u,v}$$$ is the distance from $$$u$$$ to $$$v$$$).Since the answer may be very large, you need to output it modulo $$$10^9 + 7$$$.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 10$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case is preceded by an empty line. Each test case consists of several lines. The first line of the test case contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le k \le n \le 100$$$) — the number of vertices in the tree and the number of vertices to be selected, respectively. Then $$$n - 1$$$ lines follow, each of them contains two integers $$$u$$$ and $$$v$$$ ($$$1 \le u, v \le n$$$, $$$u \neq v$$$) which describe a pair of vertices connected by an edge. It is guaranteed that the given graph is a tree and has no loops or multiple edges.

For each test case output in a separate line a single integer — the number of ways to select exactly $$$k$$$ vertices so that for all pairs of selected vertices the distances between the vertices in the pairs are equal, modulo $$$10^9 + 7$$$ (in other words, print the remainder when divided by $$$1000000007$$$).

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1551F(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	const mod int64 = 1e9 + 7
	var T, n, k, v, w int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &k)
		g := make([][]int, n)
		for i := 1; i < n; i++ {
			Fscan(in, &v, &w)
			v--
			w--
			g[v] = append(g[v], w)
			g[w] = append(g[w], v)
		}
		if k == 2 {
			Fprintln(out, n*(n-1)/2)
			continue
		}

		var cd []int
		var f func(v, fa, d int)
		f = func(v, fa, d int) {
			cd[d]++
			for _, w := range g[v] {
				if w != fa {
					f(w, v, d+1)
				}
			}
		}

		ans := int64(0)
		for rt, ws := range g {
			if len(ws) < k {
				continue
			}
			dp := make([][]int64, n)
			for i := range dp {
				dp[i] = make([]int64, k+1)
				dp[i][0] = 1
			}
			for _, w := range ws {
				cd = make([]int, n)
				f(w, rt, 0)
				for i, d := range cd {
					if d == 0 {
						break
					}
					for j := k; j > 0; j-- {
						dp[i][j] = (dp[i][j] + dp[i][j-1]*int64(d)) % mod
					}
				}
			}
			for _, dr := range dp {
				ans += dr[k]
			}
		}
		Fprintln(out, ans%mod)
	}
}

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

package main

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

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

	const mx int = 300
	F := [mx + 1]int64{1}
	for i := 1; i <= mx; i++ {
		F[i] = F[i-1] * int64(i) % mod
	}
	pow := func(x, n int64) (res int64) {
		res = 1
		for ; n > 0; n >>= 1 {
			if n&1 > 0 {
				res = res * x % mod
			}
			x = x * x % mod
		}
		return res
	}
	invF := [...]int64{mx: pow(F[mx], mod-2)}
	for i := mx; i > 0; i-- {
		invF[i-1] = invF[i] * int64(i) % mod
	}
	C := func(n, k int) int64 {
		return F[n] * invF[k] % mod * invF[n-k] % mod
	}

	solve := func(Case int) {
		var n, k int
		Fscan(in, &n, &k)
		g := make([][]int, n)
		for i := 1; i < n; i++ {
			var v, w int
			Fscan(in, &v, &w)
			v--
			w--
			g[v] = append(g[v], w)
			g[w] = append(g[w], v)
		}

		if k == 2 {
			Fprintln(out, n*(n-1)/2)
			return
		}

		ans := int64(0)
		for st := 0; st < n; st++ {
			dis := make([][]int, n)
			dd := make([]int, n)
			var dfs func(v, fa, d int)
			dfs = func(v, fa, d int) {
				dd[d]++
				for _, w := range g[v] {
					if w != fa {
						dfs(w, v, d+1)
					}
				}
			}
			for _, w := range g[st] {
				dd = make([]int, n)
				dfs(w, st, 1)
				for i, d := range dd {
					if d > 0 {
						dis[i] = append(dis[i], d)
					}
				}
			}
			for _, ds := range dis {
				if len(ds) >= k {
					res := C(len(ds),k)
					//Println(st, d,res)
					one := 0
					for _, d := range ds {
						if d == 1 {
							one++
						}
						res = res * int64(d)% mod
					}
					if one>=k && one < len(ds) {
						res -= C(one,k)
					}
					ans += res
				}
			}
		}
		ans = (ans%mod + mod) % mod
		Fprintln(out, ans)
	}

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

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

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

package main

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

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

	const mx int = 300
	F := [mx + 1]int64{1}
	for i := 1; i <= mx; i++ {
		F[i] = F[i-1] * int64(i) % mod
	}
	pow := func(x, n int64) (res int64) {
		res = 1
		for ; n > 0; n >>= 1 {
			if n&1 > 0 {
				res = res * x % mod
			}
			x = x * x % mod
		}
		return res
	}
	invF := [...]int64{mx: pow(F[mx], mod-2)}
	for i := mx; i > 0; i-- {
		invF[i-1] = invF[i] * int64(i) % mod
	}
	C := func(n, k int) int64 {
		return F[n] * invF[k] % mod * invF[n-k] % mod
	}

	solve := func(Case int) {
		var n, k int
		Fscan(in, &n, &k)
		g := make([][]int, n)
		for i := 1; i < n; i++ {
			var v, w int
			Fscan(in, &v, &w)
			v--
			w--
			g[v] = append(g[v], w)
			g[w] = append(g[w], v)
		}

		if k == 2 {
			Fprintln(out, n*(n-1)/2)
			return
		}

		ans := int64(0)
		for st := 0; st < n; st++ {
			has := make([]bool, n)
			var dfs func(v, fa, d int)
			dfs = func(v, fa, d int) {
				has[d] = true
				for _, w := range g[v] {
					if w != fa {
						dfs(w, v, d+1)
					}
				}
				return
			}
			cd := make([]int, n)
			for _, w := range g[st] {
				has = make([]bool, n)
				dfs(w, st, 1)
				for d, b := range has {
					if b {
						cd[d]++
					}
				}
			}

			for _, c := range cd {
				if c >= k {
					ans += C(c, k)
				}
			}
		}
		ans %= mod
		Fprintln(out, ans)
	}

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

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

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


Hilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capacity, meaning there is exactly one guest in every room. The hotel's manager, David Hilbert himself, decides he wants to shuffle the guests around because he thinks this will create a vacancy (a room without a guest).For any integer $$$k$$$ and positive integer $$$n$$$, let $$$k\bmod n$$$ denote the remainder when $$$k$$$ is divided by $$$n$$$. More formally, $$$r=k\bmod n$$$ is the smallest non-negative integer such that $$$k-r$$$ is divisible by $$$n$$$. It always holds that $$$0\le k\bmod n\le n-1$$$. For example, $$$100\bmod 12=4$$$ and $$$(-1337)\bmod 3=1$$$.Then the shuffling works as follows. There is an array of $$$n$$$ integers $$$a_0,a_1,\ldots,a_{n-1}$$$. Then for each integer $$$k$$$, the guest in room $$$k$$$ is moved to room number $$$k+a_{k\bmod n}$$$.After this shuffling process, determine if there is still exactly one guest assigned to each room. That is, there are no vacancies or rooms with multiple guests.

Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10^4$$$) — the number of test cases. Next $$$2t$$$ lines contain descriptions of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1\le n\le 2\cdot 10^5$$$) — the length of the array. The second line of each test case contains $$$n$$$ integers $$$a_0,a_1,\ldots,a_{n-1}$$$ ($$$-10^9\le a_i\le 10^9$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot 10^5$$$.

For each test case, output a single line containing "YES" if there is exactly one guest assigned to each room after the shuffling process, or "NO" otherwise. You can print each letter in any case (upper or lower).

NoteIn the first test case, every guest is shifted by $$$14$$$ rooms, so the assignment is still unique.In the second test case, even guests move to the right by $$$1$$$ room, and odd guests move to the left by $$$1$$$ room. We can show that the assignment is still unique.In the third test case, every fourth guest moves to the right by $$$1$$$ room, and the other guests move to the right by $$$5$$$ rooms. We can show that the assignment is still unique.In the fourth test case, guests $$$0$$$ and $$$1$$$ are both assigned to room $$$3$$$.In the fifth test case, guests $$$1$$$ and $$$2$$$ are both assigned to room $$$2$$$.

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}
func NextInt64() int64 {
	bytes := NextBytes()
	i, err := Atoi64(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func Atoi64(b []byte) (int64, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	var n int64
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int64(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func ExtendByteArray(a []byte, size int) []byte {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]byte, size-len(a))...)
	}
}

func ExtendIntArray(a []int, size int) []int {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]int, size-len(a))...)
	}
}

func reverseInts(a []int) {
	for l, r := 0, len(a)-1; l < r; l, r = l+1, r-1 {
		a[l], a[r] = a[r], a[l]
	}
}

func unique(a []int) int {
	newLen := 0
	n := len(a)
	for i := 0; i < n; i++ {
		if newLen == 0 || a[i] != a[newLen-1] {
			a[newLen] = a[i]
			newLen++
		}
	}
	return newLen
}

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 main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	// inf, err := os.Open("a.in")
	// if err != nil {
	// 	die(err)
	// }
	// out, err := os.Create("a.out")
	// if err != nil {
	// 	die(err)
	// }
	// defer out.Close()
	Init(inf, 1000010)

	T := NextInt()

	was := make([]bool, 200000)

	for t := 0; t < T; t++ {
		n := NextInt()
		for i := 0; i < n; i++ {
			was[i] = false
		}

		ok := true
		for i := 0; i < n; i++ {
			ai := NextInt()
			r := (i + ai) % n
			if r < 0 {
				r += n
			}
			if was[r] {
				ok = false
			}
			was[r] = true
		}
		if ok {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}

	}
}

// https://codeforces.com/contest/1345/problem/C
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)
	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		fmt.Println(solver())
	}
}

func solver() string {
	var n int
	fmt.Fscan(input, &n)
	a := make([]int, n)
	busy := make([]bool, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &a[i])
	}

	for i := 0; i < n; i++ {
		pos := mod(i + a[i], n)
		if busy[pos] {
			return "NO"
		}
		busy[pos] = true
	}

	return "YES"
}

func mod(a, n int) int {
	m := a % n
	if m >= 0 {
		return m
	}

	return n + m
}

/*
URL:
https://codeforces.com/contest/1345/problem/C
*/

package main

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

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

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

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

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

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

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

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

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

var (
	t int
)

func main() {
	// PrintfDebug("%v\n", NegativeMod(-1337, 3))
	// PrintfDebug("%v\n", NegativeMod(-1, 3))
	// for i := -3; i < 10; i++ {
	// 	PrintfDebug("%d -> %d\n", i, NegativeMod(i, 3))
	// }

	t = ReadInt()
	for i := 0; i < t; i++ {
		n := ReadInt()
		A := ReadIntSlice(n)
		solve(n, A)
	}
}

func solve(n int, A []int) {
	memo := make(map[int]int)
	for i := 0; i < n; i++ {
		tmp := NegativeMod(A[i]+i, n)
		memo[tmp] = 1
	}

	if len(memo) < n {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}

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

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

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

var (
	// ReadString returns a WORD string.
	ReadString 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()
	}
}

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

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

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

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

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

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

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

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

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

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

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

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

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

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

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

package main

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

func solve() {
	n := readInt()

	arr := make([]bool, n)
	for i := range arr {
		a := readInt()
		to := (i + (a%n+n)%n) % n
		arr[to] = true
	}

	for i := range arr {
		if !arr[i] {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

func main() {
	k := readInt()
	for i := 0; i < k; i++ {
		solve()
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), math.MaxInt32)
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

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

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 abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}

package main

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

type BufferedWriter interface {
	Printf(format string, a ...interface{})
	Flush()
}

type writerImpl struct {
	*bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
	return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
	fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
	impl.Writer.Flush()
}

type WordScanner interface {
	NextInt64() int64
	NextUInt64() uint64
	NextString() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

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

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

func (impl *wordScannerImpl) NextString() string {
	impl.Scan()
	return impl.Text()
}

func gcd(x, y int64) int64 {
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

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

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

const (
	INF = math.MaxInt64
	MOD = 1e9 + 7
)

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		n := reader.NextInt64()
		aa := make([]int64, n)
		for i := int64(0); i < n; i++ {
			aa[i] = reader.NextInt64()
		}
		writer.Printf("%s\n", sol(aa))
	}
}

func sol(aa []int64) string {
	for i := range aa {
		aa[i] = ((aa[i] + int64(i)) % int64(len(aa)) + int64(len(aa))) % int64(len(aa))
	}
	sort.Slice(aa, func(a, b int) bool {
		return aa[a] < aa[b]
	})
	//writer.Printf("%v\n", aa)
	for i := 1; i < len(aa); i++ {
		if aa[i] != aa[i-1]+1 {
			return "NO"
		}
	}
	return "YES"
}

package main

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

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 main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)

		A := readNNums(reader, n)

		if solve(n, A) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func solve(n int, A []int) bool {
	vis := make([]bool, n)

	for i := 0; i < n; i++ {
		x := A[i] % n
		x += i
		x %= n
		if x < 0 {
			x += n
		}
		if vis[x] {
			return false
		}
		vis[x] = true
	}

	return true
}

package main

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

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	buf := make([]byte, 15 * 1024 * 1024)

	scanner.Buffer(buf, 13 * 1024 * 1024)

	scanner.Scan()

	t := scanner.Text()

	testCases, err := strconv.Atoi(t)

	if err != nil {
		panic(err)
	}

	for j := 0; j < int(testCases); j ++ {

		scanner.Scan()

		a := scanner.Text()

		arrLen , err := strconv.Atoi(a)

		if err != nil {
			panic(err)
		}

		scanner.Scan()

		line := scanner.Text()

		parts := strings.Fields(line)

		var arr []int

		for i := 0 ; i < arrLen; i ++ {

			p , err := strconv.Atoi(parts[i])

			if err != nil {
				panic(err)
			}

			arr = append(arr, p)
		}

		res := gilbert(arr)

		fmt.Println(res)
	}
}

func gilbert(arr []int) string {

	n := len(arr)

	m := make([]int, n)

	for i := 0 ; i < n; i ++ {
		res := i + arr[i]

		if res >= 0 {
			m[res % n] ++

		} else {
			rem := (-res) % n

			if rem == 0 {
				m[0]++
			} else {
				m[n - rem]++
			}
		}
	}

	for i := range m {
		if m[i] > 1 {
			return "NO"
		}
	}
	return "YES"
}

// https://codeforces.com/contest/1345/problem/C
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)
	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		solver()
	}
}

func solver() {
	var n int
	fmt.Fscan(input, &n)
	a := make([]int, n)
	busy := make(map[int]bool)
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &a[i])
	}

	for i := 0; i < n; i++ {
		pos := mod((i + a[mod(i, n)]), n)
		if busy[pos] {
			fmt.Println("NO")
			return
		}
		busy[pos] = true
	}

	fmt.Println("YES")
}

func mod(a, n int) int {
	if a >= 0 {
		return a % n
	}

	return n + (a % n)
}

// https://codeforces.com/contest/1345/problem/C
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)
	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		solver()
	}
}

func solver() {
	var n int
	fmt.Fscan(input, &n)
	a := make([]int, n)
	busy := make(map[int]bool)
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &a[i])
	}

	for i := 0; i < n; i++ {
		pos := mod(i + a[i], n)
		if busy[pos] {
			fmt.Println("NO")
			return
		}
		busy[pos] = true
	}

	fmt.Println("YES")
}

func mod(a, n int) int {
	if a >= 0 {
		return a % n
	}

	return n + (a % n)
}

// https://codeforces.com/contest/1345/problem/C
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)
	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		solver()
	}
}

func solver() {
	var n int64
	fmt.Fscan(input, &n)
	a := make([]int64, n)
	busy := make(map[int64]bool)
	for i := 0; i < int(n); i++ {
		fmt.Fscan(input, &a[i])
	}

	for i := int64(0); i < n; i++ {
		pos := mod(i + a[i], n)
		if busy[pos] {
			fmt.Println("NO")
			return
		}
		busy[pos] = true
	}

	fmt.Println("YES")
}

func mod(a, n int64) int64 {
	if a >= 0 {
		return a % n
	}

	return n + (a % n)
}

package main

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

type BufferedWriter interface {
	Printf(format string, a ...interface{})
	Flush()
}

type writerImpl struct {
	*bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
	return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
	fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
	impl.Writer.Flush()
}

type WordScanner interface {
	NextInt64() int64
	NextUInt64() uint64
	NextString() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

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

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

func (impl *wordScannerImpl) NextString() string {
	impl.Scan()
	return impl.Text()
}

func gcd(x, y int64) int64 {
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

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

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

const (
	INF = math.MaxInt64
	MOD = 1e9 + 7
)

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		n := reader.NextInt64()
		aa := make([]int64, n)
		for i := int64(0); i < n; i++ {
			aa[i] = reader.NextInt64()
		}
		writer.Printf("%s\n", sol(aa))
	}
}

func sol(aa []int64) string {
	for i := range aa {
		aa[i] = (aa[i] + int64(i)) % int64(len(aa))
	}
	sort.Slice(aa, func(a, b int) bool {
		return aa[a] < aa[b]
	})
	if len(aa) == 1 {
		return "YES"
	}
	diff := aa[1] - aa[0]
	if diff == 0 {
		return "NO"
	}
	for i := 1; i < len(aa); i++ {
		if aa[i] != aa[i-1]+diff {
			return "NO"
		}
	}
	return "YES"
}

package main

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

type BufferedWriter interface {
	Printf(format string, a ...interface{})
	Flush()
}

type writerImpl struct {
	*bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
	return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
	fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
	impl.Writer.Flush()
}

type WordScanner interface {
	NextInt64() int64
	NextUInt64() uint64
	NextString() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

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

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

func (impl *wordScannerImpl) NextString() string {
	impl.Scan()
	return impl.Text()
}

func gcd(x, y int64) int64 {
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

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

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

const (
	INF = math.MaxInt64
	MOD = 1e9 + 7
)

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		n := reader.NextInt64()
		aa := make([]int64, n)
		for i := int64(0); i < n; i++ {
			aa[i] = reader.NextInt64()
		}
		writer.Printf("%s\n", sol(aa))
	}
}

func sol(aa []int64) string {
	for i := range aa {
		aa[i] = ((aa[i] + int64(i)) % int64(len(aa)) + int64(len(aa))) % int64(len(aa))
	}
	sort.Slice(aa, func(a, b int) bool {
		return aa[a] < aa[b]
	})
	writer.Printf("%v\n", aa)
	for i := 1; i < len(aa); i++ {
		if aa[i] != aa[i-1]+1 {
			return "NO"
		}
	}
	return "YES"
}

package main

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

type BufferedWriter interface {
	Printf(format string, a ...interface{})
	Flush()
}

type writerImpl struct {
	*bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
	return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
	fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
	impl.Writer.Flush()
}

type WordScanner interface {
	NextInt64() int64
	NextUInt64() uint64
	NextString() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

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

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

func (impl *wordScannerImpl) NextString() string {
	impl.Scan()
	return impl.Text()
}

func gcd(x, y int64) int64 {
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

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

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

const (
	INF = math.MaxInt64
	MOD = 1e9 + 7
)

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		n := reader.NextInt64()
		aa := make([]int64, n)
		for i := int64(0); i < n; i++ {
			aa[i] = reader.NextInt64()
		}
		writer.Printf("%s\n", sol(aa))
	}
}

func sol(aa []int64) string {
	for i := range aa {
		aa[i] = (aa[i] + int64(i)) % int64(len(aa))
	}
	sort.Slice(aa, func(a, b int) bool {
		return aa[a] < aa[b]
	})
	for i := 1; i < len(aa); i++ {
		if aa[i] != aa[i-1]+1 {
			return "NO"
		}
	}
	return "YES"
}

package main

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

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()

	t := scanner.Text()

	testCases, err := strconv.Atoi(t)

	if err != nil {
		panic(err)
	}

	for j := 0; j < int(testCases); j ++ {

		scanner.Scan()

		a := scanner.Text()

		arrLen , _ := strconv.Atoi(a)

		scanner.Scan()

		line := scanner.Text()

		parts := strings.Fields(line)

		var arr []int

		for i := 0 ; i < arrLen; i ++ {

			p , _ := strconv.Atoi(parts[i])

			arr = append(arr, p)
		}

		res := gilbert(arr)

		fmt.Println(res)
	}

}

func gilbert(arr []int) string {

	m := make(map[int]int)

	n := len(arr)

	for i := 0 ; i < n; i ++ {
		res := i + arr[i]

		if res >= 0 {
			m[res % n] ++

		} else {
			m[n - (res % n)]++
		}

	}

	for i := range m {
		if m[i] > 1 {
			return "NO"
		}
	}
	return "YES"
}


Vova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches.The current state of the wall can be respresented by a sequence $$$a$$$ of $$$n$$$ integers, with $$$a_i$$$ being the height of the $$$i$$$-th part of the wall.Vova can only use $$$2 \times 1$$$ bricks to put in the wall (he has infinite supply of them, however).Vova can put bricks only horizontally on the neighbouring parts of the wall of equal height. It means that if for some $$$i$$$ the current height of part $$$i$$$ is the same as for part $$$i + 1$$$, then Vova can put a brick there and thus increase both heights by 1. Obviously, Vova can't put bricks in such a way that its parts turn out to be off the borders (to the left of part $$$1$$$ of the wall or to the right of part $$$n$$$ of it).Note that Vova can't put bricks vertically.Vova is a perfectionist, so he considers the wall completed when:  all parts of the wall has the same height;  the wall has no empty spaces inside it. Can Vova complete the wall using any amount of bricks (possibly zero)?

The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of parts in the wall. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the initial heights of the parts of the wall.

Print "YES" if Vova can complete the wall using any amount of bricks (possibly zero). Print "NO" otherwise.

NoteIn the first example Vova can put a brick on parts 2 and 3 to make the wall $$$[2, 2, 2, 2, 5]$$$ and then put 3 bricks on parts 1 and 2 and 3 bricks on parts 3 and 4 to make it $$$[5, 5, 5, 5, 5]$$$.In the second example Vova can put no bricks in the wall.In the third example the wall is already complete.

package main

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

func main() {
	buf := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscanf(buf, "%d\n", &n)

	var front int = 0

	var max int = 0
	mat := make([]int, n+2)
	var ans bool = true
	for i := 1; i <= n; i++ {
		fmt.Fscanf(buf, "%d", &mat[i])
		if mat[i] > max {
			max = mat[i]
		}
	}
	mat[0] = max + 1
	mat[n+1] = max + 1
	stack := make([]int, n+5)
	stack[front] = 0
	front++
	for i := 1; ans&&i <= n+1; i++ {
	//	fmt.Println(stack[:front])
		for mat[stack[front-1]] < mat[i] {
			if i ==n+1&&front-1 <= 1{
				break
			}
			if front-2 >=0 {
		//		fmt.Printf("[%d,%d]\n",  stack[front-2],i)
				if 0 == ((i - stack[front-2]) & 1) {
					ans = false
					break
				}
			}
			front--
		}
		if mat[stack[front-1]] == mat[i] {
			stack[front-1] = i
		}else {
			stack[front] = i
			front++
		}
	}

	if ans {
		fmt.Printf("YES\n")
	} else {
		fmt.Printf("NO\n")
	}

}

/*
9
10 1 1 10 1 1 10 1 1

11
10 1 1 10 1 1 10 1 1 10 11

5 4
1 2
3 4
4 5
5 3
5 1
1 2
*/

package main

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

func main() {
    start := time.Now()
    defer func () {
        run := time.Since(start)
        _ = run
        // fmt.Println("Run in", run)
    }()

    stdin := bufio.NewReader(os.Stdin)

    var n, x int
    var stack []int

    fmt.Fscan(stdin, &n)
    stack = []int { 0 }
    fmt.Fscan(stdin, &stack[0])

    Max := func (i, j int) int {
        if i > j {
            return i
        }
        return j
    }

    var m = stack[0]
    for i := 1; i < n; i++ {
        fmt.Fscan(stdin, &x)
        stack = append(stack, x)
        m = Max(m, x)
        var l = len(stack)
        if l > 1 && stack[l-1] == stack[l-2] {
            if l == 2 || stack[l-3] >= stack[l-1] {
                stack = stack[:l-2]
            }
        }
    }

    if len(stack) == 0 || (len(stack) == 1 && stack[0] == m) {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
    // fmt.Println(stack)
}

package main

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

func main() {
	io := newIO()
	defer io.out.Flush()

	n := io.nextInt()
	a := io.nextArr(n)
	var s stack
	mx := 0
	for i := 0; i < n; i++ {
		mx = max(mx, a[i])
		s = s.clr()
		s = s.Push(a[i])
		if s.bad() {
			fmt.Println("NO")
			return
		}
	}
	s = s.clr()
	if len(s) == 0 || len(s) == 1 && s[0] == mx {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func (s stack) bad() bool {
	if len(s) >= 2 {
		s, first := s.Pop()
		_, second := s.Pop()
		if first > second {return true}
	}
	return false
}
func (s stack) clr() stack {
	var first, second int
	for len(s) >= 2 {
		s, first = s.Pop()
		s, second = s.Pop()
		s = s.Push(second)
		s = s.Push(first)
		if first != second {
			return s
		} else {
			if len(s) == 2 {
				s = s[0:0]
			} else if len(s) == 3 {
				s = s[0:1]
			} else {
				s = s[0:len(s) - 2]
			}
		}
	}
	return s
}

type stack []int

func (s stack) Push(v int) stack {
	return append(s, v)
}

func (s stack) Pop() (stack, int) {
	l := len(s)
	return s[:l-1], s[l-1]
}

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

type io struct {
	inp *bufio.Scanner
	out *bufio.Writer
}

func newIO() io {
	sc := io{
		inp: bufio.NewScanner(os.Stdin),
		out: bufio.NewWriter(os.Stdout),
	}
	sc.inp.Split(bufio.ScanWords)
	return sc
}
func (sc io) nextArr(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = sc.nextInt()
	}
	return a
}
func (sc io) nextString() string {
	sc.inp.Scan()
	return sc.inp.Text();
}

func (sc io) nextInt64() int64 {
	v, _ := strconv.ParseInt(sc.nextString(), 10, 64)
	return int64(v)
}
func (sc io) nextInt() int {
	v, _ := strconv.ParseInt(sc.nextString(), 10, 64)
	return int(v)
}

package main

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

func main() {
    start := time.Now()
    defer func () {
        run := time.Since(start)
        _ = run
        // fmt.Println("Run in", run)
    }()

    stdin := bufio.NewReader(os.Stdin)

    var n, x int
    var stack []int

    fmt.Fscan(stdin, &n)
    stack = []int { 0 }
    fmt.Fscan(stdin, &stack[0])

    Max := func (i, j int) int {
        if i > j {
            return i
        }
        return j
    }

    var m = stack[0]
    for i := 1; i < n; i++ {
        fmt.Fscan(stdin, &x)
        stack = append(stack, x)
        m = Max(m, x)
        var l = len(stack)
        if l > 1 && stack[0] >= stack[l-1] && stack[l-1] == stack[l-2] {
            stack = stack[:l - 2]
        }
    }

    if len(stack) == 0 || (len(stack) == 1 && stack[0] == m) {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
    // fmt.Println(stack)
}

package main

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

func main() {
	io := newIO()
	defer io.out.Flush()

	n := io.nextInt()
	a := io.nextArr(n)
	var s stack
	for i := 0; i < n; i++ {
		s = s.clr()
		s = s.Push(a[i])
	}
	s = s.clr()
	if len(s) <= 1 {
		fmt.Println("YES")

	} else {
		fmt.Println("NO")
	}
}

func (s stack) clr() stack {
	var first, second int
	for len(s) >= 2 {
		s, first = s.Pop()
		s, second = s.Pop()
		s = s.Push(second)
		s = s.Push(first)
		if first != second {
			return s
		} else {
			if len(s) == 2 {
				s = s[0:0]
			} else if len(s) == 3 {
				s = s[0:1]
			} else {
				s = s[0:len(s) - 2]
			}
		}
	}
	return s
}

type stack []int

func (s stack) Push(v int) stack {
	return append(s, v)
}

func (s stack) Pop() (stack, int) {
	l := len(s)
	return s[:l-1], s[l-1]
}

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

type io struct {
	inp *bufio.Scanner
	out *bufio.Writer
}

func newIO() io {
	sc := io{
		inp: bufio.NewScanner(os.Stdin),
		out: bufio.NewWriter(os.Stdout),
	}
	sc.inp.Split(bufio.ScanWords)
	return sc
}
func (sc io) nextArr(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = sc.nextInt()
	}
	return a
}
func (sc io) nextString() string {
	sc.inp.Scan()
	return sc.inp.Text();
}

func (sc io) nextInt64() int64 {
	v, _ := strconv.ParseInt(sc.nextString(), 10, 64)
	return int64(v)
}
func (sc io) nextInt() int {
	v, _ := strconv.ParseInt(sc.nextString(), 10, 64)
	return int(v)
}

package main

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

func main() {
	io := newIO()
	defer io.out.Flush()

	n := io.nextInt()
	a := io.nextArr(n)
	var s stack
	for i := 0; i < n; i++ {
		s = s.clr()
		s = s.Push(a[i])
		if s.bad() {
			fmt.Println("NO")
			return
		}
	}
	s = s.clr()
	if len(s) <= 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func (s stack) bad() bool {
	if len(s) >= 2 {
		s, first := s.Pop()
		_, second := s.Pop()
		if first > second {return true}
	}
	return false
}
func (s stack) clr() stack {
	var first, second int
	for len(s) >= 2 {
		s, first = s.Pop()
		s, second = s.Pop()
		s = s.Push(second)
		s = s.Push(first)
		if first != second {
			return s
		} else {
			if len(s) == 2 {
				s = s[0:0]
			} else if len(s) == 3 {
				s = s[0:1]
			} else {
				s = s[0:len(s) - 2]
			}
		}
	}
	return s
}

type stack []int

func (s stack) Push(v int) stack {
	return append(s, v)
}

func (s stack) Pop() (stack, int) {
	l := len(s)
	return s[:l-1], s[l-1]
}

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

type io struct {
	inp *bufio.Scanner
	out *bufio.Writer
}

func newIO() io {
	sc := io{
		inp: bufio.NewScanner(os.Stdin),
		out: bufio.NewWriter(os.Stdout),
	}
	sc.inp.Split(bufio.ScanWords)
	return sc
}
func (sc io) nextArr(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = sc.nextInt()
	}
	return a
}
func (sc io) nextString() string {
	sc.inp.Scan()
	return sc.inp.Text();
}

func (sc io) nextInt64() int64 {
	v, _ := strconv.ParseInt(sc.nextString(), 10, 64)
	return int64(v)
}
func (sc io) nextInt() int {
	v, _ := strconv.ParseInt(sc.nextString(), 10, 64)
	return int(v)
}


This is an interactive problem!Ehab has a hidden permutation $$$p$$$ of length $$$n$$$ consisting of the elements from $$$0$$$ to $$$n-1$$$. You, for some reason, want to figure out the permutation. To do that, you can give Ehab $$$2$$$ different indices $$$i$$$ and $$$j$$$, and he'll reply with $$$(p_i|p_j)$$$ where $$$|$$$ is the bitwise-or operation.Ehab has just enough free time to answer $$$4269$$$ questions, and while he's OK with answering that many questions, he's too lazy to play your silly games, so he'll fix the permutation beforehand and will not change it depending on your queries. Can you guess the permutation?

The only line contains the integer $$$n$$$ $$$(3 \le n \le 2048)$$$ — the length of the permutation.

NoteIn the first sample, the permutation is $$$[1,0,2]$$$. You start by asking about $$$p_1|p_2$$$ and Ehab replies with $$$1$$$. You then ask about $$$p_1|p_3$$$ and Ehab replies with $$$3$$$. Finally, you ask about $$$p_2|p_3$$$ and Ehab replies with $$$2$$$. You then guess the permutation.

package main

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

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 main() {
	reader := bufio.NewReader(os.Stdin)

	n := readNum(reader)

	ask := func(i, j int) int {
		fmt.Printf("? %d %d\n", i, j)
		return readNum(reader)
	}

	res := solve(n, ask)

	var buf bytes.Buffer
	buf.WriteByte('!')
	for i := 0; i < n; i++ {
		buf.WriteString(fmt.Sprintf(" %d", res[i]))
	}
	fmt.Println(buf.String())
}

func solve(n int, ask func(int, int) int) []int {
	r := rand.Perm(n)
	p := make([]int, n)

	for i, j := range r {
		p[j] = i + 1
	}

	z := make([]int, 11)

	for i := 0; i < len(z); i++ {
		z[i] = -1
	}

	for !allSet(z) {
		i := rand.Intn(n) + 1
		j := rand.Intn(n) + 1
		if i == j {
			continue
		}
		tmp := ask(i, j)
		for b := 0; b < 11; b++ {
			if tmp&(1<<b) == 0 {
				z[b] = i
			}
		}
	}

	get := func(i int, sup int) int {
		ans := sup

		for b := 0; b < 11; b++ {
			if ans&(1<<b) > 0 {
				if z[b] != i {
					ans &= ask(i, z[b])
				} else {
					ans ^= 1 << b
				}
			}
		}
		return ans
	}

	idx := -1
	val := 1<<11 - 1

	for _, i := range p {
		if idx < 0 || ask(i, idx) == val {
			idx = i
			val = get(i, val)
		}
	}
	// val == 0
	for i := 1; i <= n; i++ {
		if i == idx {
			p[i-1] = 0
		} else {
			p[i-1] = ask(i, idx)
		}
	}

	return p
}

func allSet(arr []int) bool {
	var res int
	for i := 0; i < len(arr); i++ {
		if arr[i] > 0 {
			res++
		}
	}
	return res == len(arr)
}

func solve1(n int, ask func(int, int) int) []int {
	r := rand.Perm(n)
	p := make([]int, n)

	for i, j := range r {
		p[j] = i + 1
	}

	a, b := p[0], p[1]
	val := ask(a, b)

	for i := 2; i < n; i++ {
		c := p[i]
		tmp := ask(b, c)
		if tmp < val {
			a = c
			val = tmp
		} else if tmp == val {
			b = c
			val = ask(a, b)
		}
	}
	idx := -1
	//a, b are candidates for 0
	for idx < 0 {
		i := rand.Intn(n) + 1
		if i == a || i == b {
			continue
		}
		x := ask(i, a)
		y := ask(i, b)
		if x == y {
			continue
		}
		if x < y {
			idx = a
		} else {
			idx = b
		}
	}

	p[idx-1] = 0

	for i := 1; i <= n; i++ {
		if i == idx {
			continue
		}
		p[i-1] = ask(i, idx)
	}

	return p
}

package main

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

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 main() {
	reader := bufio.NewReader(os.Stdin)

	n := readNum(reader)

	ask := func(i, j int) int {
		fmt.Printf("? %d %d\n", i, j)
		return readNum(reader)
	}

	res := solve(n, ask)

	var buf bytes.Buffer
	buf.WriteByte('!')
	for i := 0; i < n; i++ {
		buf.WriteString(fmt.Sprintf(" %d", res[i]))
	}
	fmt.Println(buf.String())
}

func solve(n int, ask func(int, int) int) []int {
	r := rand.Perm(n)
	p := make([]int, n)

	for i, j := range r {
		p[j] = i + 1
	}

	a, b := p[0], p[1]
	val := ask(a, b)

	for i := 2; i < n; i++ {
		c := p[i]
		tmp := ask(b, c)
		if tmp < val {
			a = c
			val = tmp
		} else if tmp == val {
			b = c
			val = ask(a, b)
		}
	}
	idx := -1
	//a, b are candidates for 0
	for idx < 0 {
		i := rand.Intn(n) + 1
		if i == a || i == b {
			continue
		}
		x := ask(i, a)
		y := ask(i, b)
		if x == y {
			continue
		}
		if x < y {
			idx = a
		} else {
			idx = b
		}
	}

	p[idx-1] = 0

	for i := 1; i <= n; i++ {
		if i == idx {
			continue
		}
		p[i-1] = ask(i, idx)
	}

	return p
}

package main

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

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 main() {
	reader := bufio.NewReader(os.Stdin)

	n := readNum(reader)

	ask := func(i, j int) int {
		fmt.Printf("? %d %d\n", i, j)
		return readNum(reader)
	}

	res := solve(n, ask)

	var buf bytes.Buffer
	buf.WriteByte('!')
	for i := 0; i < n; i++ {
		buf.WriteString(fmt.Sprintf(" %d", res[i]))
	}
	fmt.Println(buf.String())
}

func solve(n int, ask func(int, int) int) []int {
	r := rand.Perm(n)
	p := make([]int, n)

	for i, j := range r {
		p[j] = i + 1
	}

	a, b := p[0], p[1]
	val := ask(a, b)

	for i := 2; i < n; i++ {
		c := p[i]
		tmp := ask(b, c)
		if tmp < val {
			a = c
		} else if tmp == val {
			b = c
			val = ask(a, b)
		}
	}
	idx := -1
	//a, b are candidates for 0
	for idx < 0 {
		i := rand.Intn(n) + 1
		if i == a || i == b {
			continue
		}
		x := ask(i, a)
		y := ask(i, b)
		if x < y {
			idx = a
		} else if x > y {
			idx = b
		}
	}

	p[idx-1] = 0

	for i := 1; i <= n; i++ {
		if i == idx {
			continue
		}
		p[i-1] = ask(i, idx)
	}

	return p
}

package main

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

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 main() {
	reader := bufio.NewReader(os.Stdin)

	n := readNum(reader)

	ask := func(i, j int) int {
		fmt.Printf("? %d %d\n", i, j)
		return readNum(reader)
	}

	res := solve(n, ask)

	var buf bytes.Buffer
	buf.WriteByte('!')
	for i := 0; i < n; i++ {
		buf.WriteString(fmt.Sprintf(" %d", res[i]))
	}
	fmt.Println(buf.String())
}

func solve(n int, ask func(int, int) int) []int {
	r := rand.Perm(n)
	p := make([]int, n)

	for i, j := range r {
		p[j] = i + 1
	}

	a, b := p[0], p[1]
	val := ask(a, b)

	for i := 2; i < n; i++ {
		c := p[i]
		tmp := ask(b, c)
		if tmp < val {
			a = c
		} else if tmp == val {
			b = c
			val = ask(a, b)
		}
	}
	idx := -1
	//a, b are candidates for 0
	for idx < 0 {
		i := rand.Intn(n) + 1
		if i == a || i == b {
			continue
		}
		x := ask(i, a)
		y := ask(i, b)
		if x < y {
			idx = a
		} else {
			idx = b
		}
	}

	p[idx-1] = 0

	for i := 1; i <= n; i++ {
		if i == idx {
			continue
		}
		p[i-1] = ask(i, idx)
	}

	return p
}


Kuroni is the coordinator of the next Mathforces round written by the "Proof by AC" team. All the preparation has been done, and he is discussing with the team about the score distribution for the round.The round consists of $$$n$$$ problems, numbered from $$$1$$$ to $$$n$$$. The problems are ordered in increasing order of difficulty, no two problems have the same difficulty. A score distribution for the round can be denoted by an array $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the score of $$$i$$$-th problem. Kuroni thinks that the score distribution should satisfy the following requirements:  The score of each problem should be a positive integer not exceeding $$$10^9$$$.  A harder problem should grant a strictly higher score than an easier problem. In other words, $$$1 \leq a_1 < a_2 < \dots < a_n \leq 10^9$$$.  The balance of the score distribution, defined as the number of triples $$$(i, j, k)$$$ such that $$$1 \leq i < j < k \leq n$$$ and $$$a_i + a_j = a_k$$$, should be exactly $$$m$$$. Help the team find a score distribution that satisfies Kuroni's requirement. In case such a score distribution does not exist, output $$$-1$$$.

The first and single line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 5000$$$, $$$0 \leq m \leq 10^9$$$) — the number of problems and the required balance.

If there is no solution, print a single integer $$$-1$$$. Otherwise, print a line containing $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, representing a score distribution that satisfies all the requirements. If there are multiple answers, print any of them.

NoteIn the first example, there are $$$3$$$ triples $$$(i, j, k)$$$ that contribute to the balance of the score distribution.   $$$(1, 2, 3)$$$  $$$(1, 3, 4)$$$  $$$(2, 4, 5)$$$

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func ExtendByteArray(a []byte, size int) []byte {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]byte, size-len(a))...)
	}
}

func ExtendIntArray(a []int, size int) []int {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]int, size-len(a))...)
	}
}

func main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	// inf, err := os.Open("a.in")
	// if err != nil {
	// 	die(err)
	// }
	// out, err := os.Create("a.out")
	// if err != nil {
	// 	die(err)
	// }
	// defer out.Close()
	Init(inf, 1000010)

	n := NextInt()
	m := NextInt()
	res := make([]int, 0)
	i := 0
	for i = 1; m > 0 && i <= n; i++ {
		t := (i - 1) / 2
		if m >= t {
			m -= t
			res = append(res, i)
		} else {
			res = append(res, i-1+i-2-2*(m-1))
			m = 0
		}
	}
	if m > 0 {
		fmt.Fprintln(out, -1)
		return
	}

	for ; i <= n; i++ {
		res = append(res, 100000000+i*5001)
	}

	for i := 0; i < n; i++ {
		fmt.Fprint(out, res[i], " ")
	}
	fmt.Fprintln(out)
}

package main

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

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

	var n, m int
	Fscan(in, &n, &m)
	if n < 3 && m > 0 {
		Fprint(out, -1)
		return
	}
	maxM := 0
	for i := 3; i <= n; i++ {
		maxM += (i - 1) / 2
	}
	if m > maxM {
		Fprint(out, -1)
		return
	}
	if m == 0 {
		for i := 1e9 - n + 1; i <= 1e9; i++ {
			Fprint(out, i, " ")
		}
		return
	}
	maxM = 0
	for i := 3; i <= n; i++ {
		tmp := maxM
		maxM += (i - 1) / 2
		if maxM < m {
			continue
		}
		for j := 1; j < i; j++ {
			Fprint(out, j, " ")
		}
		last := i
		if maxM > m {
			last = i - 1 + i - 2*(m-tmp)
		}
		Fprint(out, last, " ")
		for j := i + 1; j <= n; j++ {
			Fprint(out, 1e9-(last+1)*(n-j), " ")
		}
		break
	}
}

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

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func ExtendByteArray(a []byte, size int) []byte {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]byte, size-len(a))...)
	}
}

func ExtendIntArray(a []int, size int) []int {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]int, size-len(a))...)
	}
}

func main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	// inf, err := os.Open("a.in")
	// if err != nil {
	// 	die(err)
	// }
	// out, err := os.Create("a.out")
	// if err != nil {
	// 	die(err)
	// }
	// defer out.Close()
	Init(inf, 1000010)

	n := NextInt()
	m := NextInt()
	res := make([]int, 0)
	i := 0
	for i = 1; m > 0 && i <= n; i++ {
		t := (i - 1) / 2
		if m >= t {
			m -= t
			res = append(res, i)
		} else {
			m = 0
			res = append(res, i-1+i-2-2*m)
		}
	}
	if m > 0 {
		fmt.Fprintln(out, -1)
		return
	}

	for ; i <= n; i++ {
		res = append(res, 10000000+i)
	}

	for i := 0; i < n; i++ {
		fmt.Fprint(out, res[i], " ")
	}
	fmt.Fprintln(out)
}

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func ExtendByteArray(a []byte, size int) []byte {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]byte, size-len(a))...)
	}
}

func ExtendIntArray(a []int, size int) []int {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]int, size-len(a))...)
	}
}

func main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	// inf, err := os.Open("a.in")
	// if err != nil {
	// 	die(err)
	// }
	// out, err := os.Create("a.out")
	// if err != nil {
	// 	die(err)
	// }
	// defer out.Close()
	Init(inf, 1000010)

	n := NextInt()
	m := NextInt()
	res := make([]int, 0)
	i := 0
	for i = 1; m > 0 && i <= n; i++ {
		t := (i - 1) / 2
		if m >= t {
			m -= t
			res = append(res, i)
		} else {
			res = append(res, i-1+i-2-2*(m-1))
			m = 0
		}
	}
	if m > 0 {
		fmt.Fprintln(out, -1)
		return
	}

	for ; i <= n; i++ {
		res = append(res, 10000000+i*100000)
	}

	for i := 0; i < n; i++ {
		fmt.Fprint(out, res[i], " ")
	}
	fmt.Fprintln(out)
}

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func ExtendByteArray(a []byte, size int) []byte {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]byte, size-len(a))...)
	}
}

func ExtendIntArray(a []int, size int) []int {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]int, size-len(a))...)
	}
}

func main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	// inf, err := os.Open("a.in")
	// if err != nil {
	// 	die(err)
	// }
	// out, err := os.Create("a.out")
	// if err != nil {
	// 	die(err)
	// }
	// defer out.Close()
	Init(inf, 1000010)

	n := NextInt()
	m := NextInt()
	res := make([]int, 0)
	i := 0
	for i = 1; m > 0 && i <= n; i++ {
		t := (i - 1) / 2
		if m >= t {
			m -= t
			res = append(res, i)
		} else {
			res = append(res, i-1+i-2-2*(m-1))
			m = 0
		}
	}
	if m > 0 {
		fmt.Fprintln(out, -1)
		return
	}

	for ; i <= n; i++ {
		res = append(res, 10000000+i)
	}

	for i := 0; i < n; i++ {
		fmt.Fprint(out, res[i], " ")
	}
	fmt.Fprintln(out)
}

package main

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

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

	var n, m int
	Fscan(in, &n, &m)
	if n < 3 {
		Fprint(out, -1)
		return
	}
	maxM := 0
	for i := 3; i <= n; i++ {
		maxM += (i - 1) / 2
	}
	if m > maxM {
		Fprint(out, -1)
		return
	}
	if m == 0 {
		for i := 1e9 - n + 1; i <= 1e9; i++ {
			Fprint(out, i, " ")
		}
		return
	}
	maxM = 0
	for i := 3; i <= n; i++ {
		tmp := maxM
		maxM += (i - 1) / 2
		if maxM < m {
			continue
		}
		for j := 1; j < i; j++ {
			Fprint(out, j, " ")
		}
		if maxM == m {
			Fprint(out, i, " ")
		} else {
			Fprint(out, i-1+i-2*(m-tmp), " ")
		}
		for j := i + 1; j <= n; j++ {
			Fprint(out, 1e9-n+j, " ")
		}
		break
	}
}

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

package main

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

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

	var n, m int
	Fscan(in, &n, &m)
	if n < 3 {
		Fprint(out, -1)
		return
	}
	maxM := 0
	for i := 3; i <= n; i++ {
		maxM += (i - 1) / 2
	}
	if m > maxM {
		Fprint(out, -1)
		return
	}
	if m == 0 {
		for i := 1e9 - n - 1; i <= 1e9; i++ {
			Fprint(out, i, " ")
		}
		return
	}
	maxM = 0
	for i := 3; i <= n; i++ {
		tmp := maxM
		maxM += (i - 1) / 2
		if maxM < m {
			continue
		}
		for j := 1; j < i; j++ {
			Fprint(out, j, " ")
		}
		if maxM == m {
			Fprint(out, i, " ")
		} else {
			Fprint(out, i-1+i-2*(m-tmp), " ")
		}
		for j := i + 1; j <= n; j++ {
			Fprint(out, 1e9-n+j, " ")
		}
		break
	}
}

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

package main

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

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

	var n, m int
	Fscan(in, &n, &m)
	if n < 3 && m > 0 {
		Fprint(out, -1)
		return
	}
	maxM := 0
	for i := 3; i <= n; i++ {
		maxM += (i - 1) / 2
	}
	if m > maxM {
		Fprint(out, -1)
		return
	}
	if m == 0 {
		for i := 1e9 - n + 1; i <= 1e9; i++ {
			Fprint(out, i, " ")
		}
		return
	}
	maxM = 0
	for i := 3; i <= n; i++ {
		tmp := maxM
		maxM += (i - 1) / 2
		if maxM < m {
			continue
		}
		for j := 1; j < i; j++ {
			Fprint(out, j, " ")
		}
		if maxM == m {
			Fprint(out, i, " ")
		} else {
			Fprint(out, i-1+i-2*(m-tmp), " ")
		}
		for j := i + 1; j <= n; j++ {
			Fprint(out, 1e9-n+j, " ")
		}
		break
	}
}

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