package main

import (
            "fmt"
            "bytes"
            "strconv"
        )

func Trim(x string, begin, end bool) string {
    var a, b int = 0, len(x) - 1

    if begin {
        for string(x[a]) == "0" && a < b && string(x[a + 1]) != "."{
            a++
        }
    }

    if end {
        for (string(x[b]) == "0" || string(x[b]) == ".") && b > a {
            b--
        }
    }

    return x[a:b + 1]
}

type ExponentialNumber struct {
    n string
    exp string
}

func (e ExponentialNumber) String() string {
    var result string
    var s string = e.n
    var length int = len(s)
    exp, _ := strconv.Atoi(e.exp)
    exp += 1

    var buffer bytes.Buffer

    var fs int = exp
    if fs >= length {
        fs = length

        buffer.WriteString(s)

        for i := 0; i < exp - length; i++ {
            buffer.WriteString("0")
        }

        result = Trim(buffer.String(), true, false)
    } else {
        buffer.WriteString(Trim(s[:fs], true, false))

        var p string = Trim(s[fs:], false, true)
        if p != "0" {
            buffer.WriteString(".")
            buffer.WriteString(p)
        }

        result = buffer.String()
    }

    return result
}

func main() {
    var input string
    fmt.Scanln(&input)
    var a_s string //= fmt.Sprint(a), fmt.Sprint(d)

    var buffer bytes.Buffer

    i := 0
    for i < len(input) {
        if string(input[i]) == "e" {
            break
        }

        if string(input[i]) != "." {
            buffer.WriteByte(input[i])
        }

        i++
    }

    a_s = buffer.String()

    e := ExponentialNumber{a_s, input[i + 1:]}

    fmt.Println(e)
}


package main

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

type IO struct {
	scanner *bufio.Scanner
	writer *bufio.Writer
}
func NewIO() IO {
	io := IO{scanner: bufio.NewScanner(os.Stdin),
		writer: bufio.NewWriter(os.Stdout)}
	io.scanner.Split(bufio.ScanWords)
	return io
}
func toInt(buf []byte) (n int) {
	sgn := false
	for _, v := range buf {
		if v == '-' {
			sgn = true
		} else {
			n = n*10 + int(v-'0')
		}
	}
	if sgn {
		n = -n
	}
	return
}
func (io *IO) NextInt() int {
	io.scanner.Scan()
	return toInt(io.scanner.Bytes())
}
func (io *IO) Write(data ...interface{}) {
	for _, el := range data {
		switch el.(type) {
			case int:
				io.writer.WriteString(strconv.Itoa(el.(int)))
			case string:
				io.writer.WriteString(el.(string))
			case rune:
				io.writer.WriteRune(el.(rune))
		}
	}
}
func (io *IO) Writeln(data ...interface{}) {
	io.Write(data...)
	io.writer.WriteRune('\n')
}
func (io *IO) Flush() {
	io.writer.Flush()
}

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

const N int = 100

func main() {
	io := NewIO()

	n := io.NextInt()
	var a [N](int)
	ans := 0
	for i:=0; i<n; i++ {
		a[i] = io.NextInt()
		if i>0 && a[i]!=1 && a[i-1]!=1 {
			goto Bad
		}
		if i>1 && a[i]==2 && a[i-1]==1 && a[i-2]==3 {
			ans--
		}
		if i>0 {
			if Max(a[i],a[i-1])==2 {
				ans += 3
			} else {
				ans += 4
			}
		}
	}

	io.Writeln("Finite")
	io.Writeln(ans)
	io.Flush()
	return

Bad:
	io.Writeln("Infinite")
	io.Flush()
	return
}


package main

import "fmt"

func main() {
    var a,b int
    fmt.Scan(&a,&b)
    ans := 0
    for a > 0 {
        if a >= b {
            ans += b
            a -= b
            a++
        } else {
            ans += a
            a = 0
        }
    }
    fmt.Println(ans)
}


package main

import (
    "fmt"
    )

func main() {
    var n, a, b int
    fmt.Scan(&n, &a, &b)
    fmt.Println(((a + b - 1) % n + n) % n + 1)
}


package main

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

func exp(x int64, a int64) int64 {
	const max int64 = 1000000009
	if x == 0 {
		return 1
	}
	var temp int64 = exp(x/2, (a*a)%max)
	if x%2 == 0 {
		return temp%max
	} else {
		return (temp*a)%max
	}
}

func main(){
	var n, m, k int64
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	n, _ = strconv.ParseInt(r.Text(), 0, 64)
	r.Scan()
	m, _ = strconv.ParseInt(r.Text(), 0, 64)
	r.Scan()
	k, _ = strconv.ParseInt(r.Text(), 0, 64)
	const max int64 = 1000000009
	var x int64 = (m-(n-m)*(k-1))/k
	if x < 0 {
		x = 0
	}
	var res int64 = exp(x, 2)
	var final int64 = (2*k*(res-1))%max+m-(k*x)%max
	final = final%max
	w.WriteString(strconv.FormatInt(final, 10)+"\n")
	w.Flush()
}


package main

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

var stdin *bufio.Reader
var stdout *bufio.Writer

func init() {
	stdin = bufio.NewReader(os.Stdin)
    stdout = bufio.NewWriter(os.Stdout)
}

func main() {

	n, m := 0, 0

	fmt.Fscanf(stdin, "%d%d", &n, &m)

	x := 2 * n

	if 3 * m > x {
		x = 3 * m
	}

	for {
		if x / 2 + x / 3 - x / 6 >= n + m {
			break
		}
		x++
	}

	fmt.Fprintf(stdout, "%d\n", x)

    stdout.Flush()
}


package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	t := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&t[i])
	}
	var AP bool = true
	commonDiff := t[1] - t[0]
	for i := 1; i < n; i++ {
		if t[i] - t[i-1] != commonDiff {
			AP = false
			break
		}
	}
	if AP {
		fmt.Println(t[n-1]+commonDiff)
	}
	if !AP {
		fmt.Println(t[n-1])
	}
}


package main

import (
	"fmt"
	"math"
)

func main() {
	var rows [5][5]int
	pi := 0
	pj := 0

	for i := 0; i < 5; i++ {
		for j:= 0; j < 5; j++ {
			_,_ = fmt.Scan(&rows[i][j])
			if rows[i][j] == 1 {
				pi = i
				pj = j
			}
		}
	}

	fmt.Println(int(math.Abs(float64(pi - 2)) + math.Abs(float64(pj - 2))))

}


package main

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

func check(rgb []int) bool {
	for i := 0; i < len(rgb); i++ {
		if rgb[i] > 0 {
			return false
		}
	}
	return true
}
func main() {
	fsc := NewFastScanner()
	rgb := make([]int, 3)

	for i := 0; i < len(rgb); i++ {
		rgb[i] = fsc.NextInt()
	}
	cnt := 0
	res := 0
	for !check(rgb) {
		res++
		rgb[cnt] -= 2
		cnt = (cnt + 1) % 3
	}
	fmt.Println(29 + res)
}

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

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

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

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

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

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

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

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

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

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


package main

import "fmt"

func main() {
	var n, d int
	var path string

	fmt.Scanf("%d %d\n", &n, &d)
	fmt.Scanf("%s", &path)

	dp := make([]int, n)
	dp[0] = 1

	for i := 0; i < n; i++ {
		if dp[i] > 0 {
			for j := 1; j <= d; j++ {
				if i+j < n && path[i+j] == '1' && (dp[i+j] == 0 || dp[i+j] > dp[i]+1) {
					dp[i+j] = dp[i] + 1
				}
			}
		}
	}

	fmt.Println(dp[n-1] - 1)
}


package main

import "fmt"

const mod = 1000000007

func main() {
  var n, k, d int
  fmt.Scanf("%d%d%d\n",&n,&k,&d)
  a := make([]int, n+1)
  b := make([]int, n+1)
  b[0] = 1
  for i := 1; i <= n; i++ {
    for j := 1; j <= k && j <= i; j++ {
      a[i] += a[i - j]
      if a[i] >= mod {
        a[i] -= mod
      }
    }
    for j := 1; j < d && j <= k && j <= i; j++ {
      b[i] += b[i - j]
      if b[i] >= mod {
        b[i] -= mod
      }
    }
    for j := d; j <= k && j <= i; j++ {
      a[i] += b[i - j]
      if a[i] >= mod {
        a[i] -= mod
      }
    }
  }
  fmt.Println(a[n] % mod)
}


package main

import (
	"fmt"
	"log"
	"math"
)

func check(err error) {
	if err != nil {
		log.Fatalln(err)
	}
}

func main()  {
	var n, k int
	_, err := fmt.Scan(&n, &k)
	check(err)

	aMap := make(map[int]int)
	var max int
	for i := 0; i < n; i++ {
		var a int
		_, err = fmt.Scan(&a)
		check(err)
		aMap[a]++
		if aMap[a] > max {
			max = aMap[a]
		}
	}

	nBludo := int(math.Ceil(float64(max)/float64(k)))
	nPribory := nBludo * k * len(aMap)

	fmt.Println(nPribory - n)
}


package main

import (
	"fmt"
)

func get_digits(n int) []bool {
	output := make([]bool, 10)
	for n > 0 {
		output[n%10] = true
		n = n/10
	}
	return output
}

func compatible(digits []bool, n int) bool {
	for n > 0 {
		if digits[n%10] {
			return true
		}
		n = n/10
	}
	return false
}

func main() {
	var input int
	fmt.Scan(&input)
	digits := get_digits(input)
	ans := 0
	for i:=1; i*i<=input; i++ {
		if input%i == 0 {
			if compatible(digits, i) {ans++}
			if i*i != input && compatible(digits, input/i) {ans++}
		}
	}
	fmt.Println(ans)
}


package main

import (
	"fmt"
	"strconv"
)

func main() {
	var a, b int64
	if _, err := fmt.Scanf("%d %d\n", &a, &b); err != nil {
		return
	}

	as, ac, ai := to_binary_string(a)
	bs, bc, bi := to_binary_string(b)

	var c [3]int

	if len(as) < len(bs) {
		if ac == 0 {
			c[0] = 0
		} else {
			c[0] = len(as) - ai
		}
		for i := len(as) + 1; i <= len(bs)-1; i++ {
			c[1] += i - 1
		}
		if bc == 0 {
			c[2] = len(bs) - 1
		} else {
			c[2] = bi - 1
			if bc == 1 {
				c[2] += 1
			}
		}
	} else if len(as) == len(bs) {
		c[1] = bi - ai
		if bc == 1 {
			c[2] = 1
		}
	}

	fmt.Println(c[0] + c[1] + c[2])
}

