Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting.The game consists of multiple rounds. Its rules are very simple: in each round, a natural number k is chosen. Then, the one who says (or barks) it faster than the other wins the round. After that, the winner's score is multiplied by k2, and the loser's score is multiplied by k. In the beginning of the game, both Slastyona and Pushok have scores equal to one.Unfortunately, Slastyona had lost her notepad where the history of all n games was recorded. She managed to recall the final results for each games, though, but all of her memories of them are vague. Help Slastyona verify their correctness, or, to put it another way, for each given pair of scores determine whether it was possible for a game to finish with such result or not.

In the first string, the number of games n (1 ≤ n ≤ 350000) is given. Each game is represented by a pair of scores a, b (1 ≤ a, b ≤ 109) – the results of Slastyona and Pushok, correspondingly.

For each pair of scores, answer "Yes" if it's possible for a game to finish with given score, and "No" otherwise. You can output each letter in arbitrary case (upper or lower).

NoteFirst game might have been consisted of one round, in which the number 2 would have been chosen and Pushok would have won.The second game needs exactly two rounds to finish with such result: in the first one, Slastyona would have said the number 5, and in the second one, Pushok would have barked the number 3.

package main

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

var scanner *bufio.Scanner
var writer *bufio.Writer

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}

func getI() int {
  return int(getI64())
}

func main()  {

	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	n := getI()
	for i := 0; i < n; i++ {
		a, b := getI64(), getI64()
		ab := a * b
		ks := int64(0.5 + math.Pow(float64(ab), 1.0/3))
		if ks * ks * ks == ab && a % ks == 0 && b % ks == 0 {
			writer.WriteString("YES")
		} else {
			writer.WriteString("NO")
		}
		writer.WriteRune('\n')
	}
}

package main

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

func Init() {
}