func to_binary_string(n int64) (string, int, int) {
	out := ""
	zero_count := 0
	first_zero_index := -1
	for i := 0; n > 0; i++ {
		if n%2 == 0 {
			zero_count++
			first_zero_index = i
		}
		out = strconv.FormatInt(n%2, 10) + out
		n /= 2
	}
	return out, zero_count, len(out) - first_zero_index - 1
}


package main
import (
	"fmt"
	//"bufio"
	//"os"
	//"strconv"
	//"sort"
)

func main() {
	var i,j,n int
	a:=make([]int,106)
	b:=make([]int,250000)
	fmt.Scan(&n)
	sum:=0
	flag:=true
	for i=1;i<=n;i++ {
		fmt.Scan(&a[i])
		sum+=a[i]
	}
	if sum%2!=0 {
		flag=false
	} else {
		sum/=2
		for i=1;i<=n;i++{
			for j=sum;j>=a[i];j-- {
				if (b[j-a[i]]+a[i])>b[j] {
					b[j]=b[j-a[i]]+a[i]
				}
			}
		}
		if b[sum]==sum {
			flag=true
		} else {
			flag=false
		}
	}
	if flag==true {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


//A. Махмуд, Эхаб и игра в четное-нечетное
package main

import (
	"fmt"
)

func main() {
	var n uint32

	fmt.Scan(&n)

	if n%2 == 0 {
		fmt.Println("Mahmoud")
	} else {
		fmt.Println("Ehab")
	}

}


package main

import (
	"bufio"
	"fmt"
	"os"
)
func gcd(x, y int)int{
	for y>0{
		temp:=y
		y = x%y
		x = temp
	}
	return x
}
func max(x,y int)int{
	if x>y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var n int
	fmt.Fscan(in,&n)
	var a [105]int
	sum:=0
	for i:=1;i<=n;i++{
		fmt.Fscan(in,&a[i])
		sum+=a[i]
	}
	f:=[105][100*2001]int{}
	f[0][0]=1
	for i:=1;i<=n;i++{
		for j:=1;j<=100*2000;j++{
			f[i][j] = max(f[i][j],f[i-1][j])
			if j-a[i]>=0{
				f[i][j]=max(f[i][j],f[i-1][j-a[i]])
			}
		}
	}
	if sum%2==0{
		flag:=false
		for i:=1;i<=n;i++{
			if f[i][sum/2]==1{
				flag=true
			}
		}
		if !flag{
			fmt.Fprintln(out,0)
		}else{
			odd := false
			for i:=1;i<=n;i++{
				if a[i]%2==1{
					odd = true
					fmt.Fprintln(out,1)
					fmt.Fprintln(out,i)
					break
				}
			}
			if odd == false{
				for {
					done := false
					index := -1
					gcdx := a[1]
					for i := 2; i <= n; i++ {
						gcdx = gcd(gcdx, a[i])
					}
					for i := 1; i <= n; i++ {
						a[i] = a[i] / gcdx
						if a[i]%2 == 1 {
							done = true
							index = i
						}
					}
					if done {
						fmt.Fprintln(out, 1)
						fmt.Fprintln(out, index)
						break
					}
				}
			}
		}
	}else {
		fmt.Fprintln(out, 0)
	}
}


package main

import "fmt"

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

	// posición en su grupo de cifras
	pos := 0
	for i := 0; i < len(s); i++ {
		pos *= 2
		if s[i] == '7' {
			pos++
		}
	}

	// sumamos los de menos cifras
	less := 0
	for i := 1; i < len(s); i++ {
		less |= (1 << uint(i))
	}
	fmt.Printf("%d\n", (1 + pos + less))
}


package main

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

func main() {
    in := bufio.NewReader(os.Stdin)
    out := bufio.NewWriter(os.Stdout)
    defer out.Flush()
    tot := 0
    fmt.Fscan(in, &tot)
    times := (tot/3)*2
    if tot % 3 > 0 {times++}
    fmt.Fprint(out, times)
}


package main

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

func main() {
	a, b, c, d := ScanInt64(), ScanInt64(), ScanInt64(), ScanInt64()
	P(solve(a, b, c, d))

	out.Flush()
}

func solve(a, b, c, d int64) int64 {
	sum := int64(0)
	p := make([]int64, Mx64(b+c+2, d+2))
	for i := a; i <= b; i++ {
		p[i+b] += 1
		p[i+c+1] += -1
	}
	for i := 1; i < len(p); i++ {
		p[i] += p[i-1]
	}

	for i := Mx64(b+c+1, d+1); i >= a; i-- {
		p[i-1] += p[i]
	}

	for i := c; i <= d; i++ {
		sum += int64(p[i+1])
	}
	return sum
}

/*********************** I/O ***********************/
var in *bufio.Scanner
var out *bufio.Writer

func init() {
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)
	out = bufio.NewWriter(os.Stdout)
}

func P(args ...interface{}) {
	print("\n", args...)
}

func PS(args ...interface{}) {
	print(" ", args...)
	print("\n", nil)
}

func print(seperator string, args ...interface{}) {
	for _, arg := range args {
		str := ""
		switch v := arg.(type) {
		case byte:
			str = string(v)
		case rune:
			str = string(v)
		case int:
			str = strconv.Itoa(v)
		case []int:
			sb := strings.Builder{}
			for i := 0; i < len(v); i++ {
				sb.WriteString(strconv.Itoa(v[i]) + " ")
			}
			str = sb.String()
		case int64:
			str = strconv.FormatInt(v, 10)
		case []int64:
			sb := strings.Builder{}
			for i := 0; i < len(v); i++ {
				sb.WriteString(strconv.FormatInt(v[i], 10) + " ")
			}
			str = sb.String()
		case string:
			str = v
		}
		out.WriteString(str + seperator)
	}
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanWords(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanInt() int { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = ScanInt()
	}
	return a
}
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanInt64s(n int) []int64 {
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		a[i] = ScanInt64()
	}
	return a
}

/*********************** Utils int64 ***********************/
func MnMx64(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn64(args ...int64) int64 { mn, _ := MnMx64(args...); return mn }
func Mx64(args ...int64) int64 { _, mx := MnMx64(args...); return mx }
func LCM64(a, b int64) int64   { return a / GCD64(a, b) * b }
func GCD64(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD64(b%a, a)
}
func SortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func Abs64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

/*********************** Utils int ***********************/
func MnMx(args ...int) (int, int) {
	minVal, maxVal := math.MaxInt32, math.MinInt32
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int) int { mn, _ := MnMx(args...); return mn }
func Mx(args ...int) int { _, mx := MnMx(args...); return mx }
func LCM(a, b int) int   { return a / GCD(a, b) * b }
func GCD(a, b int) int {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}


package main

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

func solve() {
    s, cur, was := readString(), []int{}, make(map[rune]bool)
    for _, ch := range s {
        if !was[ch] {
            cur = append(cur, int(ch))
            was[ch] = true
        }
    }

    var d [5][16]int
    for t := 0; t < 13*2; t++ {
        for j := 0; j < 13; j++ {
            d[1][j+1] = cur[j]
            d[2][13-j] = cur[j+13]
        }

        curI, curJ, found := t/13 + 2, t%13 + 2, true
        for _, ch := range s {
            ok := false
            for _, di := range []int{-1, 0, 1} {
                for _, dj := range []int{-1, 0, 1} {
                    posI, posJ := curI+di, curJ+dj
                    if !ok && (di != 0 || dj != 0) && int(ch) == d[posI][posJ] {
                        curI, curJ, ok = posI, posJ, true
                    }
                }
            }
            if !ok {
                found = false
            }
        }

        if found {
            for i := 0; i < 2; i++ {
                for j := 0; j < 13; j++ {
                    fmt.Print(string(d[i+1][j+1]))
                }
                fmt.Println()
            }

            return
        }
        cur = append(cur[len(cur)-1:], cur[:len(cur)-1]...)
    }

    fmt.Println("Impossible")
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

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

// Math
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

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

func min(x, y int) int {
	return x + y - max(x, y)
}

// IO

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

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

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

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


package main

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

func readInt(reader *bufio.Scanner) int {
	var result int
	reader.Scan()
	result, _ = strconv.Atoi(reader.Text())
	return result
}

func main() {
	reader := bufio.NewScanner(os.Stdin)
	buf := make([]byte, 2)
	reader.Buffer(buf, 501)
	reader.Split(bufio.ScanWords)
	x := readInt(reader)
	y := readInt(reader)
	z := readInt(reader)
	if z == 0 {
		if x > y {
			fmt.Println("+")
		} else if x < y {
			fmt.Println("-")
		} else {
			fmt.Println("0")
		}
	} else if x > y+z {
		fmt.Println("+")
	} else if y > x+z {
		fmt.Println("-")
	}else{
		fmt.Println("?")
	}
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1558B(in io.Reader, out io.Writer) {
	var n, m int
	Fscan(in, &n, &m)
	f := make([]int, n+2)
	f[n] = 1
	for i := n - 1; i > 0; i-- {
		f[i] = f[i+1] * 2 % m
		for j := 2; j*i <= n; j++ {
			f[i] = (f[i] + (f[i*j]-f[min((i+1)*j, n+1)]+m)%m) % m
		}
	}
	Fprint(out, (f[1]-f[2]+m)%m)
}

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

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


package main

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

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

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

func (io *IO) ReadInt64() int64 {
	var res int64
	fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

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

func (io *IO) ReadPairInt64() (int64, int64) {
	var a, b int64
	fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

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

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

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

type log struct {
	s string
	i int
}

var errOutOfRange = errors.New("out of range")

func (l *log) left() (bool, error) {
	if l.i >= len(l.s) {
		return false, errOutOfRange
	}
	c := l.s[l.i]
	l.i++
	return c == '0', nil
}

func mergeSort(a []int, l *log) error {
	if len(a) == 1 {
		return nil
	}

	err := mergeSort(a[:len(a)/2], l)
	if err != nil {
		return err
	}

	err = mergeSort(a[len(a)/2:], l)
	if err != nil {
		return err
	}

	b := make([]int, 0, len(a))
	i, j := 0, len(a)/2

	for i < len(a)/2 && j < len(a) {
		left, err := l.left()
		if err != nil {
			return err
		}

		if left {
			b = append(b, a[i])
			i++
		} else {
			b = append(b, a[j])
			j++
		}
	}

	for i < len(a)/2 {
		b = append(b, a[i])
		i++
	}

	for j < len(a) {
		b = append(b, a[j])
		j++
	}

	for i := range b {
		a[i] = b[i]
	}
	return nil
}

func doSomething(n int, s string) int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = i
	}

	l := log{s, 0}
	err := mergeSort(a, &l)
	if err != nil {
		return 1000000000
	}

	return len(l.s) - l.i
}

func doSomethingWithPrint(n int, s string) int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = i
	}

	l := log{s, 0}
	err := mergeSort(a, &l)
	if err != nil {
		return 1000000000
	}

	if _, err = l.left(); err != nil {
		b := make([]int, len(a))

		for i, v := range a {
			b[v] = i + 1
		}

		fmt.Println(len(a))
		for _, v := range b {
			fmt.Printf("%d ", v)
		}
	}

	return len(l.s) - l.i
}

func main() {
	io := NewIO(os.Stdin, os.Stdout)
	s := io.ReadString()

	l, r := 1, 200000

	for r - l > 1 {
		x1 := l + (r - l) / 3
		x2 := l + (r - l) / 3 * 2

		v1 := doSomething(x1, s)
		v2 := doSomething(x2, s)

		if v1 < v2 {
			l = x1
		} else {
			r = x2
		}
	}

	doSomethingWithPrint(l, s)
}


package main

import "fmt"

func main() {
	var x, y int
	fmt.Scan(&x, &y)
	ans := int(1e9)
	if y <= 0 && y <= x && x <= 1-y && -4*y < ans {ans = -4*y}
	if x > 0 && 1-x <= y && y <= x && 4*x-3 < ans {ans = 4*x-3}
	if y > 0 && -y <= x && x <= y && 4*y-2 < ans {ans = 4*y-2}
	if x < 0 && x <= y && y <= -x && -4*x-1 < ans {ans = -4*x-1}
	fmt.Println(ans)
}


package main

import (
    "fmt"
    )

func calc(a, b uint64) uint64 {
    if a == 0 || b == 0 {
        return 0
    }

    if a < b {
        tmp := a
        a = b
        b = tmp
    }

    return a/b + calc(a%b, b)
}

func main() {
    var a, b uint64
    fmt.Scan(&a, &b)
    fmt.Println(calc(a, b))
}


package main

import "fmt"

func main (){
	var n, x int
	var op int
	fmt.Scanf("%d %d\n", &n, &x)
	var f [101]int
	for i := 0; i < n; i++ {
		var here int
		fmt.Scanf("%d", &here)
		f[here] = 1
	}
	if f[x] == 1 {
		f[x] = 0
		op++
	}
	for i := 0; i < x; i++ {
		if f[i] == 0 {
			f[i] = 1
			op++
		}
	}
	fmt.Println(op)
}


/*
URL:
https://codeforces.com/problemset/problem/735/D
*/

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

func main() {
	n = ReadInt64()

	if IsPrime(n) {
		fmt.Println(1)
		return
	}

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

	if IsPrime(n - 2) {
		fmt.Println(2)
		return
	}

	fmt.Println(3)
}

// func main() {
// 	n = readInt64()

// 	// ans := 0
// 	A := []int64{}
// 	for {
// 		// ans++
// 		if IsPrime(n) {
// 			A = append(A, n)
// 			break
// 		}

// 		p := sub(n - 2)
// 		n -= p
// 		A = append(A, p)
// 	}
// 	// fmt.Println(ans)
// 	fmt.Println(len(A))
// }

// n以下の最大の素数を返す
func sub(n int64) int64 {
	for i := n; i >= 2; i-- {
		if IsPrime(i) {
			return i
		}
	}
	return 1
}

// IsPrime judges whether an argument integer is a prime number or not.
func IsPrime(n int64) bool {
	var i int64

	if n == 1 {
		return false
	}

	for i = 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}

	return true
}

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

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

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

	var n1, n2, k1, k2 int
	Fscan(in, &n1, &n2, &k1, &k2)

	const mod = 1e8
	cache := map[string]int{}
	var f func(left1, left2, c1, c2 int) int
	f = func(left1, left2, c1, c2 int) (sum int) {
		if left1 == 0 {
			if left2+c2 <= k2 {
				return 1
			}
			return 0
		}
		if left2 == 0 {
			if left1+c1 <= k1 {
				return 1
			}
			return 0
		}
		hash := Sprintf("%d;%d;%d;%d", left1, left2, c1, c2)
		if val, ok := cache[hash]; ok {
			return val
		}
		if c1 < k1 {
			sum += f(left1-1, left2, c1+1, 0)
		}
		if c2 < k2 {
			sum += f(left1, left2-1, 0, c2+1)
		}
		sum %= mod
		cache[hash] = sum
		return
	}
	Fprintln(out, f(n1, n2, 0, 0))
}

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


package main

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

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

	N, H := readTwoNums(reader)

	fmt.Println(solve(N, H))
}

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

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

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

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

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

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

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

	return i
}

func solve(N, H int) uint64 {
	dp := make([][]uint64, N+1)

	for i := 0; i <= N; i++ {
		dp[i] = make([]uint64, N+1)
	}
	//
	for h := 0; h <= N; h++ {
		dp[0][h] = 1
	}

	for i := 1; i <= N; i++ {
		for j := 1; j <= N; j++ {
			for k := 0; k < i; k++ {
				dp[i][j] += dp[k][j-1] * dp[i-k-1][j-1]
			}
		}
	}

	res := dp[N][N] - dp[N][H-1]

	return res
}


package main

import (
	"fmt"
	"strconv"
)

//a,b <=n  && a+b==x
func count(n, x int64) (ans int64) {
	if n >= x {
		n = x - 1
	}
	ans = n - x/2
	if x%2 == 0 {
		ans++
	}
	if ans < 0 {
		ans = 0
	}
	return
}

func main() {
	var n int64
	fmt.Scan(&n)
	if n < 5 {
		fmt.Println(n * (n - 1) / 2)
		return
	}
	var ans int64
	var max9 int64 = 9
	for max9 < n {
		max9 = max9*10 + 9
	}
	if max9/2+1 <= n {
		fmt.Println(count(n, max9))
		return
	}
	smax9 := fmt.Sprint(max9)
	//for i := 0; i < len(smax9); i++ {
	tmp := []byte(smax9)
	for j := 0; j < 9; j++ {
		tmp[0] = byte(j) + '0'
		x, _ := strconv.ParseInt(string(tmp), 10, 64)
		ans += count(n, x)
		//fmt.Println(count(n, x), x)
		tmp[0] = '9'
	}
	//}
	fmt.Println(ans)
}


package main

import "fmt"

func Max( x, y int ) int { // math.Max() は問題を起こすらしい。。。
  if x > y {
    return x
  }
  return y
}

func main() {
	var N, K int
	fmt.Scan( &N, &K )
	var S string
	fmt.Scan( &S )
	ypfx := make( []int, N + 1, N + 1 ); // type, length, capacity
	npfx := make( []int, N + 1, N + 1 );
	qpfx := make( []int, N + 1, N + 1 );
	for i := 0; i < N; i++ { // seems like go does not support ++i.....
	  ypfx[ i + 1 ] = ypfx[ i ];
	  npfx[ i + 1 ] = npfx[ i ];
	  qpfx[ i + 1 ] = qpfx[ i ];
	  if( S[ i ] == 'Y' ) {
	    ypfx[ i + 1 ]++;
	  } else if( S[ i ] == 'N' ) {
	    npfx[ i + 1 ]++;
	  } else {
	    qpfx[ i + 1 ]++;
	  }
	}
	original_max := 0;
	for i := 0; i < N; i++ {
	  if( S[ i ] != 'N' ) { // syntax error: missing { after if clause えええええ
	    continue;
	  }
	  j := i;
	  for j < N && S[ j ] == 'N' { // while() はだめなんかい！！
	    j++;
	  }
	  original_max = Max( original_max, j - i );
	  i = j;
	}
	if( original_max > K ) {
	  fmt.Println( "NO" );
	  return;
	}
	for i := 0; i + K <= N; i++ { // i を左界とする長さ K の区間を調べる
	  if( ypfx[ i + K ] - ypfx[ i ] > 0 ) { // ええええ -> line: 34
	    continue;
	  }
	  if( i - 1 >= 0 && S[ i - 1 ] == 'N' ) {
	    continue;
	  }
	  if( i + K < N && S[ i + K ] == 'N' ) {
	    continue;
	  }
	  fmt.Println( "YES" );
	  return;
	}
	fmt.Println( "NO" );
}


package main

import (
	"fmt"
	"strings"
)

func main() {
	var istring string
	fmt.Scan(&istring)
	temp := strings.Split(istring,"")
	answer := "NO"
	for i:=0;i<len(temp)-6; i++ {
		t := temp[i]
		if temp[i+1] == t && temp[i+2] == t && temp[i+3] == t && temp[i+4] == t && temp[i+5] == t && temp[i+6] == t {
			answer = "YES"
			break
		}
	}
	fmt.Println(answer)
}