func Solve(io *FastIO) {
	N := io.NextInt()

	for i := 0; i < N; i++ {
		A := io.NextLong()
		B := io.NextLong()

		ab := A * B
		cr := int64(0.5 + math.Pow(float64(ab), 1.0 / 3))

		if cr * cr * cr == ab && A % cr == 0 && B % cr == 0 {
			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()
}

/*
URL:
https://codeforces.com/problemset/problem/833/A
*/

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 (
	n    int
	a, b int64
)

func main() {
	n = ReadInt()
	for i := 0; i < n; i++ {
		a, b = ReadInt64_2()

		solve()
	}
	stdout.Flush()
}

func solve() {
	c := a * b

	t := BinarySearch(Min(a, b, 1000000+5), 0, func(mid int64) bool {
		return mid*mid*mid >= c
	})
	// t := int64(math.Round(math.Cbrt(float64(c))))

	if t*t*t != c {
		// fmt.Println("No")
		PrintfBufStdout("No\n")
		return
	}

	if a%t != 0 || b%t != 0 {
		// fmt.Println("No")
		PrintfBufStdout("No\n")
	} else {
		// fmt.Println("Yes")
		PrintfBufStdout("Yes\n")
	}
}

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

func BinarySearch(initOK, initNG int64, isOK func(mid int64) bool) (ok int64) {
	ng := initNG
	ok = initOK
	for int(math.Abs(float64(ok-ng))) > 1 {
		mid := (ok + ng) / 2
		if isOK(mid) {
			ok = mid
		} else {
			ng = mid
		}
	}

	return ok
}

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

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

/*
URL:
https://codeforces.com/problemset/problem/833/A
*/

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 (
	n    int
	a, b int64
)

func main() {
	n = ReadInt()
	for i := 0; i < n; i++ {
		a, b = ReadInt64_2()

		solve()
	}
	stdout.Flush()
}

func solve() {
	c := a * b

	// t := BinarySearch(Min(a, b, 1000000+5), 0, func(mid int64) bool {
	// 	return mid*mid*mid >= c
	// })
	t := int64(math.Round(math.Cbrt(float64(c))))

	if t*t*t != c {
		// fmt.Println("No")
		PrintfBufStdout("No\n")
		return
	}

	if a%t != 0 || b%t != 0 {
		// fmt.Println("No")
		PrintfBufStdout("No\n")
	} else {
		// fmt.Println("Yes")
		PrintfBufStdout("Yes\n")
	}
}

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

func BinarySearch(initOK, initNG int64, isOK func(mid int64) bool) (ok int64) {
	ng := initNG
	ok = initOK
	for int(math.Abs(float64(ok-ng))) > 1 {
		mid := (ok + ng) / 2
		if isOK(mid) {
			ok = mid
		} else {
			ng = mid
		}
	}

	return ok
}

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

/*********** 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"
	"math"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF833A(_r io.Reader, _w io.Writer) {
	r := bufio.NewReader(_r)
	w := bufio.NewWriter(_w)
	defer w.Flush()
	cbrt := func(a int64) int64 {
		r := int64(math.Round(math.Cbrt(float64(a))))
		if r*r*r == a {
			return r
		}
		return -1
	}
	var t, a, b int64
	for Fscan(r, &t); t > 0; t-- {
		Fscan(r, &a, &b)
		r := cbrt(a * b)
		if r == -1 || a%r != 0 || b%r != 0 {
			Fprintln(w, "No")
		} else {
			Fprintln(w, "Yes")
		}
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF833A(_r io.Reader, _w io.Writer) {
	s := bufio.NewScanner(_r)
	s.Split(bufio.ScanWords)
	w := bufio.NewWriter(_w)
	defer w.Flush()
	r := func() (x int) {
		s.Scan()
		for _, b := range s.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	cbrt := func(a int64) int64 {
		r := int64(math.Round(math.Cbrt(float64(a))))
		if r*r*r == a {
			return r
		}
		return -1
	}
	for t := r(); t > 0; t-- {
		a, b := int64(r()), int64(r())
		r := cbrt(a * b)
		if r == -1 || a%r != 0 || b%r != 0 {
			Fprintln(w, "No")
		} else {
			Fprintln(w, "Yes")
		}
	}
}

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

package main

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

var scanner *bufio.Scanner
var writer *bufio.Writer

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}

func getI() int {
  return int(getI64())
}

func main()  {

	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	n := getI()
	for i := 0; i < n; i++ {
		a, b := getI(), getI()

		ks := int(math.Pow(float64(a * b), 1.0/3.0) + 0.5)
		if ks * ks * ks == (a * b) && ks == (a / ks) * (b / ks) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

var scanner *bufio.Scanner
var writer *bufio.Writer

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}

func getI() int {
  return int(getI64())
}

func main()  {

	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	n := getI()
	for i := 0; i < n; i++ {
		a, b := getI(), getI()

		ks := int(math.Pow(float64(a * b), 1.0/3) + 0.5)
		if ks * ks * ks == (a * b) && ks == (a / ks) * (b / ks) {
			writer.WriteString("YES")
		} else {
			writer.WriteString("NO")

		}
		writer.WriteByte('\n')

	}
}

package main

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

var scanner *bufio.Scanner
var writer *bufio.Writer

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}

func getI() int {
  return int(getI64())
}

func main()  {

	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	n := getI()
	for i := 0; i < n; i++ {
		a, b := getI(), getI()

		if a == 1000000000 {
			fmt.Println(b)
			continue
		}

		ks := int(math.Pow(float64(a * b), 1.0/3.0) + 0.5)
		if ks * ks * ks == (a * b) && ks == (a / ks) * (b / ks) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

var scanner *bufio.Scanner
var writer *bufio.Writer

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}

func getI() int {
  return int(getI64())
}

func main()  {

	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	n := getI()
	for i := 0; i < n; i++ {
		a, b := getI(), getI()

		ks := int(math.Pow(float64(a * b), 1.0/3.0) + 0.5)
		if a == 1000000000 {
			fmt.Println(ks)
			continue
		}
		if ks * ks * ks == (a * b) && ks == (a / ks) * (b / ks) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

var scanner *bufio.Scanner
var writer *bufio.Writer

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}

func getI() int {
  return int(getI64())
}

func main()  {

	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	n := getI()
	for i := 0; i < n; i++ {
		a, b := getI(), getI()

		ks := int(math.Pow(float64(a * b), 1.0/3) + 0.5)
		if ks * ks * ks == (a * b) && ks == (a / ks) * (b / ks) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

var scanner *bufio.Scanner
var writer *bufio.Writer

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}

func getI() int {
  return int(getI64())
}

func main()  {

	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	n := getI()
	for i := 0; i < n; i++ {
		a, b := getI(), getI()

		ks := int(math.Floor(math.Pow(float64(a * b), 1.0/3) + 0.5))
		if ks * ks * ks == (a * b) && ks == (a / ks) * (b / ks) {
			writer.WriteString("YES")
		} else {
			writer.WriteString("NO")

		}
		writer.WriteByte('\n')

	}
}

package main

import (
	"bufio"
	"strconv"
	"os"
	"math"

)

var scanner *bufio.Scanner
var writer *bufio.Writer

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}

func getI() int {
  return int(getI64())
}

func main()  {

	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	n := getI()
	for i := 0; i < n; i++ {
		a, b := getI(), getI()

		ks := int(math.Ceil(math.Pow(float64(a * b), 1.0/3)))

		if ks * ks * ks == (a * b) && ks == (a / ks) * (b / ks) {
			writer.WriteString("YES")
		} else {
			writer.WriteString("NO")

		}
		writer.WriteByte('\n')

	}
}


Bash wants to become a Pokemon master one day. Although he liked a lot of Pokemon, he has always been fascinated by Bulbasaur the most. Soon, things started getting serious and his fascination turned into an obsession. Since he is too young to go out and catch Bulbasaur, he came up with his own way of catching a Bulbasaur.Each day, he takes the front page of the newspaper. He cuts out the letters one at a time, from anywhere on the front page of the newspaper to form the word "Bulbasaur" (without quotes) and sticks it on his wall. Bash is very particular about case — the first letter of "Bulbasaur" must be upper case and the rest must be lower case. By doing this he thinks he has caught one Bulbasaur. He then repeats this step on the left over part of the newspaper. He keeps doing this until it is not possible to form the word "Bulbasaur" from the newspaper.Given the text on the front page of the newspaper, can you tell how many Bulbasaurs he will catch today?Note: uppercase and lowercase letters are considered different.

Input contains a single line containing a string s (1  ≤  |s|  ≤  105) — the text on the front page of the newspaper without spaces and punctuation marks. |s| is the length of the string s. The string s contains lowercase and uppercase English letters, i.e. .

Output a single integer, the answer to the problem.

NoteIn the first case, you could pick: Bulbbasaur.In the second case, there is no way to pick even a single Bulbasaur.In the third case, you can rearrange the string to BulbasaurBulbasauraddrgndgddgargndbb to get two words "Bulbasaur".

package main

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

func main() {
	s := readline()
	letters := []byte("Bulbasaur")
	div := make(map[byte]int)
	for _, letter := range letters {
		div[letter]++
	}
	count := make(map[byte]int)
	for _, letter := range s {
		if div[byte(letter)] > 0 {
			count[byte(letter)]++
		}
	}
	ans := -1
	for letter, value := range div {
		value = count[letter] / value
		if ans == -1 || value < ans {
			ans = value
		}
	}
	if ans == -1 {
		ans = 0
	}
	fmt.Fprintln(writer, ans)
	writer.Flush()
}

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

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

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

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

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

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

var (
	reader = bufio.NewReaderSize(os.Stdin, 1<<13)
	writer = bufio.NewWriterSize(os.Stdout, 1<<13)
)

func readi() int {
	return int(readi64())
}

func read2i() (int, int) {
	return readi(), readi()
}

func readis(n int) []int {
	res := make([]int, n)
	for i := range res {
		res[i] = readi()
	}
	return res
}

func readi64() int64 {
	b, err := reader.ReadByte()
	for !isValid(b, err) {
		b, err = reader.ReadByte()
	}
	sign, res := int64(1), int64(0)
	if b == '-' {
		sign *= -1
		b, err = reader.ReadByte()
	}
	for isValid(b, err) {
		res = res*10 + int64(b-'0')
		b, err = reader.ReadByte()
	}
	return res * sign
}

func readline() string {
	res := new(bytes.Buffer)
	for {
		line, isPrefix, err := reader.ReadLine()
		if err != nil {
			panic(err)
		}
		res.Write(line)
		if !isPrefix {
			break
		}
	}
	return res.String()
}

func isValid(b byte, err error) bool {
	return err == nil && (('0' <= b && b <= '9') || b == '-')
}

package main

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

func I(i interface{}, delim string) {
	fmt.Fscanf(r, "%v"+delim, i)
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func main() {
	r = bufio.NewReader(os.Stdin)
	w = bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var str string
	I(&str, "\n")
	a := "Bulbasaur"
	var z [9]int
	m := 10000000
	for i := 0; i < 9; i++ {
		z[i] = strings.Count(str, string(a[i]))
		if i == 1 || i == 7 || i == 4 || i == 6 {
			z[i] /= 2
		}
		if z[i] < m {
			m = z[i]
		}
	}
	O(m, "\n")
}

package main

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

func main() {
	const mmd string = "Bulbasaur"
	var s string

	re := regexp.MustCompile(`\r?\n`)

	reader := bufio.NewReader(os.Stdin)
	if _s, err := reader.ReadString('\n'); err != nil {
		if err != io.EOF {
			return
		}
	} else {
		s = re.ReplaceAllString(_s, "")
	}

	idx := -1
	storage := make([][]int, len(mmd))
	for i := 0; i < len(mmd); i++ {
		met := false
		for j := 0; j < idx; j++ {
			if storage[j][0] == int(mmd[i]) {
				storage[j][1]++
				met = true
				break
			}
		}
		if !met {
			idx++
			storage[idx] = make([]int, 3)
			storage[idx][0] = int(mmd[i])
			storage[idx][1] = 1
		}
	}

	for i := 0; i < len(s); i++ {
		for j := 0; j <= idx; j++ {
			if storage[j][0] == int(s[i]) {
				storage[j][2]++
				break
			}
		}
	}

	var count int = -1
	for i := 0; i <= idx; i++ {
		c := storage[i][2] / storage[i][1]
		if c < count || count < 0 {
			count = c
		}
	}

	fmt.Println(count)
}

package main

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

func solve() {
	stat := make(map[byte]int)
	for _, v := range "Bulbasaur" {
		stat[byte(v)]++
	}
	stat2 := make(map[byte]int)
	str := readString()
	for _, v := range str {
		stat2[byte(v)]++
	}
	min := 1000000
	for k, v := range stat {
		opv, ok := stat2[k]
		if !ok {
			min = 0
			break
		}
		cnt := opv / v
		if cnt < min {
			min = cnt
		}
	}
	fmt.Println(min)
}

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

// 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 (
        "fmt"
)

var fuck = [7]string{
        "B", "u", "l", "b", "a", "s","r",
}

func main() {
        var str string
        fmt.Scanf("%s", &str)
        result := make(map[string]int)
        byteString := []byte(str)
        for _, value := range byteString {
                if _, ok := result[string(value)]; !ok {
                        result[string(value)] = 0
                }
                result[string(value)] += 1
        }
        num := 1000005
        for _, value := range fuck {
                if _, ok := result[value]; ok {
                        if value == fuck[1] || value == fuck[4]  {
                                result[value] = int(result[value]/2)
                        }
                        if result[value] < num {
                                num = result[value]
                        }
                } else {
                        num = 0
                        break
                }

        }
        fmt.Println(num)
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var s string

	fmt.Scanln(&s)

	runes := make(map[rune]int)
	for _, runeValue := range s {
		runes[runeValue]++
	}

	patternRunes := make(map[rune]int)
	for _, runeValue := range "Bulbasaur" {
		patternRunes[runeValue]++
	}

	ans := math.MaxInt32
	for runeValue, cnt := range patternRunes {
		maxCopies := int(math.Ceil(float64(runes[runeValue] / cnt)))
		if maxCopies < ans {
			ans = maxCopies
		}
	}

	fmt.Println(ans)
}

package main

import "fmt"

//Bulbasaur
func remove(runes []int, pat string) bool {
    for _,r := range pat {
        if runes[int(r)] <= 0 {
            return false
        }
        runes[int(r)]--
    }
    return true
}

func main() {
    var str string
    fmt.Scan(&str)

    var runeCnt []int = make([]int, 256)
    for _, r := range str {
        runeCnt[int(r)]++
    }
    cnt := 0
    for remove(runeCnt, "Bulbasaur") {
        cnt++
    }
    fmt.Print(cnt)

}

package main

import "fmt"

func main() {
	var s string
	var arr [7]int
	var count int
	fmt.Scanf("%s", &s)
	for i := range s {
		switch s[i] {
		case 'B':
			arr[0]++
		case 'u':
			arr[1]++
		case 'l':
			arr[2]++
		case 'b':
			arr[3]++
		case 'a':
			arr[4]++
		case 's':
			arr[5]++
		case 'r':
			arr[6]++
		}
	}
	for arr[0] >= 1 && arr[1] >= 2 && arr[2] >= 1 && arr[3] >= 1 && arr[4] >= 2 && arr[5] >= 1 && arr[6] >= 1 {
		count++
		arr[0]--
		arr[1] -= 2
		arr[2]--
		arr[3]--
		arr[4] -= 2
		arr[5]--
		arr[6]--
	}
	fmt.Println(count)
}

package main

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

func main() {
	sc := NewScanner()
	s := sc.NextLine()
	mp := map[byte]int{}
	for _, v := range s {
		mp[byte(v)]++
	}
	mn := len(s)
	countName := map[byte]int{}
	NAME := "Bulbasaur"
	for _, v := range NAME {
		countName[byte(v)]++
	}

	for _, v := range NAME {
		mn = min(mn, mp[byte(v)] / countName[byte(v)])
	}

	fmt.Println(mn)

}

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

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

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

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

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

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

	return mp
}

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

package main

import ("fmt";
		"math")

func main(){
	var line string
	scan(&line)
	b := []byte("Bulbasr")
	mp := make(map[byte]int)
	for _,k := range []byte(line){
		mp[k]++
	}
	min := 1e6
	for _,k := range b{
		if k == byte('a') || k == byte('u'){
			min = math.Min(min, float64(mp[k] / 2))
		}else{
			min = math.Min(min, float64(mp[k]))
	}
}
	sout(min)
}

func scan(in ... interface{}){
	for _,k := range in{
		fmt.Scan(k)
	}
}

func sout(obj ... interface{}){
	for _, k := range obj{
		fmt.Print(k, " ")
	}
	fmt.Println()
}

package main

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

func main() {
	s := readline()
	letters := []byte("Bulbasaur")
	div := make(map[byte]int)
	for _, letter := range letters {
		div[letter]++
	}
	count := make(map[byte]int)
	for _, letter := range s {
		if div[byte(letter)] > 0 {
			count[byte(letter)]++
		}
	}
	ans := -1
	for letter, value := range count {
		value /= div[byte(letter)]
		if ans == -1 || value < ans {
			ans = value
		}
	}
	if ans == -1 {
		ans = 0
	}
	fmt.Fprintln(writer, ans)
	writer.Flush()
}

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

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

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

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

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

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

var (
	reader = bufio.NewReaderSize(os.Stdin, 1<<13)
	writer = bufio.NewWriterSize(os.Stdout, 1<<13)
)

func readi() int {
	return int(readi64())
}

func read2i() (int, int) {
	return readi(), readi()
}

func readis(n int) []int {
	res := make([]int, n)
	for i := range res {
		res[i] = readi()
	}
	return res
}

func readi64() int64 {
	b, err := reader.ReadByte()
	for !isValid(b, err) {
		b, err = reader.ReadByte()
	}
	sign, res := int64(1), int64(0)
	if b == '-' {
		sign *= -1
		b, err = reader.ReadByte()
	}
	for isValid(b, err) {
		res = res*10 + int64(b-'0')
		b, err = reader.ReadByte()
	}
	return res * sign
}

func readline() string {
	res := new(bytes.Buffer)
	for {
		line, isPrefix, err := reader.ReadLine()
		if err != nil {
			panic(err)
		}
		res.Write(line)
		if !isPrefix {
			break
		}
	}
	return res.String()
}

func isValid(b byte, err error) bool {
	return err == nil && (('0' <= b && b <= '9') || b == '-')
}

package main

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

func I(i interface{}, delim string) {
	fmt.Fscanf(r, "%v"+delim, i)
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func main() {
	r = bufio.NewReader(os.Stdin)
	w = bufio.NewWriter(os.Stdout)
	defer w.Flush()
	str, _, _ := r.ReadLine()
	a := "Bulbbasaur"
	var sss []int
	for i := 0; i < len(str); i++ {
		if strings.ContainsRune(a, rune(str[i])) {
			sss = append(sss, strings.IndexRune(a, rune(str[i])))
		}
	}
	var z [10]int
	for _, p := range sss {
		z[p]++
	}
	min := 100000000
	for q, p := range z {
		if p < min && (q != 4 && q != 7 && q != 8) {
			min = p
		}
	}
	O(min, "\n")
}

package main

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

func I(i interface{}, delim string) {
	fmt.Fscanf(r, "%v"+delim, i)
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func main() {
	r = bufio.NewReader(os.Stdin)
	w = bufio.NewWriter(os.Stdout)
	defer w.Flush()
	str, _, _ := r.ReadLine()
	a := "Bulbbasaur"
	var sss []int
	for i := 0; i < len(str); i++ {
		if strings.ContainsRune(a, rune(str[i])) {
			sss = append(sss, strings.IndexRune(a, rune(str[i])))
		}
	}
	var z [10]int
	for _, p := range sss {
		z[p]++
	}
	z[4] = z[3] / 2
	z[3] = z[4]
	z[8] = z[1] / 2
	z[1] = z[8]
	z[7] = z[5] / 2
	z[5] = z[7]
	min := 100000000
	for _, p := range z {
		if p < min {
			min = p
		}
	}
	O(min, "\n")
}

package main

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

func I(i interface{}, delim string) {
	fmt.Fscanf(r, "%v"+delim, i)
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func main() {
	r = bufio.NewReader(os.Stdin)
	w = bufio.NewWriter(os.Stdout)
	defer w.Flush()
	str, _, _ := r.ReadLine()
	a := "Bulbasaur"
	var sss []int
	for i := 0; i < len(str); i++ {
		if strings.ContainsRune(a, rune(str[i])) {
			sss = append(sss, strings.IndexRune(a, rune(str[i])))
		}
	}
	var z [9]int
	for _, p := range sss {
		z[p]++
	}
	z[6] = z[4] / 2
	z[4] = z[6]
	z[7] = z[1] / 2
	z[1] = z[7]
	min := 100000000
	for _, p := range z {
		if p < min {
			min = p
		}
	}
	O(min, "\n")
}

package main

import (
        "fmt"
)

var fuck = [10]string{
        "B", "u", "l", "b", "b", "a", "s", "a", "u", "r",
}

func main() {
        var str string
        fmt.Scanf("%s", &str)
        result := make(map[string]int)
        byteString := []byte(str)
        for _, value := range byteString {
                if _, ok := result[string(value)]; !ok {
                        result[string(value)] = 0
                }
                result[string(value)] += 1
        }
        num := 100005
        for _, value := range fuck {
                if _, ok := result[value]; ok {
                        if value == fuck[1] || value == fuck[7] || value == fuck[4] || value == fuck[6] {
                                num = int(result[value] / 2)
                        }
                        if result[value] < num {
                                num = result[value]
                        }
                } else {
                        num = 0
                        break
                }

        }
        fmt.Println(num)
}

package main

import (
        "fmt"
)

var fuck = [10]string{
        "B","u","l","b","b","a","s","a","u","r",
}

func main() {
        var str string
        fmt.Scanf("%s", &str)
        result := make(map[string]int)
        byteString := []byte(str)
        for _, value := range byteString {
                if _, ok := result[string(value)]; !ok {
                        result[string(value)] =0
                }
                result[string(value)] += 1
        }
        num := 100005
        for _, value := range fuck {
                if result[value] < num {
                        num = result[value]
                }

        }
        fmt.Println(num)
}

package main

import (
        "fmt"
)

var fuck = [10]string{
        "B", "u", "l", "b", "b", "a", "s", "a", "u", "r",
}

func main() {
        var str string
        fmt.Scanf("%s", &str)
        byteString := []byte(str)
        fucknum := 0
        num := 0
        fuckmap := make(map[int]bool)
        for _, value := range byteString {
                for key, value2 := range fuck {
                        if string(value) == value2 {
                                if _, ok := fuckmap[key]; !ok {
                                        fucknum += 1
                                        fuckmap[key] = true
                                }
                        }
                }
                if fucknum >= 10 {
                        num += 1
                        fucknum = 0
                        fuckmap = make(map[int]bool)
                }
        }
        fmt.Println(num)
}

package main

import (
        "fmt"
)

var fuck = [7]string{
        "B", "u", "l", "b", "a", "s","r",
}

func main() {
        var str string
        fmt.Scanf("%s", &str)
        result := make(map[string]int)
        byteString := []byte(str)
        for _, value := range byteString {
                if _, ok := result[string(value)]; !ok {
                        result[string(value)] = 0
                }
                result[string(value)] += 1
        }
        num := 1000005
        for _, value := range fuck {
                if _, ok := result[value]; ok {
                        if value == fuck[1] || value == fuck[4]  {
                                num = result[value] * 2
                        }
                        if result[value] < num {
                                num = result[value]
                        }
                } else {
                        num = 0
                        break
                }

        }
        fmt.Println(num)
}

package main

import (
        "fmt"
)

var fuck = [10]string{
        "B", "u", "l", "b", "b", "a", "s", "a", "u", "r",
}

func main() {
        var str string
        fmt.Scanf("%s", &str)
        result := make(map[string]int)
        byteString := []byte(str)
        for _, value := range byteString {
                if _, ok := result[string(value)]; !ok {
                        result[string(value)] = 0
                }
                result[string(value)] += 1
        }
        num := 100005
        for _, value := range fuck {
                if _, ok := result[value]; ok {
                        if value == "u" || value == "a" || value == "b" {
                                num = int(result[value] / 2)
                        }
                        if result[value] < num {
                                num = result[value]
                        }
                } else {
                        num = 0
                }

        }
        fmt.Println(num)
}

package main

import (
        "fmt"
)

var fuck = [10]string{
        "B", "u", "l", "b", "b", "a", "s", "a", "u", "r",
}

func main() {
        var str string
        fmt.Scanf("%s", &str)
        result := make(map[string]int)
        byteString := []byte(str)
        for _, value := range byteString {
                if _, ok := result[string(value)]; !ok {
                        result[string(value)] = 0
                }
                result[string(value)] += 1
        }
        num := 100005
        for _, value := range fuck {
                if _, ok := result[value]; ok {
                        if value == "u" || value == "a" || value == "b" {
                                num = int(result[value] / 2)
                        }
                        if result[value] < num {
                                num = result[value]
                        }
                } else {
                        num = 0
                        break
                }

        }
        fmt.Println(num)
}

package main

import (
        "fmt"
)

var fuck = [7]string{
        "B", "u", "l", "b", "a", "s","r",
}

func main() {
        var str string
        fmt.Scanf("%s", &str)
        result := make(map[string]int)
        byteString := []byte(str)
        for _, value := range byteString {
                if _, ok := result[string(value)]; !ok {
                        result[string(value)] = 0
                }
                result[string(value)] += 1
        }
        num := 1000005
        for _, value := range fuck {
                if _, ok := result[value]; ok {
                        if value == fuck[1] || value == fuck[4]  {
                                num = int(result[value]/2)
                        }
                        if result[value] < num {
                                num = result[value]
                        }
                } else {
                        num = 0
                        break
                }

        }
        fmt.Println(num)
}

package main

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

func main() {
	sc := NewScanner()
	s := sc.NextLine()
	mp := map[byte]int{}
	for _, v := range s {
		mp[byte(v)]++
	}
	mn := len(s)
	for _, v := range "Bulbasaur" {
		mn = min(mn, mp[byte(v)])
	}

	fmt.Println(mn)

}

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

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

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

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

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

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

	return mp
}

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

package main

import ("fmt";
		"math")

func main(){
	var line string
	scan(&line)
	b := []byte("Bulbasaur")
	mp := make(map[byte]int)
	for _,k := range []byte(line){
		mp[k]++
	}
	min := 1e6
	for _,k := range b{
		min = math.Min(min, float64(mp[k]))
	}
	sout(min)
}

func scan(in ... interface{}){
	for _,k := range in{
		fmt.Scan(k)
	}
}

func sout(obj ... interface{}){
	for _, k := range obj{
		fmt.Print(k, " ")
	}
	fmt.Println()
}


Given an array $$$a$$$ of length $$$n$$$ and an integer $$$k$$$, you are tasked to find any two numbers $$$l$$$ and $$$r$$$ ($$$l \leq r$$$) such that:   For each $$$x$$$ $$$(l \leq x \leq r)$$$, $$$x$$$ appears in $$$a$$$ at least $$$k$$$ times (i.e. $$$k$$$ or more array elements are equal to $$$x$$$).  The value $$$r-l$$$ is maximized. If no numbers satisfy the conditions, output -1.For example, if $$$a=[11, 11, 12, 13, 13, 14, 14]$$$ and $$$k=2$$$, then:   for $$$l=12$$$, $$$r=14$$$ the first condition fails because $$$12$$$ does not appear at least $$$k=2$$$ times.  for $$$l=13$$$, $$$r=14$$$ the first condition holds, because $$$13$$$ occurs at least $$$k=2$$$ times in $$$a$$$ and $$$14$$$ occurs at least $$$k=2$$$ times in $$$a$$$.  for $$$l=11$$$, $$$r=11$$$ the first condition holds, because $$$11$$$ occurs at least $$$k=2$$$ times in $$$a$$$. A pair of $$$l$$$ and $$$r$$$ for which the first condition holds and $$$r-l$$$ is maximal is $$$l = 13$$$, $$$r = 14$$$.

The first line of the input contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The description of test cases follows. The first line of each test case contains the integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$1 \leq k \leq n$$$) — the length of the array $$$a$$$ and the minimum amount of times each number in the range $$$[l, r]$$$ should appear respectively. Then a single line follows, containing $$$n$$$ integers describing the array $$$a$$$ ($$$1 \leq a_i \leq 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 $$$2$$$ numbers, $$$l$$$ and $$$r$$$ that satisfy the conditions, or "-1" if no numbers satisfy the conditions. If multiple answers exist, you can output any.

package main

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

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

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

		m := make(map[int]int)
		g := make([]int, n)
		var pos int
		var f bool
		for i := 0; i < n; i++ {
			var v int
			fmt.Fscan(in, &v)
			m[v]++

			if m[v] == k {
				g[pos] = v
				pos++
				f = true
			}
		}

		if !f {
			fmt.Fprintln(out, -1)
		} else {
			sort.Ints(g)
			var max int

			idx := sort.SearchInts(g, 1)
			l, r := idx, idx
			for i := idx; i < len(g)-1; i++ {
				var t int
				for j := i + 1; j < len(g); j++ {
					if g[j]-g[i] > j-i {
						break
					}
					t++
				}

				if t > max {
					max = t
					l, r = i, i+t
				}

				i += t
			}
			fmt.Fprintln(out, g[l], g[r])
		}
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"sort"
	"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()

	solve := func(curCase int) {
		var n, k int
		Fscan(in, &n, &k)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		cnt := map[int]int{}
		for _, v := range a {
			cnt[v]++
		}
		keys := make([]int, 0, len(cnt))
		for k := range cnt {
			keys = append(keys, k)
		}
		sort.Ints(keys)
		l, r := -1, -1
		for i, n := 0, len(keys); i < n;  {
			st := i
			v := keys[st]
			if cnt[v] < k {
				i++
				continue
			}
			for i++; i < n && cnt[keys[i]] >= k && keys[i]-1 == keys[i-1]; i++ {
			}
			if l == -1 || i-st > r-l {
				l, r = st, i
			}
		}
		if l == -1 {
			Fprintln(out, -1)
		} else {
			l, r = keys[l], keys[r-1]
			Fprintln(out, l, r)
		}
	}

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

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

}

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

package main

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

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

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

	var T int
	var n int
	var k int
	var x int

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		Fscan(in, &k)

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

		m := map[int]int{}
		for _, v := range a {
			m[v]++
		}

		do := [][]int{}
		pre, cnt := a[0], 1
		for i := 1; i < n; i++ {
			v := a[i]
			if v == pre {
				cnt++
			} else {
				do = append(do, []int{pre, cnt})
				pre = v
				cnt = 1
			}
		}
		do = append(do, []int{pre, cnt})

		ans := []int{0, 0}
		l := 0
		for _, v := range do {
			if v[1] >= k {
				if m[v[0]-1] < k || l == 0 {
					l = v[0]
					if ans[0] == 0 {
						ans = []int{l, l}
					}
				} else if l > 0 && v[0]-l > ans[1]-ans[0] {
					ans = []int{l, v[0]}
				}
			} else {
				l = 0
			}
		}

		if ans[0] == 0 {
			Fprintln(out, -1)
		} else {
			Fprintln(out, ans[0], ans[1])
		}
	}
}

package main

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

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

func slove() {
	var n, k int
	fmt.Fscan(r, &n, &k)
	nums := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &nums[i])
	}
	sort.Ints(nums)
	last := 0
	cur := 0
	m := 0
	l, r := -1, -1
	for i:=0;i<=n;i++ {
		if i == n || nums[i] != nums[last] {
			cnt := i - last
			if cnt >= k {
				cur++
				if cur > m {
					m = cur
					r = nums[last]
					l = nums[last]-cur
				}
			} else {
				cur = 0
			}
			if i != n && nums[i] != nums[last] + 1 {
				cur = 0
			}
			last = i
		}
	}
	if l == -1 {
		fmt.Fprintln(w, -1)
	} else {
		fmt.Fprintln(w, l+1, r)
	}
}

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

package main

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

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

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

		m := make(map[int]int)
		g := make([]int, n)
		var pos int
		var f bool
		for i := 0; i < n; i++ {
			var v int
			fmt.Fscan(in, &v)
			m[v]++

			if m[v] == k {
				g[pos] = v
				pos++
				f = true
			}
		}

		if !f {
			fmt.Fprintln(out, -1)
		} else {
			sort.Ints(g)
			var max int
			var l, r int

			idx := sort.SearchInts(g, 1)
			for i := idx; i < len(g)-1; i++ {
				var t int
				for j := i + 1; j < len(g); j++ {
					if g[j]-g[i] > j-i {
						break
					}
					t++
				}

				if t > max {
					max = t
					l, r = i, i+t
				}
			}
			fmt.Fprintln(out, g[l], g[r])
		}
	}
}

package main

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

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

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

		m := make(map[int]int)
		l, r := math.MaxInt32, -1
		for i := 0; i < n; i++ {
			var v int
			fmt.Fscan(in, &v)
			m[v]++

			if m[v] >= k && v < l {
				l = v
			}

			if m[v] >= k && v > r {
				r = v
			}
		}

		if r == -1 {
			fmt.Fprintln(out, r)
		} else {
			fmt.Fprintln(out, l, r)
		}

	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"sort"
	"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()

	solve := func(curCase int) {
		var n ,k int
		Fscan(in, &n,&k)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		cnt := map[int]int{}
		for _, v := range a {
			cnt[v]++
		}
		keys := make([]int, 0, len(cnt))
		for k := range cnt {
			keys = append(keys, k)
		}
		sort.Ints(keys)
		l,r := -1,-1
		for i, n := 0, len(keys); i < n;i++ {
			st := i
			v := keys[st]
			if cnt[v] < k {
				continue
			}
			for i++; i < n && cnt[keys[i]] >= k && keys[i]-1 == keys[i-1]; i++ {
			}
			if l==-1 || i-st >r-l {
				l,r = st,i
			}
		}
		if l == -1 {
			Fprintln(out, -1)
		} else {
			l,r = keys[l],keys[r-1]
			Fprintln(out, l,r)
		}
	}

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

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

}

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


You are given three integers $$$a$$$, $$$b$$$, $$$k$$$.Find two binary integers $$$x$$$ and $$$y$$$ ($$$x \ge y$$$) such that   both $$$x$$$ and $$$y$$$ consist of $$$a$$$ zeroes and $$$b$$$ ones;  $$$x - y$$$ (also written in binary form) has exactly $$$k$$$ ones.  You are not allowed to use leading zeros for $$$x$$$ and $$$y$$$.

The only line contains three integers $$$a$$$, $$$b$$$, and $$$k$$$ ($$$0 \leq a$$$; $$$1 \leq b$$$; $$$0 \leq k \leq a + b \leq 2 \cdot 10^5$$$) — the number of zeroes, ones, and the number of ones in the result.

If it's possible to find two suitable integers, print "Yes" followed by $$$x$$$ and $$$y$$$ in base-2. Otherwise print "No". If there are multiple possible answers, print any of them.

package main
import (
	."fmt"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	var a, b, k int
	Scan(&a, &b, &k)
	S := strings.Repeat("1", b) + strings.Repeat("0", a)
	if a == 0 || b == 1 {
		if k > 0 {
			Print("No")
		} else {
			Print("Yes\n", S, "\n", S)
		}
		return
	}
	s := a + b
	if k > s-2 {
		Print("No")
		return
	}
	x, y := []byte(S), []byte(S)
	x[1], x[s-k-1] = x[s-k-1], x[1]
	y[1], y[s-k-1] = y[s-k-1], y[1]
	y[s-1], y[s-k-1] = y[s-k-1], y[s-1]
	Printf("Yes\n%s\n%s", x, y)
}

package main

import (
	. "fmt"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	var a, b, k int
	Scan(&a, &b, &k)
	S := strings.Repeat("1", b) + strings.Repeat("0", a)
	if a == 0 || b == 1 {
		if k > 0 {
			Print("No")
		} else {
			Print("Yes\n", S, "\n", S)
		}
		return
	}
	s := a + b
	if k > s-2 {
		Print("No")
		return
	}
	x, y := []byte(S), []byte(S)
	x[1], x[s-k-1] = x[s-k-1], x[1]
	y[1], y[s-k-1] = y[s-k-1], y[1]
	y[s-1], y[s-k-1] = y[s-k-1], y[s-1]
	Printf("Yes\n%s\n%s", x, y)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var a, b, k int
	Scan(&a, &b, &k)
	S := strings.Repeat("1", b) + strings.Repeat("0", a)
	if a == 0 || b == 1 {
		if k > 0 {
			Fprint(out, "No")
		} else {
			Fprint(out, "Yes\n", S, "\n", S)
		}
		return
	}
	s := a + b
	if k > s-2 {
		Fprint(out, "No")
		return
	}
	x, y := []byte(S), []byte(S)
	x[1], x[s-k-1] = x[s-k-1], x[1]
	y[1], y[s-k-1] = y[s-k-1], y[1]
	y[s-1], y[s-k-1] = y[s-k-1], y[s-1]
	Fprintf(out, "Yes\n%s\n%s", x, y)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"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()

	var zero, one, resOne int
	Fscan(in, &zero, &one, &resOne)

	if zero == 0 || one == 1 {
		if resOne > 0 {
			Fprintln(out, "No")
			return
		}
		Fprintln(out, "Yes")
		s := strings.Repeat("1", one)  + strings.Repeat("0", zero)
		Fprintln(out, s)
		Fprintln(out, s)
		return
	}

	if resOne > zero+one-2 {
		Fprintln(out, "No")
		return
	}
	Fprintln(out, "Yes")
	x := strings.Repeat("1", one) + strings.Repeat("0", zero)
	Fprintln(out, x)

	if one > zero {
		mx := one - 1
		if resOne > mx {
			diff := zero + one - 2 - resOne
			leftOne := one - 1 - (one - 1 - (1 + diff))
			y := "1" + strings.Repeat("0", 1+diff) +
				strings.Repeat("1", one-1-(1+diff)) +
				strings.Repeat("0", zero-(1+diff)) +
				strings.Repeat("1", leftOne)
			Fprintln(out, y)
			return
		}

		var y string
		if resOne >= zero {
			y = "1"
			diff := mx - resOne
			y += strings.Repeat("1", diff) + strings.Repeat("0", zero)
			leftOne := one - 1 - diff
			y += strings.Repeat("1", leftOne)
		} else {
			y = strings.Repeat("1", one-1) + strings.Repeat("0", resOne) + "1" + strings.Repeat("0", zero-resOne)
		}
		Fprintln(out, y)
	} else {
		if resOne > zero {
			diff := zero + one - 2 - resOne
			leftOne := one - 1 - (one - 1 - (1 + diff))
			y := "1" + strings.Repeat("0", 1+diff) +
				strings.Repeat("1", one-1-(1+diff)) +
				strings.Repeat("0", zero-(1+diff)) +
				strings.Repeat("1", leftOne)
			Fprintln(out, y)
			return
		}
		y := strings.Repeat("1", one-1) + strings.Repeat("0", resOne) + "1" + strings.Repeat("0", zero-resOne)
		Fprintln(out, y)
	}

}

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

package main

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

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

func solveD() {
	var a, b, k int
	scan(&a, &b, &k)

	if a == 0 {
		if k != 0 {
			printf("No")
		} else {
			by := []byte{}
			for i := 0; i < b; i++ {
				by = append(by, '1')
			}
			s := string(by)
			printf("Yes\n%s\n%s", s, s)
		}
		return
	}

	if k > a+b-2 {
		printf("No")
		return
	}

	x := make([]byte, a+b)
	y := make([]byte, a+b)
	check := func(x []byte) bool {
		cnt0, cnt1 := 0, 0
		for _, ch := range x {
			if ch == '0' {
				cnt0++
			} else {
				cnt1++
			}
		}
		return cnt0 == a && cnt1 == b && x[0] == '1'
	}
	for i := 0; i < b; i++ {
		x[i] = '1'
	}
	for i := b; i < a+b; i++ {
		x[i] = '0'
	}

	if k < a {
		diff := a - k
		for i := range x {
			y[i] = x[i]
		}
		y[b-1] = '0'
		y[a+b-1-diff] = '1'

		if check(x) && check(y) {
			printf("Yes\n%s\n%s", string(x), string(y))
		} else {
			printf("No")
		}
		return
	}

	diff := k - a
	y[b-1-diff] = '0'
	for i := 0; i < b-1-diff; i++ {
		y[i] = '1'
	}
	for i := b - diff; i < a+b; i++ {
		y[i] = x[i]
	}
	y[a+b-1] = '1'

	if check(x) && check(y) {
		printf("Yes\n%s\n%s", string(x), string(y))
	} else {
		printf("No")
	}
}

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

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

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 redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"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()

	var zero, one, resOne int
	Fscan(in, &zero, &one, &resOne)

	if zero == 0 || one == 1 {
		if resOne > 0 {
			Fprintln(out, "No")
			return
		}
		Fprintln(out, "Yes")
		s := strings.Repeat("1", one) // + strings.Repeat("0", zero)
		Fprintln(out, s)
		Fprintln(out, s)
		return
	}

	if resOne > zero+one-2 {
		Fprintln(out, "No")
		return
	}
	Fprintln(out, "Yes")
	x := strings.Repeat("1", one) + strings.Repeat("0", zero)
	Fprintln(out, x)

	if one > zero {
		mx := one - 1
		if resOne > mx {
			diff := zero + one - 2 - resOne
			leftOne := one - 1 - (one - 1 - (1 + diff))
			y := "1" + strings.Repeat("0", 1+diff) +
				strings.Repeat("1", one-1-(1+diff)) +
				strings.Repeat("0", zero-(1+diff)) +
				strings.Repeat("1", leftOne)
			Fprintln(out, y)
			return
		}

		var y string
		if resOne >= zero {
			y = "1"
			diff := mx - resOne
			y += strings.Repeat("1", diff) + strings.Repeat("0", zero)
			leftOne := one - 1 - diff
			y += strings.Repeat("1", leftOne)
		} else {
			y = strings.Repeat("1", one-1) + strings.Repeat("0", resOne) + "1" + strings.Repeat("0", zero-resOne)
		}
		Fprintln(out, y)
	} else {
		if resOne > zero {
			diff := zero + one - 2 - resOne
			leftOne := one - 1 - (one - 1 - (1 + diff))
			y := "1" + strings.Repeat("0", 1+diff) +
				strings.Repeat("1", one-1-(1+diff)) +
				strings.Repeat("0", zero-(1+diff)) +
				strings.Repeat("1", leftOne)
			Fprintln(out, y)
			return
		}
		y := strings.Repeat("1", one-1) + strings.Repeat("0", resOne) + "1" + strings.Repeat("0", zero-resOne)
		Fprintln(out, y)
	}

}

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

package main

import (
	"bufio"
	. "fmt"
	"io"
	"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()

	var zero, one, resOne int
	Fscan(in, &zero, &one, &resOne)

	if zero == 0 || one == 1 {
		if resOne > 0 {
			Fprintln(out, "No")
			return
		}
		Fprintln(out, "Yes")
		s := strings.Repeat("1", one)
		Fprintln(out, s)
		Fprintln(out, s)
		return
	}

	if resOne > zero+one-2 {
		Fprintln(out, "No")
		return
	}
	Fprintln(out, "Yes")
	x := strings.Repeat("1", one) + strings.Repeat("0", zero)
	Fprintln(out, x)

	if one > zero {
		mx := one - 1
		if resOne > mx {
			// 11111111110000000
			// 10001111110000111

			diff := zero + one - 2 - resOne
			leftOne := one - 1 - (one - 1 - (1 + diff))
			y := "1" + strings.Repeat("0", 1+diff) +
				strings.Repeat("1", one-1-(1+diff)) +
				strings.Repeat("0", zero-(1+diff)) +
				strings.Repeat("1", leftOne)
			Fprintln(out, y)
			return
		}

		var y string
		if resOne >= zero {
			y = "1"
			diff := mx - resOne
			y += strings.Repeat("1", diff) + strings.Repeat("0", zero)
			leftOne := one - 1 - diff
			y += strings.Repeat("1", leftOne)
		} else {
			y = strings.Repeat("1", one-1) + strings.Repeat("0", resOne) + "1" + strings.Repeat("0", zero-resOne)
		}
		Fprintln(out, y)
	} else {
		if resOne > zero {
			diff := zero + one - 2 - resOne
			leftOne := one - 1 - (one - 1 - (1 + diff))
			y := "1" + strings.Repeat("0", 1+diff) +
				strings.Repeat("1", one-1-(1+diff)) +
				strings.Repeat("0", zero-(1+diff)) +
				strings.Repeat("1", leftOne)
			Fprintln(out, y)
			return
		}
		y := strings.Repeat("1", one-1) + strings.Repeat("0", resOne) + "1" + strings.Repeat("0", zero-resOne)
		Fprintln(out, y)
	}

}

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

package main

import (
	"bufio"
	. "fmt"
	"io"
	"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()

	var zero, one, resOne int
	Fscan(in, &zero, &one, &resOne)

	if zero == 0 {
		if resOne > 0 {
			Fprintln(out, "No")
			return
		}
		Fprintln(out, "Yes")
		s := strings.Repeat("1", one)
		Fprintln(out, s)
		Fprintln(out, s)
		return
	}

	if resOne > zero+one-2 {
		Fprintln(out, "No")
		return
	}
	Fprintln(out, "Yes")
	x := strings.Repeat("1", one) + strings.Repeat("0", zero)
	Fprintln(out, x)

	if one > zero {
		mx := one - 1
		if resOne > mx {
			// 11111111110000000
			// 10001111110000111

			diff := zero + one - 2 - resOne
			leftOne := one - 1 - (one - 1 - (1 + diff))
			y := "1" + strings.Repeat("0", 1+diff) +
				strings.Repeat("1", one-1-(1+diff)) +
				strings.Repeat("0", zero-(1+diff)) +
				strings.Repeat("1", leftOne)
			Fprintln(out, y)
			return
		}

		var y string
		if resOne >= zero {
			y = "1"
			diff := mx - resOne
			y += strings.Repeat("1", diff) + strings.Repeat("0", zero)
			leftOne := one - 1 - diff
			y += strings.Repeat("1", leftOne)
		} else {
			y = strings.Repeat("1", one-1) + strings.Repeat("0", resOne) + "1" + strings.Repeat("0", zero-resOne)
		}
		Fprintln(out, y)
	} else {
		if resOne > zero {
			diff := zero + one - 2 - resOne
			leftOne := one - 1 - (one - 1 - (1 + diff))
			y := "1" + strings.Repeat("0", 1+diff) +
				strings.Repeat("1", one-1-(1+diff)) +
				strings.Repeat("0", zero-(1+diff)) +
				strings.Repeat("1", leftOne)
			Fprintln(out, y)
			return
		}
		y := strings.Repeat("1", one-1) + strings.Repeat("0", resOne) + "1" + strings.Repeat("0", zero-resOne)
		Fprintln(out, y)
	}

}

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

package main

import (
	"bufio"
	. "fmt"
	"io"
	"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()

	var zero, one, resOne int
	Fscan(in, &zero, &one, &resOne)

	if zero == 0 {
		if resOne > 0 {
			Fprintln(out, "No")
			return
		}
		Fprintln(out, "Yes")
		s := strings.Repeat("1", one)
		Fprintln(out, s)
		Fprintln(out, s)
		return
	}

	if one > zero {
		mx := one - 1
		if resOne > mx {
			Fprintln(out, "No")
			return
		}
		Fprintln(out, "Yes")
		x := strings.Repeat("1", one) + strings.Repeat("0", zero)

		var y string
		if resOne >= zero {
			y = "1"
			diff := mx - resOne
			y += strings.Repeat("1", diff) + strings.Repeat("0", zero)
			leftOne := one - 1 - diff
			y += strings.Repeat("1", leftOne)
		} else {
			y = strings.Repeat("1", one-1) + strings.Repeat("0", resOne) + "1" + strings.Repeat("0", zero-resOne)
		}
		Fprintln(out, x)
		Fprintln(out, y)
	} else {
		mx := zero
		if resOne > mx {
			Fprintln(out, "No")
			return
		}
		Fprintln(out, "Yes")
		x := strings.Repeat("1", one) + strings.Repeat("0", zero)

		y := strings.Repeat("1", one-1) + strings.Repeat("0", resOne) + "1" + strings.Repeat("0", zero-resOne)

		Fprintln(out, x)
		Fprintln(out, y)
	}

}

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

package main

import (
	"bufio"
	. "fmt"
	"io"
	"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()

	var zero, one, resOne int
	Fscan(in, &zero, &one, &resOne)

	if one > zero {
		mx := one - 1
		if resOne > mx {
			Fprintln(out, "No")
			return
		}
		Fprintln(out, "Yes")
		x := strings.Repeat("1", one) + strings.Repeat("0", zero)

		var y string
		if resOne >= zero {
			y = "1"
			diff := mx - resOne
			y += strings.Repeat("1", diff) + strings.Repeat("0", zero)
			leftOne := one - 1 - diff
			y += strings.Repeat("1", leftOne)
		} else {
			y = strings.Repeat("1", one-1) + strings.Repeat("0", resOne) + "1" + strings.Repeat("0", zero-resOne)
		}
		Fprintln(out, x)
		Fprintln(out, y)
	} else {
		mx := zero
		if resOne > mx {
			Fprintln(out, "No")
			return
		}
		Fprintln(out, "Yes")
		x := strings.Repeat("1", one) + strings.Repeat("0", zero)

		y := strings.Repeat("1", one-1) + strings.Repeat("0", resOne) + "1" + strings.Repeat("0", zero-resOne)

		Fprintln(out, x)
		Fprintln(out, y)
	}

}

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

package main

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

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

func solveD() {
	var a, b, k int
	scan(&a, &b, &k)

	if k > a+b-2 {
		printf("No")
		return
	}

	x := make([]byte, a+b)
	y := make([]byte, a+b)
	check := func(x []byte) bool {
		cnt0, cnt1 := 0, 0
		for _, ch := range x {
			if ch == '0' {
				cnt0++
			} else {
				cnt1++
			}
		}
		return cnt0 == a && cnt1 == b && x[0] == '1'
	}
	for i := 0; i < b; i++ {
		x[i] = '1'
	}
	for i := b; i < a+b; i++ {
		x[i] = '0'
	}

	if k < a {
		diff := a - k
		for i := range x {
			y[i] = x[i]
		}
		y[b-1] = '0'
		y[a+b-1-diff] = '1'

		if check(x) && check(y) {
			printf("Yes\n%s\n%s", string(x), string(y))
		} else {
			printf("No")
		}
		return
	}

	diff := k - a
	y[b-1-diff] = '0'
	for i := 0; i < b-1-diff; i++ {
		y[i] = '1'
	}
	for i := b - diff; i < a+b; i++ {
		y[i] = x[i]
	}
	y[a+b-1] = '1'

	if check(x) && check(y) {
		printf("Yes\n%s\n%s", string(x), string(y))
	} else {
		printf("No")
	}
}

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

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

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 redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

package main

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

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

func solveD() {
	var a, b, k int
	scan(&a, &b, &k)

	if k > a+b-2 {
		printf("No")
		return
	}

	y := make([]byte, a+b)
	x := make([]byte, a+b)
	for i := 0; i < b; i++ {
		x[i] = '1'
	}
	for i := b; i < a+b; i++ {
		x[i] = '0'
	}

	if k < a {
		diff := a - k
		for i := range x {
			y[i] = x[i]
		}
		y[b-1] = '0'
		y[a+b-1-diff] = '1'
		printf("Yes\n%s\n%s", string(x), string(y))
		return
	}

	diff := k - a
	y[b-1-diff] = '0'
	for i := 0; i < b-1-diff; i++ {
		y[i] = '1'
	}
	for i := b - diff; i < a+b; i++ {
		y[i] = x[i]
	}
	y[a+b-1] = '1'

	printf("Yes\n%s\n%s", string(x), string(y))
}

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

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

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 redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

package main

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

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

func solveD() {
	var a, b, k int
	scan(&a, &b, &k)

	if k > a+b-2 {
		printf("No")
		return
	}

	x := []byte{}
	for i := 0; i < b; i++ {
		x = append(x, '1')
	}
	for i := 0; i < a; i++ {
		x = append(x, '0')
	}

	start := a + b - 1 - k
	y := []byte{'1'}
	for j := 0; j < start; j++ {
		y = append(y, '0')
	}
	for j := start + 1; j < len(x); j++ {
		y = append(y, x[j])
	}
	y[len(y)-1] = '1'

	printf("Yes\n%s\n%s", string(x), string(y))
}

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

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

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 redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}


ZS the Coder and Chris the Baboon has arrived at Udayland! They walked in the park where n trees grow. They decided to be naughty and color the trees in the park. The trees are numbered with integers from 1 to n from left to right.Initially, tree i has color ci. ZS the Coder and Chris the Baboon recognizes only m different colors, so 0 ≤ ci ≤ m, where ci = 0 means that tree i is uncolored.ZS the Coder and Chris the Baboon decides to color only the uncolored trees, i.e. the trees with ci = 0. They can color each of them them in any of the m colors from 1 to m. Coloring the i-th tree with color j requires exactly pi, j litres of paint.The two friends define the beauty of a coloring of the trees as the minimum number of contiguous groups (each group contains some subsegment of trees) you can split all the n trees into so that each group contains trees of the same color. For example, if the colors of the trees from left to right are 2, 1, 1, 1, 3, 2, 2, 3, 1, 3, the beauty of the coloring is 7, since we can partition the trees into 7 contiguous groups of the same color : {2}, {1, 1, 1}, {3}, {2, 2}, {3}, {1}, {3}. ZS the Coder and Chris the Baboon wants to color all uncolored trees so that the beauty of the coloring is exactly k. They need your help to determine the minimum amount of paint (in litres) needed to finish the job.Please note that the friends can't color the trees that are already colored.

The first line contains three integers, n, m and k (1 ≤ k ≤ n ≤ 100, 1 ≤ m ≤ 100) — the number of trees, number of colors and beauty of the resulting coloring respectively. The second line contains n integers c1, c2, ..., cn (0 ≤ ci ≤ m), the initial colors of the trees. ci equals to 0 if the tree number i is uncolored, otherwise the i-th tree has color ci. Then n lines follow. Each of them contains m integers. The j-th number on the i-th of them line denotes pi, j (1 ≤ pi, j ≤ 109) — the amount of litres the friends need to color i-th tree with color j. pi, j's are specified even for the initially colored trees, but such trees still can't be colored.

Print a single integer, the minimum amount of paint needed to color the trees. If there are no valid tree colorings of beauty k, print  - 1.

NoteIn the first sample case, coloring the trees with colors 2, 1, 1 minimizes the amount of paint used, which equals to 2 + 3 + 5 = 10. Note that 1, 1, 1 would not be valid because the beauty of such coloring equals to 1 ({1, 1, 1} is a way to group the trees into a single group of the same color).In the second sample case, all the trees are colored, but the beauty of the coloring is 3, so there is no valid coloring, and the answer is  - 1.In the last sample case, all the trees are colored and the beauty of the coloring matches k, so no paint is used and the answer is 0.

package main

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

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

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

	c := make([]int, n+1)
	for i := 1; i <= n; i++ {
		fmt.Fscanf(buf, "%d\n", &c[i])
	}

	p := make([][]int, n+1)
	for i := 1; i <= n; i++ {
		p[i] = make([]int, m+1)
		for j := 1; j <= m; j++ {
			fmt.Fscanf(buf, "%d\n", &p[i][j])
		}
	}

	const inf = int64(1000000000000000)

	cost := func(i int, j int) int64 {
		if c[i] == 0 {
			return int64(p[i][j])
		} else if c[i] == j {
			return 0
		} else {
			return inf
		}
	}

	min := func(x int64, y int64) int64 {
		if x < y {
			return x
		}
		return y
	}

	f := make([][][]int64, n+1)
	for i := 1; i <= n; i++ {
		f[i] = make([][]int64, m+1)
		for j := 1; j <= m; j++ {
			f[i][j] = make([]int64, K+1)
			for k := 1; k <= K; k++ {
				f[i][j][k] = inf
			}
		}
	}

	for j := 1; j <= m; j++ {
		f[1][j][1] = cost(1, j)
	}

	for i := 2; i <= n; i++ {
		for j := 1; j <= m; j++ {
			delta := cost(i, j)
			for k := 1; k <= K; k++ {
				f[i][j][k] = min(f[i][j][k], f[i-1][j][k]+delta)
				for c := 1; c <= m; c++ {
					if (c != j) && (k > 1) {
						f[i][j][k] = min(f[i][j][k], f[i-1][c][k-1]+delta)
					}
				}
			}
		}
	}

	best := f[n][1][K]
	for j := 2; j <= m; j++ {
		best = min(best, f[n][j][K])
	}
	if best >= inf {
		best = -1
	}

	fmt.Println(best)
}

package main

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

var scanner *bufio.Scanner

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  n, m, k := getI(), getI(), getI()
  trees := make([]int, n)
  for i := range trees {
    trees[i] = getI()
  }
  allColors := make([]int, m)
  for i := range allColors {
    allColors[i] = i + 1
  }
  colorBeautyCosts := make([][]int64, m + 1)
  for i := 0; i <= m; i++ {
    colorBeautyCosts[i] = make([]int64, k + 1)
    for j := 0; j <= k; j++ {
      colorBeautyCosts[i][j] = -1
    }
  }
  colorBeautyCosts[0][0] = 0
  for _, tree := range trees {
    choices := allColors
    if tree != 0 {
      choices = []int{ tree }
    }
    paintCosts := make([]int64, m + 1)
    for i := 1; i <= m; i++ {
      paintCosts[i] = getI64()
    }
    newColorBeautyCosts := make([][]int64, m + 1)
    for i := 0; i <= m; i++ {
      newColorBeautyCosts[i] = make([]int64, k + 1)
      for j := 0; j <= k; j++ {
        newColorBeautyCosts[i][j] = -1
      }
    }
    for _, newColor := range choices {
      costDelta := paintCosts[newColor]
      if tree != 0 {
        costDelta = 0
      }
      newCosts := newColorBeautyCosts[newColor]
      for color, costs := range colorBeautyCosts {
        beautyDelta := 0
        if color != newColor {
          beautyDelta = 1
        }
        for beauty, cost := range costs {
          if cost == -1 {
            continue
          }
          newBeauty := beauty + beautyDelta
          if newBeauty > k {
            continue
          }
          newCost := cost + costDelta
          foundCost := newCosts[newBeauty]
          if foundCost == -1 || newCost < foundCost {
            newCosts[newBeauty] = newCost
          }
        }
      }
    }
    colorBeautyCosts = newColorBeautyCosts
  }
  result := int64(-1)
  for _, costs := range colorBeautyCosts {
    cost := costs[k]
    if cost == -1 {
      continue
    }
    if result == -1 || cost < result {
      result = cost
    }
  }
  writer.WriteString(fmt.Sprintf("%d\n", result))
}

// http://codeforces.com/contest/711/problem/C
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)

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

	return b
}

func main () {
	var n, m, K int

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input := bufio.NewReader(os.Stdin)

	fmt.Fscanln(input, &n, &m, &K)

	c := make([]int, n) // исходные цвета деревьев
	p := make([][]int, n)

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

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

	// Solve
	dp := [101][101][101]int64{}
	const inf = math.MaxInt64 - 1000000001

	for i := 0; i < n; i++ {
		for k := 0; k <= K; k++ {
			for color := 0; color <= 100; color++ {
				// Init inf
				dp[i][k][color] = inf
			}
		}
	}

	if c[0] == 0 {
		for color := 1; color <= m; color++ {
			dp[0][1][color] = int64(p[0][color])
		}
	} else {
		dp[0][1][c[0]] = 0
	}

	for i := 1; i < n; i++ {
		for k := 1; k <= K; k++ {

			if c[i] == 0 {
				// Если можно рисовать
				for color := 1; color <= m; color++ {
					for prev_color := 1; prev_color <= m; prev_color++ {
						if prev_color == color {
							dp[i][k][color] = min(dp[i - 1][k][prev_color] + int64(p[i][color]), dp[i][k][color])
						} else {
							dp[i][k][color] = min(dp[i - 1][k - 1][prev_color] + int64(p[i][color]), dp[i][k][color])
						}
					}
				}
			} else {
				// Если нельзя рисовать
				for prev_color := 1; prev_color <= m; prev_color++ {
					if prev_color == c[i] {
						dp[i][k][c[i]] = min(dp[i - 1][k][prev_color], dp[i][k][c[i]])
					} else {
						dp[i][k][c[i]] = min(dp[i - 1][k - 1][prev_color], dp[i][k][c[i]])
					}
				}
			}
		}
	}

	ans := int64(inf)
	for i := 1; i <= m; i++ {
		ans = min(ans, dp[n - 1][K][i])
	}

	if ans == inf {
		fmt.Println("-1")
		return
	}

	fmt.Println(ans)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF711C(_r io.Reader, out io.Writer) {
	min := func(a, b int64) int64 {
		if a < b {
			return a
		}
		return b
	}
	in := bufio.NewReader(_r)
	var n, m, tar int
	Fscan(in, &n, &m, &tar)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	cost := make([][]int64, n)
	for i := range cost {
		cost[i] = make([]int64, m)
		for j := range cost[i] {
			Fscan(in, &cost[i][j])
		}
	}

	const inf int64 = 1e18
	ans := inf
	dp := make([][][]int64, n)
	for i := range dp {
		dp[i] = make([][]int64, n+1)
		for j := range dp[i] {
			dp[i][j] = make([]int64, m)
			for k := range dp[i][j] {
				dp[i][j][k] = inf
			}
		}
	}
	if c := a[0]; c > 0 {
		dp[0][1][c-1] = 0
	} else {
		dp[0][1] = cost[0]
	}
	for i := 1; i < n; i++ {
		for b := 1; b <= n; b++ {
			for c, cst := range cost[i] {
				if a[i] > 0 {
					if c != a[i]-1 {
						continue
					}
					cst = 0
				}
				for pc := 0; pc < m; pc++ {
					bb := b
					if c != pc {
						bb--
					}
					dp[i][b][c] = min(dp[i][b][c], dp[i-1][bb][pc]+cst)
				}
			}
		}
	}
	for _, v := range dp[n-1][tar] {
		ans = min(ans, v)
	}
	if ans == inf {
		ans = -1
	}
	Fprint(out, ans)
}

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

package main

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

const (
	maxNM = 110
	INF   = int64(1 << 40)
)

var N, M, K int
var C []int
var P [][]int
var dp [maxNM][maxNM][maxNM]int64

func main() {
	fsc := NewFastScanner()
	N, M, K = fsc.NextInt(), fsc.NextInt(), fsc.NextInt()
	C = make([]int, N)
	for i := 0; i < N; i++ {
		C[i] = fsc.NextInt()
	}
	P = make([][]int, N)
	for i := 0; i < N; i++ {
		P[i] = make([]int, M)
	}
	for i := 0; i < N; i++ {
		for j := 0; j < M; j++ {
			P[i][j] = fsc.NextInt()
		}
	}
	for i := 0; i < maxNM; i++ {
		for j := 0; j < maxNM; j++ {
			for k := 0; k < maxNM; k++ {
				dp[i][j][k] = INF
			}
		}
	}
	if C[0] == 0 {
		dp[0][0][0] = 0
	} else {
		dp[0][C[0]][1] = 0
	}

	for i := 0; i < N; i++ { //pos
		for j := 0; j <= M; j++ { //color
			for k := 0; k <= K; k++ { //cnt
				if dp[i][j][k] == INF {
					continue
				}
				if C[i] != 0 { //colored
					if j == C[i] {
						dp[i+1][C[i]][k] = Min(dp[i+1][C[i]][k], dp[i][j][k])
					} else {
						dp[i+1][C[i]][k+1] = Min(dp[i+1][C[i]][k+1], dp[i][j][k])
					}
				} else { //uncolored

					for c := 0; c < M; c++ {
						if c+1 == j { //same color
							dp[i+1][c+1][k] = Min(dp[i+1][c+1][k], dp[i][j][k]+int64(P[i][c]))
						} else {
							dp[i+1][c+1][k+1] = Min(dp[i+1][c+1][k+1], dp[i][j][k]+int64(P[i][c]))
						}
					}
				}
			}
		}
	}
	var ans int64
	ans = INF
	for i := 1; i <= M; i++ {
		ans = Min(ans, dp[N][i][K])
	}
	if ans == INF {
		ans = -1
	}
	fmt.Println(ans)
}

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

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

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 2028)
	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) NextInt() int {
	val, err := strconv.Atoi(s.Next())
	if err != nil {
		panic(err)
	}
	return val
}
func (s *FastScanner) NextInt64() int64 {
	val, err := strconv.ParseInt(s.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return val
}
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, err := s.r.ReadLine()
		if err != nil {
			panic(err.Error())
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

// http://codeforces.com/contest/711/problem/C
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)

func main () {
	var n, m, K int

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input := bufio.NewReader(os.Stdin)

	fmt.Fscanln(input, &n, &m, &K)

	c := make([]int, n) // исходные цвета деревьев
	p := make([][]int, n)

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

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

	// Solve
	dp := make([][]struct{
		litres int64
		k int
	}, n)

	for i := 0; i < n; i++ {
		dp[i] = make([]struct{
			litres int64
			k int
		}, m + 1)

		if c[i] == 0 {
			// Если можно рисовать
			for color := 1; color <= m; color++ {

				if i == 0 {
					dp[i][color].k = 1
					dp[i][color].litres = int64(p[i][color])
					continue
				}

				for prev_color := 1; prev_color <= m; prev_color++ {
					if prev_color == color {
						if dp[i - 1][prev_color].k > 0 && (dp[i][color].k == 0 || dp[i][color].litres > dp[i - 1][prev_color].litres + int64(p[i][color])) {
							dp[i][color].litres = dp[i - 1][prev_color].litres + int64(p[i][color])
							dp[i][color].k = dp[i - 1][prev_color].k
						}
					} else {
						if dp[i - 1][prev_color].k > 0 && (dp[i][color].k == 0 || dp[i][color].litres > dp[i - 1][prev_color].litres + int64(p[i][color])) {
							if dp[i - 1][prev_color].k + 1 <= K {
								dp[i][color].litres = dp[i - 1][prev_color].litres + int64(p[i][color])
								dp[i][color].k = dp[i - 1][prev_color].k + 1
							}
						}
					}
				}
			}

		} else {
			// Если нельзя рисовать
			if i == 0 {
				dp[i][c[i]].k = 1
				dp[i][c[i]].litres = 0
				continue
			}

			for prev_color := 1; prev_color <= m; prev_color++ {
				if prev_color == c[i] {
					if dp[i - 1][prev_color].k > 0 && (dp[i][c[i]].k == 0 || dp[i][c[i]].litres > dp[i - 1][prev_color].litres) {
						dp[i][c[i]].litres = dp[i - 1][prev_color].litres
						dp[i][c[i]].k = dp[i - 1][prev_color].k
					}
				} else {
					if dp[i - 1][prev_color].k > 0 && (dp[i][c[i]].k == 0 || dp[i][c[i]].litres > dp[i - 1][prev_color].litres) {
						if dp[i - 1][prev_color].k + 1 <= K {
							dp[i][c[i]].litres = dp[i - 1][prev_color].litres
							dp[i][c[i]].k = dp[i - 1][prev_color].k + 1
						}
					}
				}
			}
		}

	}

	ans := dp[n - 1][1]
	ans.litres = math.MaxInt64
	for i := 1; i <= m; i++ {
		fmt.Println(dp[n - 1][i])
		if dp[n - 1][i].k == K && ans.litres > dp[n - 1][i].litres {
			ans = dp[n - 1][i]
		}
	}

	if ans.k != K {
		fmt.Println("-1")
		return
	}

	fmt.Println(ans.litres)
}

// http://codeforces.com/contest/711/problem/C
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)

func main () {
	var n, m, K int

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input := bufio.NewReader(os.Stdin)

	fmt.Fscanln(input, &n, &m, &K)

	c := make([]int, n) // исходные цвета деревьев
	p := make([][]int, n)

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

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

	// Solve
	dp := make([][]struct{
		litres int64
		k int
	}, n)

	for i := 0; i < n; i++ {
		dp[i] = make([]struct{
			litres int64
			k int
		}, m + 1)

		if c[i] == 0 {
			// Если можно рисовать
			for color := 1; color <= m; color++ {

				if i == 0 {
					dp[i][color].k = 1
					dp[i][color].litres = int64(p[i][color])
					continue
				}

				for prev_color := 1; prev_color <= m; prev_color++ {
					if prev_color == color {
						if dp[i - 1][prev_color].k > 0 && (dp[i][color].k == 0 || dp[i][color].litres > dp[i - 1][prev_color].litres + int64(p[i][color])) {
							dp[i][color].litres = dp[i - 1][prev_color].litres + int64(p[i][color])
							dp[i][color].k = dp[i - 1][prev_color].k
						}
					} else {
						if dp[i - 1][prev_color].k > 0 && (dp[i][color].k == 0 || dp[i][color].litres > dp[i - 1][prev_color].litres + int64(p[i][color])) {
							if dp[i - 1][prev_color].k + 1 <= K {
								dp[i][color].litres = dp[i - 1][prev_color].litres + int64(p[i][color])
								dp[i][color].k = dp[i - 1][prev_color].k + 1
							}
						}
					}
				}
			}

		} else {
			// Если нельзя рисовать
			if i == 0 {
				dp[i][c[i]].k = 1
				dp[i][c[i]].litres = 0
				continue
			}

			for prev_color := 1; prev_color <= m; prev_color++ {
				if prev_color == c[i] {
					if dp[i - 1][prev_color].k > 0 && (dp[i][c[i]].k == 0 || dp[i][c[i]].litres > dp[i - 1][prev_color].litres) {
						dp[i][c[i]].litres = dp[i - 1][prev_color].litres
						dp[i][c[i]].k = dp[i - 1][prev_color].k
					}
				} else {
					if dp[i - 1][prev_color].k > 0 && (dp[i][c[i]].k == 0 || dp[i][c[i]].litres > dp[i - 1][prev_color].litres) {
						if dp[i - 1][prev_color].k + 1 <= K {
							dp[i][c[i]].litres = dp[i - 1][prev_color].litres
							dp[i][c[i]].k = dp[i - 1][prev_color].k + 1
						}
					}
				}
			}
		}

	}

	ans := dp[n - 1][1]
	ans.litres = math.MaxInt64
	for i := 1; i <= m; i++ {
		if dp[n - 1][i].k == K && ans.litres > dp[n - 1][i].litres {
			ans = dp[n - 1][i]
		}
	}

	if ans.k != K {
		fmt.Println("-1")
		return
	}

	fmt.Println(ans.litres)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF711C(_r io.Reader, out io.Writer) {
	min := func(a, b int) int {
		if a < b {
			return a
		}
		return b
	}
	in := bufio.NewReader(_r)
	var n, m, tar int
	Fscan(in, &n, &m, &tar)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	cost := make([][]int, n)
	for i := range cost {
		cost[i] = make([]int, m)
		for j := range cost[i] {
			Fscan(in, &cost[i][j])
		}
	}

	const inf int = 1e9
	ans := inf
	dp := make([][][]int, n)
	for i := range dp {
		dp[i] = make([][]int, n+1)
		for j := range dp[i] {
			dp[i][j] = make([]int, m)
			for k := range dp[i][j] {
				dp[i][j][k] = inf
			}
		}
	}
	if c := a[0]; c > 0 {
		dp[0][1][c-1] = 0
	} else {
		dp[0][1] = cost[0]
	}
	for i := 1; i < n; i++ {
		for b := 1; b <= n; b++ {
			for c, cst := range cost[i] {
				if a[i] > 0 {
					if c != a[i]-1 {
						continue
					}
					cst = 0
				}
				for pc := 0; pc < m; pc++ {
					bb := b
					if c != pc {
						bb--
					}
					dp[i][b][c] = min(dp[i][b][c], dp[i-1][bb][pc]+cst)
				}
			}
		}
	}
	for _, v := range dp[n-1][tar] {
		ans = min(ans, v)
	}
	if ans == inf {
		ans = -1
	}
	Fprint(out, ans)
}

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