package main

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

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	fr := func() string {
		var k, l string = readStr(), readStr()
		l = string(l[1]) + string(l[0])
		var s string = k + l
		var r string
		for _, v := range s {
			if string(v) != "X" {
				r += string(v)
			}
		}
		return r
	}
	fk := func(s string) string {
		for string(s[0]) != "A" {
			s = string(s[1:]) + string(s[0])
			// fmt.Println("..", s)
		}
		return s
	}
	var a, b string = fk(fr()), fk(fr())
	// fmt.Println("a", a)
	// fmt.Println("b", b)
	if a == b {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

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

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

func readInt64() int64 {
	sc.Scan()
	ans, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return ans
}

func printInts(ints ...int) {
	for _, v := range ints {
		wr.WriteString(strconv.Itoa(v))
		wr.WriteByte(' ')
	}
}
func printInt64s(ints ...int64) {
	for _, v := range ints {
		wr.WriteString(strconv.FormatInt(v, 10))
		wr.WriteByte(' ')
	}
}

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

func println() {
	wr.WriteByte('\n')
}


package main

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

// https://codeforces.com/problemset/problem/1030/A
// A. In Search of an Easy Problem
// time limit per test
// 1 second
// memory limit per test
// 256 megabytes
// input
// standard input
// output
// standard output

// When preparing a tournament, Codeforces coordinators try treir best to make the first problem as easy as possible. This time the coordinator had chosen some problem and asked n

// people about their opinions. Each person answered whether this problem is easy or hard.

// If at least one of these n

// people has answered that the problem is hard, the coordinator decides to change the problem. For the given responses, check if the problem is easy enough.
// Input

// The first line contains a single integer n
// (1≤n≤100

// ) — the number of people who were asked to give their opinions.

// The second line contains n
// integers, each integer is either 0 or 1. If i-th integer is 0, then i-th person thinks that the problem is easy; if it is 1, then i

// -th person thinks that the problem is hard.
// Output

// Print one word: "EASY" if the problem is easy according to all responses, or "HARD" if there is at least one person who thinks the problem is hard.

// You may print every letter in any register: "EASY", "easy", "EaSY" and "eAsY" all will be processed correctly.

func main() {
	solveTheProblem()
}

func solveTheProblem() {
	bufStdin := bufio.NewReader(os.Stdin)

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

	for i := 0; i < n; i++ {
		var vi int
		fmt.Fscan(bufStdin, &vi)
		if vi == 1 {
			fmt.Print("HARD")
			return
		}
	}

	fmt.Print("EASY")
}


package main

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

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

func main() {
	ini()
	defer writer.Flush()

	n := scanString()
	k := scanInt()

	cntZeros := strings.Count(n, "0")

	if cntZeros < k {
		writer.WriteString(strconv.Itoa(len(n)-1))
		return
	}

	result := 0
	cnt:= 0
	for i:=len(n)-1; i>=0; i-- {
		if n[i] == '0' {
			cnt++
		} else {
			result++
		}

		if cnt == k {
			break
		}
	}
	writer.WriteString(strconv.Itoa(result))

	return

}

func ini() {
	scanner = bufio.NewScanner(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
	scanner.Split(bufio.ScanWords)
}

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

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


package main

import (
	"bytes"
	"fmt"
	"io"
	"io/ioutil"
	"os"
)

func main() {
	var p, y int
	r := RapidReader()
	fmt.Fscan(r, &p, &y)
	for i := y; i >= 2 && i >= y-1000; i-- {
		if i <= p {
			continue
		}
		undivisible := true
		for k := 2; k <= p && k < 31623; k++ {
			if i%k == 0 {
				undivisible = false
				break
			}
		}
		if undivisible {
			fmt.Println(i)
			return
		}
	}
	fmt.Println(-1)
}

func RapidReader() io.Reader {
	b, _ := ioutil.ReadAll(os.Stdin)
	return bytes.NewReader(b)
}


package main

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

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

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

func main() {
  defer writer.Flush()
  var d int
  scanf("%d\n", &d)
  arr := make([]int, d)
  for i := range arr {
    scanf("%d", &arr[i])
  }
  solve(arr)
}

func solve(arr []int) {
  for D := 0; D <= 105; D++ {
    target := []int{arr[0], arr[0] + D, arr[0] - D}
    for _, t := range target {
      ok := true
      for i := range arr {
        diff := t - arr[i]
        if !(diff == 0 || diff == D || diff == -D) {
          ok = false
          break
        }
      }
      if ok {
        printf("%d", D)
        return
      }
    }
  }
  printf("%d", -1)
}


// GoIntoGo project main.go
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	for i := 16; i > -1; i-- {
		if ((n >> uint(i)) & 1) > 0 {
			fmt.Printf("%d ", i+1)
		}
	}
	fmt.Println("")
}


package main

// https://codeforces.com/problemset/problem/148/A

import "fmt"

func taskSolution(a [4]int, n int) int {
	ans := 0
	for number := 1; number <= n; number += 1 {
		if number%a[0] == 0 || number%a[1] == 0 || number%a[2] == 0 || number%a[3] == 0 {
			ans += 1
		}
	}
	return ans
}

func main() {
	var a [4]int
	for i := 0; i < 4; i += 1 {
		if _, err := fmt.Scan(&a[i]); err != nil {
			panic(err)
		}
	}

	var n int
	if _, err := fmt.Scan(&n); err != nil {
		panic(err)
	}

	fmt.Println(taskSolution(a, n))
}


package main

import (
    "fmt"
)

func main() {
    var scale, remainWeights string
    fmt.Scan(&scale, &remainWeights)

    text := scale + "\n" + remainWeights

    l := make([]rune, 0)
    r := make([]rune, 0)
    p := make([]rune, 0)
    flag := 1
    for _, v := range text {
        if v == '\n' || v == '|' {
            flag++
            continue
        }
        switch flag {
        case 1:
            l = append(l, v)
        case 2:
            r = append(r, v)
        case 3:
            p = append(p, v)
        }
    }

    // sz := (tlen - 2) / 2
    // c := sz - len(l)
    // if c >= 0 && c < len(p) {
    //  l = append(l, p[:c]...)
    //  r = append(r, p[c:]...)
    // }

    for _, v := range p {
        if len(l) < len(r) {
            l = append(l, v)
        } else {
            r = append(r, v)
        }
    }

    if len(l) != len(r) {
        fmt.Println("Impossible")
    } else {
        l = append(l, '|')
        l = append(l, r...)

        fmt.Println(string(l))
    }
}


package main

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

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

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

    var L, A, F int
    fmt.Fscanf(in, "%d\n%d\n%d\n", &L, &A, &F)
    mul := min(L, min(A / 2, F / 4))
    fmt.Println(mul * 7)
}


package main

import "fmt"

func main() {
	var n, t int
	fmt.Scan(&n)
	for ; n > 0; n-- {
		fmt.Scan(&t)
		fmt.Println(t/7 + 1)
	}
}


package main

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

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

func ReadInt32() int {
    scanner.Scan()
    ans, _ := strconv.Atoi(scanner.Text())
    return ans
}

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

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

func main() {
    defer writer.Flush()
    scanner.Split(bufio.ScanWords)
    a := ReadInt32()
    m := ReadInt32()
    f := false
    d := make(map[int]bool)

    for {
        q := a % m
        if q == 0 {
            f = true
            break
        } else if _, r := d[q]; r {
            f = false
            break
        } else {
            d[q] = true
            a += q
        }
    }

    if f {
        writer.WriteString("Yes\n")
    } else {
        writer.WriteString("No\n")
    }
}


package main

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

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

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	_ = n
	hamsters := next()

	countx, countX := 0, 0

	for i := range hamsters {
		if hamsters[i] == 'x' {
			countx++
		} else {
			countX++
		}
	}

	result := []uint8(hamsters)
	minutes := 0

	switch {
	case countx > countX:
		t := countx - countX
		t /= 2
		minutes = t
		for i:=0; t>0; i++ {
			if result[i] == 'x' {
				result[i] = 'X'
				t--
			}
		}
	case countx < countX:
		t := countX - countx
		t /= 2
		minutes = t
		for i:=0; t>0; i++ {
			if result[i] == 'X' {
				result[i] = 'x'
				t--
			}
		}
	}

	println(minutes)
	println(string(result))
}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return n
}

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	return n
}

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

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

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


package main

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

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

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

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

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

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

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

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

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

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

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

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

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

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

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

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}

func main() {
	defer Flush()

	n := readi()
	s := readb()

	var t []byte
	t = append(t, s[0])
	for i := 1; i < n; i++ {
		j := len(t) - 1
		if t[j] != 'D' && s[i] != t[j] {
			t[j] = 'D'
		} else {
			t = append(t, s[i])
		}
	}
	println(len(t))
}


package main

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

func main() {
	var n, l, r, x int
	if _, err := fmt.Scanf("%d %d %d %d\n", &n, &l, &r, &x); err != nil {
		return
	}

	c := make([]int, n)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; i < n && scanner.Scan(); i++ {
		_c, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}
		c[i] = _c
	}

	ways := 0

	mask := (1 << uint(n)) - 1
	for mask > 0 {
		m := mask

		cnt := 0
		sum := 0
		max := -1
		min := -1
		for i := 0; i < n; i++ {
			v := m % 2
			if v == 1 {
				cnt++
				sum += c[i]
				if c[i] > max {
					max = c[i]
				}
				if c[i] < min || min < 0 {
					min = c[i]
				}
			}
			m /= 2
		}
		if cnt >= 2 && sum >= l && sum <= r && max-min >= x {
			ways++
		}

		mask -= 1
	}

	fmt.Println(ways)
}


package main

import "fmt"

func power(exp int64) int64 {
	if exp == 0 {
		return 1
	}
	if exp == 1 {
		return 2
	}
	var result int64 = 1
	if exp%2 == 1 {
		result = 2
	}
	p := power(exp / 2)
	result = (result * p * p) % 1000000007
	return result
}

func main() {
	var k int
	fmt.Scan(&k)
	answer := (6 * power((1<<(k+1))-4)) % 1000000007
	fmt.Println(answer)
}


package main

import (
	"fmt"
	"math"
	"strconv"
)

func Sum(num int64) int64 {
	var sum int64
	sum = 0
	for num > 0 {
		sum += num % 10
		num /= 10
	}

	return sum
}

func main() {
	var n int64

	fmt.Scanln(&n)

	str := strconv.FormatInt(n/2, 10)
	digits := len(str)
	pow10 := int64(math.Pow10(digits - 1))
	a := int64(str[0]-48) * pow10
	if digits > 1 {
		a += pow10 - 1
	}

	fmt.Println(Sum(a) + Sum(n-a))
}


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 getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

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

  s := getS()
  chars := []byte{ s[0] }
  for i := 1; i < len(s); i++ {
    if s[i] != '/' || s[i-1] != '/' {
      chars = append(chars, s[i])
    }
  }
  if len(chars) > 1 && chars[len(chars)-1] == '/' {
    chars = chars[:len(chars)-1]
  }
  writer.WriteString(fmt.Sprintf("%s\n", string(chars)))
}


package main

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

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

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

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

func consec(arr []int) int {

	ans := 0

	for i := 0; i < len(arr); i++ {
		cur := 1
		last := arr[i]
		for j := i + 1; j < len(arr); j++ {
			if arr[j] == last+1 {
				last = last + 1
				cur++
			} else {
				ans = max(ans, cur)
				break
			}
		}
		ans = max(ans, cur)
	}
	return ans
}

func same(arr []int) int {

	ans := 0

	for i := 0; i < len(arr); i++ {
		cur := 1
		last := arr[i]
		for j := i + 1; j < len(arr); j++ {
			if arr[j] == last {
				cur++
			} else {
				ans = max(ans, cur)
				break
			}
		}
		ans = max(ans, cur)
	}
	return ans
}

func main() {
	defer writer.Flush()
	var a, b, c string

	s := []int{}
	m := []int{}
	p := []int{}

	scanf("%s %s %s\n", &a, &b, &c)

	if a[1] == byte('s') {
		cur := int(a[0] - byte('0'))
		s = append(s, cur)
	}
	if a[1] == byte('m') {
		cur := int(a[0] - byte('0'))
		m = append(m, cur)
	}
	if a[1] == byte('p') {
		cur := int(a[0] - byte('0'))
		p = append(p, cur)
	}

	if b[1] == byte('s') {
		cur := int(b[0] - byte('0'))
		s = append(s, cur)
	}
	if b[1] == byte('m') {
		cur := int(b[0] - byte('0'))
		m = append(m, cur)
	}
	if b[1] == byte('p') {
		cur := int(b[0] - byte('0'))
		p = append(p, cur)
	}

	if c[1] == byte('s') {
		cur := int(c[0] - byte('0'))
		s = append(s, cur)
	}
	if c[1] == byte('m') {
		cur := int(c[0] - byte('0'))
		m = append(m, cur)
	}
	if c[1] == byte('p') {
		cur := int(c[0] - byte('0'))
		p = append(p, cur)
	}

	sort.Ints(s)
	sort.Ints(p)
	sort.Ints(m)

	// fmt.Println(s, p, m)

	// fmt.Println(consec(p))

	if same(s) == 3 || consec(s) == 3 || same(p) == 3 || consec(p) == 3 || same(m) == 3 || consec(m) == 3 {
		printf("0")
		return
	}

	if same(s) == 2 || consec(s) == 2 || same(p) == 2 || consec(p) == 2 || same(m) == 2 || consec(m) == 2 {
		printf("1")
		return
	}

	if len(s) == 2 {
		s = []int{s[0], s[0] + 1, s[1]}
	} else if len(s) == 3 {
		s = []int{s[0], s[0] + 1, s[1], s[1] + 1, s[2]}
	}
	if len(m) == 2 {
		m = []int{m[0], m[0] + 1, m[1]}
	} else if len(m) == 3 {
		m = []int{m[0], m[0] + 1, m[1], m[1] + 1, m[2]}
	}
	if len(p) == 2 {
		p = []int{p[0], p[0] + 1, p[1]}
	} else if len(p) == 3 {
		p = []int{p[0], p[0] + 1, p[1], p[1] + 1, p[2]}
	}

	if same(s) >= 3 || consec(s) >= 3 || same(p) >= 3 || consec(p) >= 3 || same(m) >= 3 || consec(m) >= 3 {
		printf("1")
		return
	}

	printf("2")

}


package main

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

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)

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

func Count(left, right int, a []int) (cnt int) {
  for i, val := range a {
    if left <= i && i <= right {
      cnt += 1 - val
    } else {
      cnt += val
    }
  }
  return
}

func main() {
  sc.Split(bufio.ScanWords)
  n := nextInt()
  var a = make([]int, n)
  for i := range a {
    a[i] = nextInt()
  }
  best := 0
  for i := 0; i < n; i++ {
    for j := i; j < n; j++ {
      cnt := Count(i,j,a)
      if best < cnt {
        best = cnt
      }
    }
  }
  fmt.Println(best)
}


package main

import (
	"fmt"
	"math"
)

// 378 task
func CalculateChansesToWin() {
	var first_player_num int
	fmt.Scan(&first_player_num)

	var second_player_num int
	fmt.Scan(&second_player_num)

	var (
		first  int
		draw   int
		second int
	)

	for i := 1; i < 7; i++ {
		if math.Abs(float64(second_player_num-i)) > math.Abs(float64(first_player_num-i)) {
			first += 1
		} else if math.Abs(float64(second_player_num-i)) == math.Abs(float64(first_player_num-i)) {
			draw += 1
		} else {
			second += 1
		}
	}

	fmt.Println(first, draw, second)
}

func main() {
	CalculateChansesToWin()
}


package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	a := int64(0)
	fmt.Fscanf(in, "%d\n", &a)
	i := int64(2)
	for i = 2; i*i <= a; i++ {
		if a%int64(i) == 0 {
			fmt.Fprintf(out, "%d\n", (a-int64(i))/2+1)
			return
		}
	}
	fmt.Fprintf(out, "%d\n", 1)
	return
}


package main

import (
	"fmt"
	"sort"
)

const mod = 998244353
const N = 5001

var factor = [N][]int{}
var primes = []int64{}

func comb(m int, n int) int64 {
	for i := len(primes) - 1; i >= 0; i-- {
		if primes[i] <= int64(n) {
			primes = primes[:i+1]
			break
		}
	}
	res := int64(1)
	fnm := make([]int, len(factor[0]))
	copy(fnm, factor[n])
	for i, x := range factor[m] {
		fnm[i] += x
	}
	for w := 1; w <= m; w++ {
		fw, fmw, fnw, r := factor[w], factor[m-w], factor[n-w], int64(1)
		for i, p := range primes {
			for pw := fnm[i] - fw[i] - fmw[i] - fnw[i]; pw > 0; pw >>= 1 {
				if pw&1 == 1 {
					r = r * p % mod
				}
				p = p * p % mod
			}
		}
		res += r
	}
	return res % mod
}

func main() {
	abc := []int{0, 0, 0}
	fmt.Scan(&abc[0], &abc[1], &abc[2])
	sort.Ints(abc)
	a, b, c := abc[0], abc[1], abc[2]
	sieve := [N]bool{true, true}
	for p := range sieve {
		if !sieve[p] {
			primes = append(primes, int64(p))
			for q := p * p; q < N; q += p {
				sieve[q] = true
			}
		}
	}
	for j := range factor {
		factor[j] = make([]int, len(primes))
	}
	for i, p := range primes {
		for pp := p; pp < N; pp *= p {
			for j := pp; j < N; j += pp {
				factor[j][i]++
			}
		}
	}
	cur := factor[0]
	for _, nxt := range factor[:c+1] {
		for i, x := range cur {
			nxt[i] += x
		}
		cur = nxt
	}
	fmt.Println(comb(b, c) * comb(a, c) % mod * comb(a, b) % mod)
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1515E(in io.Reader, out io.Writer) {
	var n int
	var mod, ans int64
	Fscan(in, &n, &mod)
	inv := make([]int64, n+1)
	inv[1] = 1
	for i := 2; i <= n; i++ {
		inv[i] = (mod - mod/int64(i)) * inv[mod%int64(i)] % mod
	}

	dp := [2][][]int64{}
	for i := range dp {
		dp[i] = make([][]int64, n+1)
		for j := range dp[i] {
			dp[i][j] = make([]int64, n+1)
		}
	}
	dp[1][1][1] = 1
	for i := 2; i <= n; i++ {
		cur, pre := dp[i&1], dp[i&1^1]
		for _, r := range cur {
			for j := range r {
				r[j] = 0
			}
		}
		cur[1][0] = pre[1][1]
		for j := 2; j <= i; j++ {
			for k := 1; k <= j; k++ {
				cur[j][0] += pre[j][k]
			}
			cur[j][0] %= mod
			cur[j][1] = pre[j-1][0] * int64(j) % mod
			for k := 2; k <= j; k++ {
				cur[j][k] = pre[j-1][k-1] * int64(j) * 2 % mod * inv[k] % mod
			}
		}
	}
	for _, r := range dp[n&1] {
		for _, v := range r[1:] {
			ans += v
		}
	}
	Fprint(out, ans%mod)
}

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


package main
 import   "fmt"

func main(){
	var a,b int64
	fmt.Scanf("%d %d", &a, &b)
	for {
		if a == 0 || b == 0 {
			break
		}
		if a >= 2*b {
			z := a / (2*b)
			if z > 0 {
				a = a - 2*b*z
			} else {
				a = a - 2*b
			}

		} else if b >= 2*a {
			z := b / (2*a)
			if z > 0 {
				b = b - 2*a*z
			} else {
				b = b - 2*a

			}

		} else {break}
	}
	fmt.Print(a , b)
}


package main

import (
	"fmt"
	"time"
)

func main() {
	var x, h, m int
	fmt.Scanf("%d\n%d %d", &x, &h, &m)
	t := time.Date(2000, time.November, 10, h, m, 0, 0, time.UTC)
	i := 0
	for true {
		hour := t.Hour()
		if hour%10 == 7 {
			break
		}
		minute := t.Minute()
		if minute%10 == 7 {
			break
		}
		t = t.Add(-time.Duration(x) * time.Minute)
		i++
	}
	fmt.Print(i)
}


package main

import "fmt"

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)
	c := make([]int, n)
	for i, _ := range c {
		fmt.Scan(&c[i])
	}

	min_price := a
	if b < min_price {
		min_price = b
	}
	//fmt.Println(c)
	ans := 0
	for i, _ := range c {
		ri := n - 1 - i
		if i > ri {
			break
		} else if i == ri {
			if c[i] == 2 {
				ans += min_price
			}
		} else {
			if c[i] != 2 && c[ri] != 2 {
				if c[i] != c[ri] {
					ans = -1
					break
				}
			} else if c[i] == 2 && c[ri] != 2 {
				if c[ri] == 0 {
					ans += a
				} else {
					ans += b
				}
			} else if c[ri] == 2 && c[i] != 2 {
				if c[i] == 0 {
					ans += a
				} else {
					ans += b
				}
			} else {
				ans += (min_price * 2)
			}
		}
	}

	fmt.Println(ans)
}


package main

import "fmt"

func main() {
	var s string
	var m int64
	fmt.Scan(&s)
	fmt.Scan(&m)
	var n = len(s)

	var ten [300000]int64
	var suf [300000]int64

	ten[0] = 1;
	for i := 1; i <= n; i++ {
		ten[i] = (ten[i - 1] * 10) % m;
	}

	suf[n] = 0;
	for i := n-1; i >= 0; i-- {
		var id = int64(n - 1 - i);
		var dig = int64(s[i] - '0');
		suf[i] = (suf[i + 1] + dig * ten[id]) % m;
	}

	var mn = int64(m);
	var pv = int64(0);
	for i := 0; i < n; i++ {
		var cur = (suf[i] * ten[i] + pv) % m;
		//DBN(i, ten[i], suf[i]*ten[i], pv);
		var dig = int64(s[i] - '0');
		pv = (pv * 10 + dig) % m;
		if (dig != 0 && cur < mn) {
			mn = cur;
		}
	}

	fmt.Println(mn)
}


package main

import (
	"fmt"
	"strings"
)

func main() {
	var (
		a, b string
		c    int
	)
	fmt.Scan(&a, &b)
	a = strings.ToLower(a)
	b = strings.ToLower(b)
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			if a[i] < b[i] {
				c = -1
			} else {
				c = 1
			}
			break
		}
	}
	fmt.Print(c)

}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1618F(in io.Reader, out io.Writer) {
	var x, y uint64
	Fscan(in, &x, &y)
	if x == y {
		Fprintln(out, "YES")
		return
	}
	s := strconv.FormatUint(x, 2)
	t := strconv.FormatUint(y, 2)
	rt := []byte(t)
	for i, n := 0, len(rt); i < n/2; i++ {
		rt[i], rt[n-1-i] = rt[n-1-i], rt[i]
	}
	f := func() bool {
		r := regexp.MustCompile("^1*" + s + "1*$")
		return r.MatchString(t) || r.Match(rt)
	}
	s += "1"
	if f() {
		Fprintln(out, "YES")
		return
	}
	s = s[:len(s)-1]
	for s[len(s)-1] == '0' {
		s = s[:len(s)-1]
	}
	if f() {
		Fprintln(out, "YES")
	} else {
		Fprintln(out, "NO")
	}
}

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


package main

import "fmt"

func main () {

	var n int
	var str string

	fmt.Scanf("%d\n",&n)
	fmt.Scanf("%s\n",&str)

	if n == 1 {
		if str[0] == '0' {
			fmt.Println("no")
			return
		} else {
			fmt.Println("yes")
			return
		}
	}

	if str[0] == '0' && str[1] == '0' {
		fmt.Println("no")
		return
	}

	if str[n-1] == '0' && str[n-2] == '0' {
		fmt.Println("no")
		return
	}

	trick := 0
	rtrick := 0
	for i:= 0 ; i < n ; i++ {

		if str[i] == '1' {
			trick = 0
		} else {
			trick ++
		}

		if str[i] == '1' {
			rtrick ++
		} else {
			rtrick = 0
		}

		if trick == 3 || rtrick == 2{
			break
		}

	}

	if trick == 3 || rtrick == 2{
		fmt.Println("no")
	} else {
		fmt.Println("yes")
	}
}


package main

import (
	"fmt"
)

func main() {
	var a,b,c int
	fmt.Scan(&a, &b, &c)
	switch {
	case a >= b && a >= c && a+1>=b+c:
		fmt.Println(a + 1 - b - c);
	case b >= c && b >= a && b+1>=a+c:
		fmt.Println(b + 1 - a - c);
	case c >= a && c >= b && c+1>=a+b:
		fmt.Println(c + 1 - a - b);
	default:
		fmt.Println(0);
	}
}


package main

import (
  "fmt"
  "strings"
)

var n int
var str string
func main() {
  fmt.Scanf("%d\n", &n)
  fmt.Scanf("%s", &str)
  ll := 2
  max_subs := 1
	for ll < n/2+1 {
	    subs := strings.Contains(str[ll:2*ll], str[0:ll])
	    if subs {
	      max_subs = ll
	    }
	    ll+=1
	}
	fmt.Println(n-max_subs+1)
}


package main

import "fmt"

func main() {
    var n int64
    fmt.Scan(&n)
    for a := int64(1); ; a *= 3 {
        if (n%a) != 0 {
            fmt.Println((n/a)+1)
            break
        }
    }
}


package main

import (
	"fmt"
	"strconv"
)

func bololo(s string) int {
	var haha int
	for i := 0; i < len(s); i++ {
		atual := s[i : i+1]
		if atual == "4" || atual == "7" {
			haha++
		}
	}
	return haha
}

func main() {
	var lucky string
	var digits int
	var luckydigits string
	var digits2 int
	fmt.Scanf("%s", &lucky)
	digits = bololo(lucky)
	luckydigits = strconv.FormatInt(int64(digits), 10)
	digits2 = bololo(luckydigits)
	if digits2 == len(luckydigits) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	exp := map[int]string{
		1:  "one",
		2:  "two",
		3:  "three",
		4:  "four",
		5:  "five",
		6:  "six",
		7:  "seven",
		8:  "eight",
		9:  "nine",
		10: "ten",
		11: "eleven",
		12: "twelve",
		13: "thirteen",
		15: "fifteen",
		18: "eighteen",
		20: "twenty",
		30: "thirty",
		40: "forty",
		50: "fifty",
		80: "eighty",
	}

	var scr int
	fmt.Fscan(reader, &scr)
	if scr == 0 {
		fmt.Println("zero")
		return
	}
	if _, exst := exp[scr]; exst {
		fmt.Println(exp[scr])
		return
	}

	if scr/10 == 1 {
		fmt.Printf("%s%s", exp[scr%10], "teen")
	} else {
		if _, exst := exp[(scr/10)*10]; exst {
			fmt.Print(exp[(scr/10)*10])
		} else {
			fmt.Printf("%s%s", exp[scr/10], "ty")
		}
		if scr%10 > 0 {
			fmt.Printf("-%s", exp[scr%10])
		}
	}
}


package main

import (
	"fmt"
)

func int_abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

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

func int_min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	var v1, v2, t, d int
	fmt.Scan(&v1)
	fmt.Scan(&v2)
	fmt.Scan(&t)
	fmt.Scan(&d)
	ans := 0
	speed := v1
	for i := 0; i < t; i++ {
		ans += speed
		speed = int_min(speed+d, v2+d*(t-2-i))
	}
	fmt.Println(ans)
}


package main

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

const (
	EPS = 1e-8
)

var (
	reader = bufio.NewReader(os.Stdin)
)

type Light struct {
	p complex128
	a float64
}

type Line struct {
	p1, p2 complex128
}

func CrossProduct(a complex128, b complex128) float64 {
	return real(a)*imag(b) - real(b)*imag(a)
}

func Roatate(p complex128, a float64) complex128 {
	return p * complex(math.Cos(a), math.Sin(a))
}

func Intersact(a Line, b Line) (intersaction complex128, isIntersact bool) {
	var (
		s1 = CrossProduct(a.p2-a.p1, b.p1-a.p1)
		s2 = CrossProduct(a.p2-a.p1, b.p2-a.p1)
		s  = s2 - s1
	)
	if math.Abs(s) >= EPS {
		isIntersact = true
		intersaction = complex((real(b.p1)*s2-real(b.p2)*s1)/s, (imag(b.p1)*s2-imag(b.p2)*s1)/s)
	}
	return
}

func foo(l float64, lit Light, r float64) float64 {
	v1 := complex(l-real(lit.p), 0-imag(lit.p))
	v2 := Roatate(v1, lit.a)
	if imag(v2) > -EPS {
		return r
	}

	p1 := complex(0.0, 0.0)
	p2 := complex(100.0, 0.0)
	inter, _ := Intersact(Line{lit.p, lit.p + v2}, Line{p1, p2})
	return real(inter)
}

func main() {
	var (
		n    int
		l, r float64
		lits []Light
	)

	fmt.Fscan(reader, &n, &l, &r)
	for i := 0; i < n; i++ {
		var x, y, a float64
		fmt.Fscan(reader, &x, &y, &a)
		lits = append(lits, Light{complex(x, y), a * math.Pi / 180.0})
	}

	f := make([]float64, 1<<uint(n))
	for i := range f {
		f[i] = l
	}
	for i := 0; i < (1 << uint(n)); i++ {
		for j := 0; j < n; j++ {
			if k := i | 1<<uint(j); i != k {
				cur := foo(f[i], lits[j], r)
				if cur > f[k] {
					f[k] = cur
				}
			}
		}
	}
	fmt.Print(math.Min(f[(1<<uint(n))-1]-l, r-l))
}


package main

import "fmt"

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	f := []byte(s)

	l := len(s)
	found := false
	nearFound := false
	iNearFound := -1
	for i := 0; i < l; i++ {
		if nearFound {
			if int(s[i]) < int('z') {
				f[i] = s[i] + 1
				for k := iNearFound; k < i; k++ {
					f[k] = s[k]
				}

				found = true
				break
			} else if int(t[i]) > int('a') {
				f[i] = t[i] - 1
				for k := iNearFound; k < i; k++ {
					f[k] = t[k]
				}
				found = true
				break
			}
			continue
		}
		if int(t[i])-int(s[i]) > 1 {
			f[i] = s[i] + 1
			found = true
			break
		} else if int(t[i])-int(s[i]) > 0 {
			if i < len(s)-1 {
				nearFound = true
				iNearFound = i
			}
		} else if int(s[i]) > int(t[i]) {
			break
		}

	}

	if found {
		fmt.Print(string(f))
		return
	}

	fmt.Print("No such string")
}

/*
pnzcl
pnzdf

pnzcm

*/


package main

import "fmt"

func main() {
    var n,d,a int
    fmt.Scan(&n,&d)
    total := 0
    for i := 0; i < n; i++ {
        fmt.Scan(&a)
        total += a
    }
    total += (n-1)*10
    if total > d {
        fmt.Println("-1")
    } else {
        fmt.Println(2*(n-1) + (d-total)/5)
    }
}


package  main
import ("fmt")

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

func min(x,y int) int {
   if (x<y){
   	return x
   } else{
   	return y
   }
}

func abs(x int) int{
	if(x <0){
		x = -1*x
	}

	return x
}
func main(){
	var n int
	//fmt.Print(abs(-30))

	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)
	l := len(s)
    ans :=100000
	for i:=0 ;i<l-3;i++ {
		var p int
		p =0
		//fmt.Println(abs(int(s[i]-'A')))
		b := int(s[i])

		p+= min(26- abs(int(b-65)) , abs(int(b-65)))
		b = int(s[i+1])

    	p+= min(26- abs(int(b-67)) , abs(int(b-67)))
    	b = int(s[i+2])
    	p+= min(26- abs(int(b-84)) , abs(int(b-84)))
    	b = int(s[i+3])
    	p+= min(26- abs(int(b-71)) , abs(int(b-71)))
    	ans = min(p,ans);

	}
	fmt.Print(ans)

}


package main
import (
	"fmt"
)
func main() {
	var a,b,k int64
	c:=0
	fmt.Scan(&a,&b)
	k=a
	for ;k<b; {
		k*=a
		c++
	}
	if k==b {
		fmt.Println("YES")
		fmt.Println(c)
	} else {
		fmt.Println("NO") }
}


package main

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

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

	n, s, cnt, i := io.nextInt(), io.nextString(), 0, 0
	for i < n {
		if s[i] != 'x' {
			i++
			continue
		}
		j := i
		for j < n && s[j] == s[i] {
			j++
		}
		cnt += max(0, j - i - 2)
		i = j
	}
	io.print(strconv.Itoa(cnt))
}

type stack []int

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

func (s stack) Pop() (stack, int, bool) {
	l := len(s)
	if l == 0 {return s, 0, false}
	return s[:l-1], s[l-1], true
}

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

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

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

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

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

func (out io) print (s string) {
	out.out.WriteString(s)
}


package main

import (
	"fmt"
	//"sort"
	//"math"
)

func main() {
	var m,x,y int
	var a [100]int
	s,t:=0,0
	flag:=false
    	fmt.Scan(&m)
	for i:=0;i<m;i++ {
	    	fmt.Scan(&a[i])
	    	t+=a[i]
	}
	fmt.Scan(&x,&y)
	for i:=0;i<m;i++ {
		s+=a[i]
		if s>=x && s<=y && t-s>=x && t-s<=y {
			fmt.Println(i+2)
			flag=true
			break
		}
	}
	if flag==false {
		fmt.Println("0")
	}
}


// 80B
package main

import (
	"fmt"
)

func main() {
	var x, y int
	fmt.Scanf("%d:%d", &x, &y)
	x %= 12
	n := float64(y) / 2
	fmt.Printf("%.10f %d\n", float64(x%12)*30+n, y*6)
}


package main

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

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

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

	res := 3
	if n > 1 {
		p := (n-1) % 3
		q := (n+2) / 3
		res = 4*q + 3*p / 2
	}

	fmt.Fprintln(w, res)
}


package main

import "fmt"

func main() {
    var a,b,c int
    fmt.Scan(&a,&c)
    for i := 1; (a > 0) || (c > 0); i *= 3 {
        da, dc := a%3, c%3
        if dc < da { dc += 3 }
        b += (i*(dc-da))
        a /= 3
        c /= 3
    }
    fmt.Println(b)
}


package main

import (
	"fmt"
	"math"
	"runtime/debug"
)

type Range struct {
	left, right int
}

var (
	isNotPrime []bool
	primes     []int
	n          int
)

func main() {
	debug.SetGCPercent(-1)

	fmt.Scanf("%d", &n)
	// n = 1e6

	calcPrimes(n)

	x1Range := getRange(n)

	x0Range := getRange(x1Range.left)

	for i := x1Range.left + 1; i < x1Range.right; i++ {
		x0Range = joinRanges(x0Range, getRange(i))
	}

	fmt.Println(x0Range.left)
}

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

	return b
}

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

	return b
}

func joinRanges(r1, r2 Range) Range {
	left := min(r1.left, r2.left)

	right := max(r1.right, r2.right)

	return Range{left, right}
}

func getRange(n int) Range {
	divider := findMaxPrimeDivider(n)

	return Range{n - divider + 1, n}
}

func findMaxPrimeDivider(x int) int {
	sqrtx := int(math.Sqrt(float64(x))) + 1

	for i := 0; i < len(primes) && primes[i] < sqrtx; i++ {
		if x%primes[i] == 0 {
			x /= primes[i]

			for isNotPrime[x] && x%primes[i] == 0 {
				x /= primes[i]
			}

			if !isNotPrime[x] {
				return x
			}
		}
	}

	return 1
}

func calcPrimes(n int) {
	isNotPrime = make([]bool, n+1)

	for i := 2; i*i <= n; i++ {
		if !isNotPrime[i] {
			for j := i * i; j <= n; j += i {
				isNotPrime[j] = true
			}
		}
	}

	primes = make([]int, 0, n/2)

	for i := 2; i <= n; i++ {
		if !isNotPrime[i] {
			primes = append(primes, i)
		}
	}
}


package main

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

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

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	board := make([]string, 8)
	maxB, minW := 0, 10

	for i := range board {
		board[i] = next()
	}

	for c := 0; c < 8; c++ {
		b, w := -1, -1

		for r := 0; r < 8; r++ {
			if board[r][c] == 'B' {
				break
			}

			if board[r][c] == 'W' {
				w = r
				break
			}
		}

		for r := 7; r >= 0; r-- {
			if board[r][c] == 'W' {
				break
			}

			if board[r][c] == 'B' {
				b = r
				break
			}
		}

		// println(w, b, minW, maxB)

		if w != -1 && w < minW {
			minW = w
		}

		if b != -1 && b > maxB {
			maxB = b
		}
	}

	// println(minW, maxB)
	maxB = 8 - maxB - 1
	// println(minW, maxB)
	if minW <= maxB {
		println("A")
	} else {
		println("B")
	}
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

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

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }


package main

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

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

func reverse(x int, s []byte) {
	for i, j := 0, x-1; i < j; i, j = i+1, j-1 {
		s[i], s[j] = s[j], s[i]
	}
}

func main() {
	defer out.Flush()

	var n int
	var s []byte
	fmt.Fscan(in, &n, &s)

	//TODO: enhancement, sqrt
	for i := 2; i <= n; i++ {
		if n % i == 0 {
			reverse(i, s)
		}
	}
	fmt.Fprintln(out, string(s))
}


package main

import "fmt"

func main() {
	var n int

	fmt.Scan(&n)

	var a, mid int

	var sum = 0

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			fmt.Scan(&a)

			if n/2 == i {
				sum += a
			}

			if n/2 == j {
				sum += a
			}

			if i == j {
				sum += a
			}

			if n-i-1 == j {
				sum += a
			}

			if n/2 == i && n/2 == j {
				mid = a
			}
		}
	}

	sum -= mid * 3

	fmt.Println(sum)
}


package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	var q string
	fmt.Scan(&q)

	var f [26]int

	for i := 0; i < len(q); i++ {
		var ci int = int(q[i] - 'a')
		f[ci] = 1
	}

	var c int = 0
	for i := 0; i < len(f); i++ {
		c += f[i]
	}

	if c < n {
		fmt.Println("NO")
		return
	}

	fmt.Print("YES")
	var g [26]int
	for i := 0; i < len(q); i++ {
		var ci int = int(q[i] - 'a')
		if (n > 0) && (g[ci] == 0) {
			fmt.Printf("\n%c", q[i])
			g[ci] = 1
			n--
		} else {
			fmt.Printf("%c", q[i])
		}
	}
	fmt.Println("")
}


package main

import "fmt"

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

func main() {
    var n,c,cur int
    fmt.Scan(&n,&c)
    ans, prev := 0, -100
    for i := 0; i < n; i++ {
        fmt.Scan(&cur)
        ans = max(ans,prev-cur-c)
        prev = cur
    }
    fmt.Println(ans)
}


package main

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

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

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

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	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
}

/*********** DP sub-functions ***********/

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

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

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

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

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

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

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

	return s
}

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

	if e == 0 {
		return 1
	}

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

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

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

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

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

/********** 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 MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var n int64

func main() {
	n = ReadInt64()

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

	if IsPrime(n) {
		fmt.Println(n)
		return
	}

	// D := divisor(n)
	// if len(D) == 3 {
	// 	fmt.Println(D[2])
	// 	return
	// }
	memo := TrialDivision(n)
	if len(memo) == 1 {
		for k := range memo {
			fmt.Println(k)
			return
		}
	}

	fmt.Println(1)
}

// 約数の列挙: O(sqrt(n))
func divisor(n int64) []int64 {
	res := []int64{}

	for i := int64(1); i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i != (n / i) {
				res = append(res, (n / i))
			}
		}
	}

	return res
}

// TrialDivision returns the result of prime factorization of integer N.
func TrialDivision(n int64) map[int64]int {
	if n <= 1 {
		panic(errors.New("[argument error]: TrialDivision only accepts a NATURAL number"))
	}

	p := map[int64]int{}
	for i := int64(2); i*i <= n; i++ {
		exp := 0
		for n%i == 0 {
			exp++
			n /= i
		}

		if exp == 0 {
			continue
		}
		p[i] = exp
	}
	if n > 1 {
		p[n] = 1
	}

	return p
}

// IsPrime judges whether an argument integer is a prime number or not.
func IsPrime(n int64) bool {
	if n == 1 {
		return false
	}

	for i := int64(2); i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}

	return true
}

// エラトステネスの篩: O(NloglogN)
// n以下の素数の数と素数のスライスを返す
func sieve(n int) (int, []int) {
	// var prime [2000000 + 5]int
	prime := []int{}
	var isPrime [2000000 + 5 + 1]bool

	p := 0
	for i := 0; i <= n; i++ {
		isPrime[i] = true
	}
	isPrime[0], isPrime[1] = false, false

	for i := 2; i <= n; i++ {
		// iがtrueで残っている場合は素数認定し、自分より大きい倍数を取り除いていく
		if isPrime[i] {
			// prime[p] = i
			prime = append(prime, i)
			p++

			// 倍数の除去
			for j := 2 * i; j <= n; j += i {
				isPrime[j] = false
			}
		}
	}

	return p, prime
}

// MODはとったか？
// 遷移だけじゃなくて最後の最後でちゃんと取れよ？

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


package main

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

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

	fmt.Fscanf(buf, "%d\n", &t)
	var ans int64 = 1

	for  {
		if ans*ans >=t{
			ans = ans*2
			break
		}
		if ans*(ans+1) >= t{
			ans = ans*2+1
			break
		}
		ans++
	}

	fmt.Printf("%d\n", ans)
}


package main

import "fmt"

func main() {
	var i, j, r, c, ans int
	fmt.Scan(&r, &c)
	input := make([]string, r)
	rows := make([]bool, r)
	cols := make([]bool, c)
	for i=0; i<r; i++ {
		rows[i] = false
	}
	for i=0; i<c; i++ {
		cols[i] = false
	}
	for i=0; i<r; i++ {
		fmt.Scan(&input[i])
	}
	for i=0; i<r; i++ {
		for j=0; j<c; j++ {
			if input[i][j] == 'S' {
				rows[i] = true
				cols[j] = true
			}
		}
	}
	ans = 0
	for i=0; i<r; i++ {
		for j=0; j<c; j++ {
			if !rows[i] || !cols[j] {
				ans += 1
			}
		}
	}
	fmt.Println(ans)
}


package main

import "fmt"

func gcd(a, b uint64) uint64 {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func main() {
	var a, b, x, y uint64
	fmt.Scanf("%d %d %d %d", &a, &b, &x, &y)

	d := gcd(x, y)
	x /= d
	y /= d

	if a/x > b/y {
		fmt.Println(b / y)
		return
	}

	fmt.Println(a / x)
}


package main

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

func Sol584D(reader io.Reader, writer io.Writer) {
	isPrime := func(n int) bool {
		for i := 2; i*i <= n; i++ {
			if n%i == 0 {
				return false
			}
		}
		return true
	}

	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	Fscan(in, &n)
	if isPrime(n) {
		Fprintln(out, 1)
		Fprintln(out, n)
		return
	}
	n -= 3
	for i := 3; ; i += 2 {
		if isPrime(i) && isPrime(n-i) {
			Fprintln(out, 3)
			Fprintln(out, 3, i, n-i)
			return
		}
	}
}

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


package main

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

func solve() {
	n := readInt()
	m := readInt() - 1
	k := readInt()
	ans := math.MaxInt32
	for i := 0; i < n; i++ {
		a := readInt()
		if a != 0 && a <= k {
			if ans > 10*abs(i-m) {
				ans = 10 * abs(i-m)
			}
		}
	}
	fmt.Println(ans)
}

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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


package main

import "fmt"

func main() {
    var n int
    var a [7]int
    fmt.Scan(&n)
    total := 0
    for i := 0; i < 7; i++ {
        fmt.Scan(&a[i])
        total += a[i]
    }
    n %= total
    ans := 0
    if n == 0 {
        ans = 6
        for ; ans >= 0; ans-- {
            if a[ans] > 0 {
                break
            }
        }
    } else {
        for n > a[ans] {
            n -= a[ans]
            ans++
        }
    }
    fmt.Println(ans+1)
}


package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n, m := 0, 0
	fmt.Fscanf(in, "%d %d\n", &n, &m)
	ans := 0
	if m >= n-1 {
		ans = n - 1
	} else {
		ans = n - 1
		for i := 1; i <= n-1-m; i++ {
			ans += i
		}
	}
	fmt.Fprintf(out, "%d\n", ans)
	return
}

func recover(s string) string {
	if len(s) == 1 {
		return s
	}
	if len(s)%2 == 0 {
		return recover(s[:len(s)-1]) + string(s[len(s)-1])
	} else {
		return recover(s[1:]) + string(s[0])
	}
}


// Codeforces My Practice
// author: Leonardone @ NEETSDKASU
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	xs := make([]int, n)
	ones := 0
	for i := range xs {
		fmt.Scan(&xs[i])
		if xs[i] == 1 {
			ones++
		}
	}
	ans := ones
	zeros := 0
	for _, x := range xs {
		if x == 0 {
			zeros++
		} else {
			ones--
		}
		tmp := ones + zeros
		if tmp > ans {
			ans = tmp
		}
	}
	fmt.Println(ans)
}


package main

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

const N = 205
const INF = -1000000000

func main() {
	io := NewFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	n, k := io.NextInt(), io.NextInt()
	s, t := io.Next(), io.Next()
	var suff [N][26]int

	for i := n; i >= 1; i-- {
		for j := 0; j < 26; j++ {
			suff[i][j] = suff[i+1][j]
		}
		suff[i][int(s[i-1]-'a')]++
	}

	if t[0] == t[1] {
		have, cur := 0, 0
		for i := 0; i < n; i++ {
			if s[i] == t[0] {
				cur++
			} else {
				have++
			}
		}
		cur += min(have, k)
		io.Println(cur * (cur - 1) / 2)
		return
	}

	var dp [N][N][N]int
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			for k := 0; k < N; k++ {
				dp[i][j][k] = -1
			}
		}
	}

	a, b := int(t[0]-'a'), int(t[1]-'a')
	_ = a

	var dfs func(int, int, int) int
	dfs = func(i, r, c int) int {
		if r < 0 {
			return INF
		}
		if i == n+1 {
			if r == 0 {
				return 0
			} else {
				return INF
			}
		}
		if dp[i][r][c] != -1 {
			return dp[i][r][c]
		}
		ans := 0
		if s[i-1] == t[0] {
			ans = dfs(i+1, r, c+1) + suff[i+1][b]
			ans = max(ans, dfs(i+1, r-1, c))
			ans = max(ans, dfs(i+1, r-1, c)+c)
		} else if s[i-1] == t[1] {
			ans = dfs(i+1, r-1, c+1) - c + suff[i+1][b]
			ans = max(ans, dfs(i+1, r, c))
			ans = max(ans, dfs(i+1, r-1, c))
		} else {
			ans = dfs(i+1, r-1, c+1) + suff[i+1][b]
			ans = max(ans, dfs(i+1, r-1, c)+c)
			ans = max(ans, dfs(i+1, r, c))
		}
		dp[i][r][c] = ans
		return ans
	}

	ans := 0
	for i := 0; i <= k; i++ {
		ans = max(ans, dfs(1, i, 0))
	}

	io.Println(ans)
}

func min(i, j int) int {
	if i > j {
		return j
	}
	return i
}

func max(i, j int) int {
	if i > j {
		return i
	}
	return j
}

type FastIO struct {
	*bufio.Reader
	*bufio.Writer
	c [1]byte
}

func NewFastIO(r io.Reader, w io.Writer) *FastIO {
	return &FastIO{Reader: bufio.NewReader(r), Writer: bufio.NewWriter(w)}
}

func (f *FastIO) readC() byte {
	f.Read(f.c[:])
	return f.c[0]
}

func (f *FastIO) NextInt() int {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := 0
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}

func (f *FastIO) NextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt()
	}
	return a
}

func (f *FastIO) Next() string {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	var s []byte
	for ; c > ' '; c = f.readC() {
		s = append(s, f.c[0])
	}
	return string(s)
}

func (f *FastIO) Println(a ...interface{}) {
	fmt.Fprintln(f.Writer, a...)
}

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f.Writer, a...)
}

func (f *FastIO) PrintInts(a ...int) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}

func (f *FastIO) PrintlnInts(a ...int) {
	f.PrintInts(a...)
	f.Println()
}


package main

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

func main() {
	var n int
	var s string
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &n, &s)
	ans := ""
	j := 0
	for i := 0; i < n; i += j {
		j += 1
		ans += string(s[i])
	}
	fmt.Println(ans)
}


package main

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

var bestTimes int
var m int

//var ret []int

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscanln(reader, &n, &m)
	//max := 0
	if n > m {
		bestTimes = n - m
		//max = n
	} else {
		c1, n1 := findFirstBigger(n, m)
		//fmt.Println(c1, n1)
		bestTimes = c1 + (n1 - m)
	}
	//fmt.Println(bestTimes)
	//ret = make([]int, max*2+1)
	//for i := 0; i < len(ret); i++ {
	//	ret[i] = -1
	//}
	dfs1(n, m, 0)
	fmt.Println(bestTimes)
}

func dfs1(n int, m int, count int) {
	//fmt.Println(n, m, count)
	if count > bestTimes {
		return
	}
	if n == m {
		if count < bestTimes {
			bestTimes = count
		}
		//fmt.Println("====")
		return
	}
	if n == 0 {
		//fmt.Println("====")
		return
	}
	if n > m {
		if count+n-m < bestTimes {
			bestTimes = count + n - m
		}
		//fmt.Println("====")
		return
	} else {
		if m%2 == 0 {
			dfs1(n, m/2, count+1)
		} else {
			_, n1 := findFirstBigger(n, m)
			for i := n1; i > m; i-- {
				if i%2 == 0 {
					dfs1(n, i, count+i-m)
				}
			}
		}

	}
}

// 次数， temp
func findFirstBigger(n, m int) (int, int) {
	temp := n
	count := 0
	for {
		count++
		temp *= 2
		if temp >= m {
			return count, temp
		}
	}
}


package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()

	ans := ""

	ans += strings.Repeat("8", N/2)
	N = N % 2
	ans += strings.Repeat("4", N)

	if len(ans) > 18 {
		fmt.Println(-1)
	} else {
		fmt.Println(ans)
	}
}

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 "os"
import "bufio"
import "strconv"

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

func main(){
	var k int
	var a, b int
	var v int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	k, _ = strconv.Atoi(r.Text())
	r.Scan()
	a, _ = strconv.Atoi(r.Text())
	r.Scan()
	b, _ = strconv.Atoi(r.Text())
	r.Scan()
	v, _ = strconv.Atoi(r.Text())
	box := 0
	x := 0
	for a > 0 {
		x = min(k-1, b)
		a -= (x+1)*v
		b -= x
		box += 1
	}
	w.WriteString(strconv.Itoa(box)+"\n")
	w.Flush()
}


package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	arr := [16]int{}
	rems := [4]int{}
	for i := 1; i < 4; i++ {
		fmt.Scan(&rems[i])
	}
	arr[n%4] = 1
	for i := 0; i < 12; i++ {
		if arr[i] > 0 {
			for j := 1; j < 4; j++ {
				if arr[i+j] == 0 || arr[i+j] > arr[i]+rems[j] {
					arr[i+j] = arr[i] + rems[j]
				}
			}
		}
	}
	ans := 0
	for i := 0; i < 16; i += 4 {
		if arr[i] > 0 && (ans == 0 || arr[i] < ans) {
			ans = arr[i]
		}
	}
	fmt.Println(ans - 1)
}


package main

import (
	"fmt"
	"sort"
)

func calc(arr []int) int{
	sort.Ints(arr)
	count := 0
	for i:=0;i<len(arr);i++{
		if arr[i]==0{
			continue
		}else{
			for j:=i+1;j<len(arr);j++{
				if arr[j]%arr[i]==0{
					arr[j] = 0
				}
			}
			arr[i] = 0
			count++
		}
	}
	return count
}

func main(){
	var n int
	fmt.Scan(&n)
	arr := make([]int,n)
	for i:=0;i<n;i++{
		fmt.Scan(&arr[i])
	}
	fmt.Print(calc(arr))
}


package main

import (
	"fmt"
)

func main() {
	var n int

	fmt.Scan(&n)

	var freq [10]int
	for i:=0; i<10; i++ {
		freq[i] = 0
	}

	for i:=0; i<4; i++ {
		var s string

		fmt.Scan(&s);
		for j:=0; j<len(s); j++ {
			if s[j] >= '0' && s[j] <= '9' {
				freq[s[j]-'0']++
			}
		}
	}

	possible := true
	for i:=0; i<10; i++ {
		if freq[i] > 2*n {
			possible = false
		}
	}

	if possible {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


package main

import (
	"fmt"
	"sort"
)

var(
	n int				/*Number of students*/
	M int				/*Maximum time*/
	t[110] int  		/*Students' time*/
	sum[110] int 		/*sum [0..i)*/
	buffer[110] int 	/*used for sorting*/
)

func main(){
	//input
	fmt.Scanf("%d %d\n", &n, &M)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &t[i])
	}

	sum[0] = 0
	for i := 1; i < n; i++ {
		sum[i] = sum[i - 1] + t[i - 1]
	}
	buffer = sum

	for i := 0; i < n; i++ {	/*Next student*/
		ans := 0
		required := M - t[i]
		current := sum[i]
		if current > required{
			copy(buffer[0:i], t[0:i])
			sort.Ints(buffer[0:i])
		}
		for current > required {
			ans++
			current -= buffer[i - ans]  /*M > t[i]*/
		}
		fmt.Printf("%d ",  ans)
	}
}


package main

import (
    "fmt"
)

func main() {
    var n, m int
    fmt.Scanf("%d %d", &n, &m)
    mn := n
    if m < n {
        mn = m
    }
    if mn % 2 == 0 {
        fmt.Println("Malvika")
    } else {
        fmt.Println("Akshat")
    }
}


package main

import "fmt"

func main() {
	var A, B, C, D int
	fmt.Scan(&A, &B, &C, &D)
	A -= C
	B -= C
	D -= C
	D -= (A + B)
	// fmt.Printf("A:%d B:%d C:%d D:%d\n", A, B, C, D)
	if A < 0 || B < 0 || D < 1 {
		D = -1
	}
	fmt.Println(D)
}