source_code:
package main

import (
)
import "fmt"

func main() {
	var n, prev, now int64
	fmt.Scan(&n)
	prev = 1
	now = 2
	ans := 0
	for now <= n {
		prev, now = now, prev + now
		ans += 1;
	}
	fmt.Println(ans)
}

lang_cluster: Go

exec_outcome: PASSED


source_code:
package main

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

func solve() {
	l := readInt64()
	r := readInt64()
	x := readInt64()
	y := readInt64()
	k := readInt64()
	for j := x; j <= y; j++ {
		t := j * k
		if t > r {
			break
		}
		if t >= l && t <= r {
			fmt.Println("YES")
			return
		}
	}
	// for i := l; i <= r; i++ {
	// 	for j := x; j <= y; j++ {
	// 		if i%j == 0 && i/j == k {
	// 			fmt.Println("YES")
	// 			return
	// 		}
	// 	}
	// }
	fmt.Println("NO")
}

var scanner *bufio.Scanner

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

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

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

// IO

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

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

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

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

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


source_code:
package main

import (
	"fmt"
	"log"
)

var (
	hi = []string{"h", "e", "l", "l", "o"}
)

func main() {
	var (
		s       string
		counter int
		length  = len(hi)
	)
	if _, err := fmt.Scanf("%s\n", &s); err != nil {
		log.Fatal(err)
	}

	for i := range s {
		if s[i:i+1] == hi[counter] {
			counter++
			if counter == length {
				fmt.Println("YES")
				return
			}
		}
	}
	fmt.Println("NO")
}


source_code:
package main

import (
    "fmt"
    s "strings"
)
 func main() {
    var l int
    var str string
    fmt.Scan(&l, &str)
    fs := s.Count(str, "FS")
    sf := s.Count(str, "SF")
    if sf > fs {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}


source_code:
package main

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

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

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

	n := nextInt64()
	var sum, i int64 = 0, 0

	for sum+i+1 <= n {
		sum += i
		i++
	}
	// println(sum)
	println(n - sum)
}

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


source_code:
// https://codeforces.com/problemset/problem/731/A
package main

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

func diff(x int, y int) int {
	z := x - y
	if z >= 0 {
		return z
	}

	return z * (-1)
}

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

	var m, mRev map[rune]int
	m = make(map[rune]int)
	mRev = make(map[rune]int)
	char := 'a'
	for i := 1; i <= 26; i++ {
		m[rune(char)] = i
		char++
	}
	charRev := 'z'
	for i := 26; i >= 1; i-- {
		mRev[rune(charRev)] = i
		charRev--
	}

	var s string
	var ans int
	fmt.Fscanf(in, "%s\n", &s)
	for i := 0; i < len(s); i++ {
		var a, b int
		if i == 0 {
			a = diff(m[rune(s[i])], m['a'])
			b = diff(a, 26)
		} else {
			a = diff(m[rune(s[i])], m[rune(s[i-1])])
			b = diff(a, 26)
		}
		if a < b {
			ans += a
		} else {
			ans += b
		}
	}

	fmt.Fprintln(out, ans)
}


source_code:
package main

import "fmt"

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

func main() {
	var y, b, r int
	fmt.Scan(&y, &b, &r)
	ans_r := min(y + 2, min(b + 1, r))
	fmt.Println((ans_r - 1) * 3)
}


source_code:
package main

import (
    "fmt"
    )

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

    if n%4==0 || n%4==3 {
        fmt.Println("0")
    } else {
        fmt.Println("1")
    }
}


source_code:
package main

import (
	"fmt"
)

func gcd(a, b int) int {
	if a > b {
		a, b = b, a
	}

	// Special case for zero
	if a == 0 || b == 0 {
		return a + b
	}

	// Calculate GCD using Euclidean algorithm
	result := 1

	for {
		remain := b % a

		if remain == 0 {
			result *= a
			break
		} else {
			b = a
			a = remain
		}
	}
	return result
}

func main() {
	var simon, antisimon, stones int

	fmt.Scanf("%d %d %d", &simon, &antisimon, &stones)

	for {
		// Simon plays
		var simonQuota = gcd(simon, stones)

		if simonQuota <= stones {
			stones -= simonQuota
		} else {
			fmt.Println(1)
			return
		}

		// Antisimon plays
		var antiQuota = gcd(antisimon, stones)

		if antiQuota <= stones {
			stones -= antiQuota
		} else {
			fmt.Println(0)
			return
		}

		// fmt.Println(simon, antisimon, stones, simonQuota, antiQuota)
	}
}


source_code:
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n)
	fmt.Scan(&m)

	grid := make([][]bool, n)
	for i := 0; i < n; i++ {
		grid[i] = make([]bool, m)
	}

	var ret bool = false

	for {
		var found bool = false

		for i := 0; i < n && !found; i++ {
			for j := 0; j < m && !found; j++ {
				if !grid[i][j] {
					for k := 0; k < n; k++ {
						grid[k][j] = true
					}
					for k := 0; k < m; k++ {
						grid[i][k] = true
					}
					found = true
					break
				}
			}
		}

		if !found {
			break
		}

		ret = !ret
	}

	if !ret {
		fmt.Println("Malvika")
	} else {
		fmt.Println("Akshat")
	}
}


source_code:
package main

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

var res []int

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	scanner.Scan()
	k, _ := strconv.Atoi(scanner.Text())

	solve(n, k)
	if len(res) == 0 || len(res) != k {
		fmt.Println(-1)
		os.Exit(0)
	}
	check := 1
	for _, el := range res {
		check *= el
	}
	if check != n {
		fmt.Println(-1)
		os.Exit(0)
	}
	for i, el := range res {
		if i == len(res)-1 {
			fmt.Printf("%d\n", el)
			continue
		}
		fmt.Printf("%d ", el)
	}
}

func solve(n, k int) {
	if n == 1 {
		return
	}
	if k == 1 {
		res = append(res, n)
		return
	}
	for i := 2; i <= int(math.Sqrt(float64(n)))+1; i++ {
		if n%i == 0 {
			res = append(res, i)
			solve(n/i, k-1)
			return
		}
	}
}


source_code:
package main

import (
	"fmt"
)

var (
	n      int
	m      int
	result int
)

func in() {
	fmt.Scanf("%d %d\n", &n, &m)
}

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

func run() {
	var remain int = n
	var d int = 1
	for ; remain > 0; d++ {
		if d%m != 0 {
			remain--
		}
	}
	result = d - 1
}

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


source_code:
package main

import "fmt"

func main() {
    var x,t,a,b,da,db int
    fmt.Scan(&x,&t,&a,&b,&da,&db)
    m := make(map[int]bool)
    m[0] = true
    for i := 0; i < t; i++ {
        m[a-(da*i)] = true
    }
    ans := false
    for i := 0; i <= t; i++ {
        if i == t {
            if m[x] {
                ans = true
                break
            }
        } else if m[x-(b-(db*i))] {
            ans = true
            break
        }
    }
    if ans { fmt.Println("YES") } else { fmt.Println("NO") }
}


source_code:
package main

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

func main(){
	var a, c int64
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	a, _ = strconv.ParseInt(r.Text(), 0, 64)
	r.Scan()
	c, _ = strconv.ParseInt(r.Text(), 0, 64)
	var b int64
	i := 0
	var x [105]int64
	var y [105]int64
	for i=1; a+c>0; i++ {
		x[i] = a%3
		a /= 3
		y[i] = c%3
		c /= 3
	}
	for i > 1 {
		i -= 1
		b = b*3 + ((y[i]-x[i]+3)%3)
	}
	w.WriteString(strconv.FormatInt(b, 10)+"\n")
	w.Flush()
}


source_code:
package main
import "fmt"

func main() {
	var x, x1 int
	var ts string
	var t string
	var t1 string
	fmt.Scan(&ts)
	fmt.Scan(&t, &t1)

	if string(t[0])=="T" {
		x=11
	} else if string(t[0])=="A" {
		x=15
	} else if string(t[0])=="K" {
		x=14
	} else if string(t[0])=="Q" {
		x=13
	} else if string(t[0])=="J" {
		x=12
	} else if string(t[0])=="9" {
		x=9
	} else if string(t[0])=="8" {
		x=8
	} else if string(t[0])=="7" {
		x=7
	} else if string(t[0])=="6" {
		x=6
	}
	if string(t1[0])=="T" {
		x1=11
	} else if string(t1[0])=="A" {
		x1=15
	} else if string(t1[0])=="K" {
		x1=14
	} else if string(t1[0])=="Q" {
		x1=13
	} else if string(t1[0])=="J" {
		x1=12
	} else if string(t1[0])=="9" {
		x1=9
	} else if string(t1[0])=="8" {
		x1=8
	} else if string(t1[0])=="7" {
		x1=7
	} else if string(t1[0])=="6" {
		x1=6
	}

	if string(t[1]) == string(ts) && string(t1[1])!=string(ts) {
		fmt.Println("YES")
	} else if string(t[1])!=string(ts) && string(t1[1])==string(ts) {
		fmt.Println("NO")
	} else if string(t[1])!=string(ts) && string(t1[1])!=string(ts) {
		if string(t[1])!=string(t1[1]) {
			fmt.Println("NO")
		} else {
			if x<=x1 {
				fmt.Println("NO")
			} else {
				fmt.Println("YES")
			}
		}
	} else if string(t[1])==string(ts) && string(t1[1])==string(ts) {
		if x<=x1 {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}
}


source_code:
// 121A
package main

import (
	"fmt"
)

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

func main() {
	var a [15]int64
	var i, l, r, x, j, n1, n2 int64
	x, j = 0, 1
	fmt.Scan(&l, &r)
	for i = 0; i <= 10; i++ {
		a[i] = 0
	}
	for j <= r {
		i = 10
		a[i]++
		for a[i] > 2 {
			a[i] = 0
			i--
			a[i]++
		}
		j = 0
		for i = 1; i <= 10; i++ {
			if j > 0 && a[i] == 0 {
				break
			}
			if a[i] == 1 {
				n1 = 4
			} else {
				n1 = 0
			}
			if a[i] == 2 {
				n2 = 7
			} else {
				n2 = 0
			}
			j = j*10 + n1 + n2
		}
		if x == 0 && j >= l {
			x += j
		}
		if i <= 10 {
			continue
		}
		if j >= l {
			x += (min(j, r) - l) * j
			l = j
		}
	}
	fmt.Print(x)
}


source_code:
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	var array [200]int
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &array[i])
	}
	sort.Ints(array[:n])
	var sum float64 = float64(4.5 * float64(n))

	for i := 0; i < n; i++ {
		sum -= float64(array[i])
		//	fmt.Printf("%d ", array[i])
	}
	//	fmt.Printf("%f\n", sum)
	if sum <= 0 {
		fmt.Printf("0\n")
		return
	} else {
		//	fmt.Printf("%f\n", sum)
		sum = -sum
		var result int = 0
		for i := 0; i < n; i++ {
			sum += float64(5 - array[i])
			result++
			//	fmt.Printf("%f", sum)
			if sum >= 0 {
				break
			}
		}
		fmt.Printf("%d\n", result)
	}

}


source_code:
package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	s.Scan()
	a := s.Text()
	var c int
	for i:=0; i<len(a) ; i++ {
		b := a[i] - '0'
		if 9 -b < b {
			if i==0 && b==9 {
				c=9
			} else {
				c = int(9 - b)
			}
		} else {
			c=int(b)
		}
		fmt.Print(c)
	}
}


source_code:
package main

import (
	"fmt"
)

func main() {
	var table[3][3]int

	for i := 0; i < 3; i++ {
		fmt.Scanf("%d %d %d\n", &table[i][0], &table[i][1], &table[i][2])
	}

	var sum int = 0
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			sum = 0
			if i-1 >= 0 {
				sum += table[i-1][j]
			}
			if i+1 < 3 {
				sum += table[i+1][j]
			}
			if j-1 >= 0 {
				sum += table[i][j-1]
			}
			if j+1 < 3 {
				sum += table[i][j+1]
			}
			sum += table[i][j]+1
			fmt.Printf("%d", sum%2)
		}
		fmt.Printf("\n")
	}
}


source_code:
//13A
package main
import "fmt"

func main() {
	var aa, k, l, ttl int
	fmt.Scan(&aa)
	for i:=2; i<aa; i++ {
		k=aa
		for k>0 {
			ttl=ttl+(k%i)
			k/=i
			if k<i {
				ttl=ttl+k
				break
			}
		}
	}
	l=aa-2
	for i:=l; i>1; i-- {
		if ttl%i==0 && l%i==0 {
			ttl/=i
			l/=i
			break
		}
	}
	fmt.Print(ttl,"/",l)
	fmt.Println()
}


source_code:
package main

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

var a [9]int64
var helper SHelper

func main() {
	helper.Init()

	for k := uint64(1); k <= 8; k++ {
		l := (1 << k) - 1 // shift count type int64, must be unsigned integer
		r := 1 << (k - 1)
		v := l * r
		a[k] = int64(v)
	}

	n := helper.ReadInt64()
	for k := int64(8); k >= 1; k-- {
		if n >= a[k] && n % a[k] == 0 {
			fmt.Println(a[k])
			return
		}
	}
}

type SHelper struct {
	file *os.File
	scanner *bufio.Scanner
}

func (this *SHelper) Init() {
	this.file = os.Stdin
	this.scanner = bufio.NewScanner(this.file)
	this.scanner.Split(bufio.ScanWords)
}

func (this *SHelper) ReadInt64() int64 {
	this.scanner.Scan()
	n, err:= strconv.ParseInt(this.scanner.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return n
}


source_code:
package main

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

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

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

	n := nextInt()

	a := make([]int, n)

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

	sort.Ints(a)

	for i := range a{
		print(a[i], " ")
	}
}

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


source_code:
package main

import (
	"fmt"
	"math"
)

var allLuckNumber[] int64

func dfs(dep int, number int64, num4, num7 int){
	if num4 == num7{
		allLuckNumber = append(allLuckNumber, number)
	}
	if dep > 10{
		return;
	}
	dfs(dep + 1, number * 10 + 4, num4 + 1, num7)
	dfs(dep + 1, number * 10 + 7, num4, num7 + 1)
}

func main(){
	var n, ans int64
	ans = math.MaxInt64
	dfs(0, 4, 1, 0)
	dfs(0, 7, 0 ,1)
	fmt.Scan(&n)
	for _,each := range allLuckNumber{
		if each >= n && each < ans{
			ans = each
		}
	}
	fmt.Println(ans)

}


source_code:
package main

import (
	"fmt"
)

type pair struct {
	location int
	dist     int
}

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

	if n >= m {
		fmt.Println(n - m)
	} else {
		visited := make([]bool, m+2)

		queue := make([]pair, 1)
		queue[0] = pair{n, 0}

		ans := 0
		visited[n] = true
		for {
			// pop front element
			tmp := queue[0]
			queue = queue[1:]
			// copy(queue[0:len(queue)-1], queue[1:])

			if tmp.location == m { // reached destination
				ans = tmp.dist
				break
			}

			// adist neighbors to the queue
			if tmp.location*2 <= m+1 && visited[tmp.location*2] == false {
				queue = append(queue, pair{tmp.location * 2, tmp.dist + 1})
				visited[tmp.location*2] = true
			}
			if tmp.location-1 >= 0 && visited[tmp.location-1] == false {
				queue = append(queue, pair{tmp.location - 1, tmp.dist + 1})
				visited[tmp.location-1] = true
			}
		}

		fmt.Println(ans)
	}
}


source_code:
package main

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

var (
	bufin  = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
)

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

/*
f(x) = 2*x - .5
4*x - 1.5
2^(n+1) x - (2^n - 1)
*/

const M = 1000000007

func main() {
	defer bufout.Flush()
	var N, K uint64
	scanf("%d%d", &N, &K)
	if N == 0 {
		printf("0\n")
		return
	}
	N = (2*N - 1) % M
	z := getx(K)
	printf("%d\n", (int64(z)*int64(N)+1)%M)
}

func getx(N uint64) int {
	if N < 30 {
		return 1 << N
	}
	if N%2 == 0 {
		Y := getx(N >> 1)
		return int(int64(Y) * int64(Y) % M)
	}
	return getx(N-1) * 2 % M
}


source_code:
package main

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

const Mod = 998244353

func main() {
	defer _w.Flush()
	solve()
}
func solve() {
	n, x := ReadInt(), ReadInt()

	var pow [501][501]int64
	for i := int64(0); i < 501; i++ {
		pow[i][0] = 1
		for j := 0; j < 500; j++ {
			pow[i][j+1] = pow[i][j] * i % Mod
		}
	}

	var dp [501][501]int64
	for i := 2; i <= n; i++ {
		jj := Min(x, i-1)
		for j := 1; j <= jj; j++ {
			// dp[i][j] = j^i - (j-1)^i
			dp[i][j] = pow[j][i] - pow[j-1][i]
			dp[i][j] %= Mod
		}
	}

	for i := 2; i <= n; i++ {
		for j := 1; j <= x; j++ {
			if dp[i][j] == 0 {
				continue
			}
			for k := 0; k <= n-i; k++ {
				nj := j + i + k - 1
				if nj > x {
					break
				}
				dp[i+k][nj] += dp[i][j] * pow[i+k-1][k] % Mod * ModCombination(i+k, k)
				dp[i+k][nj] %= Mod
			}
		}
	}

	ans := int64(0)
	for j := 1; j <= x; j++ {
		ans += dp[n][j]
		ans %= Mod
	}
	println(((ans % Mod) + Mod) % Mod)
}

func ModCombination(n, k int) (ret int64) {
	if n < k {
		return 0
	}
	for ret = 1; n > 0 || k > 0; n, k = n/Mod, k/Mod {
		ret = ret * fac[n%Mod] % Mod * finv[k%Mod] % Mod * finv[(n-k)%Mod] % Mod
	}
	return
}

const MAX = 500

var fac, finv, inv [MAX + 1]int64

func init() {
	fac[int64(0)], fac[int64(1)], finv[int64(0)], finv[int64(1)], inv[int64(1)] = int64(1), int64(1), int64(1), int64(1), int64(1)
	for i := int64(2); i <= MAX; i++ {
		fac[i], inv[i] = fac[i-int64(1)]*i%Mod, Mod-inv[Mod%i]*(Mod/i)%Mod
		finv[i] = finv[i-int64(1)] * inv[i] % Mod
	}
}

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

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

func ReadString() (s string)   { fmt.Fscan(_r, &s); return }
func ReadInt() (i int)         { fmt.Fscan(_r, &i); return }
func print(a ...interface{})   { fmt.Fprint(_w, a...) }
func println(a ...interface{}) { fmt.Fprintln(_w, a...) }
func prints(s []int64)         { v := fmt.Sprint(s); println(v[int64(1) : int64(len(v))-int64(1)]) }


source_code:
package main

import (
	"fmt"
	"sort"
)

func next_permutation(idx []int) bool {
	n := len(idx)
	for i := n - 1; i >= 1; i-- {
		if idx[i] > idx[i-1] {
			idx[i], idx[i-1] = idx[i-1], idx[i]
			sort.Ints(idx[i:])
			return true
		}
	}

	return false
}

func main() {
	var n, a, b int
	fmt.Scanf("%d\n%d\n%d", &n, &a, &b)
	frames := make([]int, 6)
	idxs := make([]int, 6)
	for i := 0; i < 6; i++ {
		if i < 4 {
			frames[i] = a
		} else {
			frames[i] = b
		}
		idxs[i] = i
	}

	bestAnswer := 6
	for {
		count, leftover := 0, 0
		for i := 0; i < 6; i++ {
			if leftover < frames[idxs[i]] {
				count++
				leftover = n
			}
			leftover -= frames[idxs[i]]
		}
		if count < bestAnswer {
			bestAnswer = count
		}
		if !next_permutation(idxs) {
			break
		}
	}

	fmt.Println(bestAnswer)
}


source_code:
// 219B
package main

import (
	"fmt"
)

func main() {
	var p, d, t, ans int64
	fmt.Scan(&p, &d)
	p++
	ans = p
	for t = 10; ; t *= 10 {
		if p%t > d {
			break
		}
		ans = p - p%t
	}
	fmt.Print(ans - 1)
}


source_code:
package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n, m, h := 0, 0, 0
	fmt.Fscanf(in, "%d %d %d\n", &n, &h, &m)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = h
	}
	for i := 0; i < m; i++ {
		l, r, res := 0, 0, 0
		fmt.Fscanf(in, "%d %d %d\n", &l, &r, &res)
		l--
		r--
		for j := l; j <= r; j++ {
			//fmt.Println(j)
			if a[j] > res {
				a[j] = res
			}
		}
	}
	ans := 0
	for i := 0; i < n; i++ {
		ans += a[i] * a[i]
	}
	//fmt.Println(odd1, odd2, even1, even2)
	fmt.Fprintf(out, "%d\n", ans)
	return
}
func minstep(a, b byte) int {
	return min(int(a-b+26)%26, int(b-a+26)%26)
}

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


source_code:
package main

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

/*
1
1 1
1 2
2 1
2 3
---
0
0
2 [0,1], [1,0]
X [0,7], [7,0],

*/

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

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

	for ; t > 0; t-- {
		var n, k int64
		scanf("%d %d\n", &n, &k)

		ans := big.NewInt(0).Exp(big.NewInt(n), big.NewInt(k), big.NewInt(1e9+7)).Int64()

		fmt.Fprintln(writer, ans)
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int) int {
	quot := num / div
	if num%div != 0 {
		quot++
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	minimum := nums[0]
	for _, num := range nums {
		if num < minimum {
			minimum = num
		}
	}
	return minimum
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	maximum := nums[0]
	for _, num := range nums {
		if num > maximum {
			maximum = num
		}
	}
	return maximum
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}


source_code:
package main

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

func cube(x int) int64 {
	return int64(x) * int64(x) * int64(x)
}

func foo(n int64) int64 {
	var ans int64
	for k := 2; ; k++ {
		x := n / cube(k)
		if x == 0 {
			break
		}
		ans += x
	}
	return ans
}

// najmniejszy argument, dla ktorego f(arg) zwraca prawde
// funkcja logiczna powinna byc niemalejaca
func bin_search(f func(int64) bool, lo, up, eps int64) int64 {
	up++
	cnt := up - lo
	var mid, step int64
	for cnt >= eps {
		step = cnt / 2
		mid = lo + step
		if !f(mid) {
			lo = mid + eps
			cnt -= step + eps
		} else {
			cnt = step
		}
	}
	return lo
}

func main() {
	m := getInt64()
	mx := int64(4949100894494448)
	x := func(n int64) bool {
		return foo(n) >= m
	}

	p := bin_search(x, 1, mx, 1)

	if foo(p) != m {
		p = -1
	}

	fmt.Println(p)
}

type Input struct {
	*bufio.Scanner
}

var globalInput = wrapStdin()

func wrapStdin() Input {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return Input{Scanner: sc}
}
func getInt64() int64 {
	globalInput.Scan()
	x, _ := strconv.ParseInt(globalInput.Text(), 10, 64)
	return x
}
func getInt() int {
	globalInput.Scan()
	x, _ := strconv.Atoi(globalInput.Text())
	return x
}
func getIntOk() (int, bool) {
	ok := globalInput.Scan()
	x, _ := strconv.Atoi(globalInput.Text())
	return x, ok
}
func getNint(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		v[i] = getInt()
	}
	return v
}
func getVint(v []int) bool {
	var ok bool
	for i := 0; i < len(v); i++ {
		v[i], ok = getIntOk()
	}
	return ok
}
func getWord() string {
	globalInput.Scan()
	return globalInput.Text()
}
func getWordOk() (string, bool) {
	ok := globalInput.Scan()
	return globalInput.Text(), ok
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func minStr(a, b string) string {
	if a < b {
		return a
	}
	return b
}
func maxStr(a, b string) string {
	if a < b {
		return b
	}
	return a
}
func remin(a *int, b int) bool {
	if b < *a {
		*a = b
		return true
	}
	return false
}
func remax(a *int, b int) bool {
	if b > *a {
		*a = b
		return true
	}
	return false
}
func remin64(a *int64, b int64) bool {
	if b < *a {
		*a = b
		return true
	}
	return false
}
func remax64(a *int64, b int64) bool {
	if b > *a {
		*a = b
		return true
	}
	return false
}
func reminStr(a *string, b string) bool {
	if b < *a {
		*a = b
		return true
	}
	return false
}
func remaxStr(a *string, b string) bool {
	if b > *a {
		*a = b
		return true
	}
	return false
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}
func abs64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

type (
	FLess    func(i, j int) bool
	FSwap    func(i, j int)
	wrapSort struct {
		Length int
		FLess
		FSwap
	}
)

func (w *wrapSort) Len() int           { return w.Length }
func (w *wrapSort) Less(i, j int) bool { return w.FLess(i, j) }
func (w *wrapSort) Swap(i, j int)      { w.FSwap(i, j) }
func wsort(length int, fless func(i, j int) bool, fswap func(i, j int)) {
	sort.Sort(&wrapSort{length, fless, fswap})
}


source_code:
package main

import (
	"fmt"
	"sort"
)

const mod = 998244353
const N = 5000

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

func comb(m int, n int) int64 {
	res := int64(1)
	fnm := make([]int, len(primes))
	copy(fnm, factor[n])
	for i, x := range factor[m] {
		fnm[i] += x
	}
	for w := 1; w <= m; w++ {
		r := int64(1)
		for i, p := range primes {
			for pw := fnm[i] - factor[w][i] - factor[n-w][i] -
				factor[m-w][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)
	sieve := [N + 1]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]++
			}
		}
	}
	a := factor[0]
	for _, b := range factor {
		for i, x := range a {
			b[i] += x
		}
		a = b
	}
	fmt.Println(comb(abc[0], abc[1]) * comb(abc[0], abc[2]) % mod * comb(abc[1], abc[2]) % mod)
}


source_code:
package main

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

const INF  = 1000000001

type Pair struct {
	first, second int
}

func sort(arr []int) []int {
	if len(arr) < 2 {
		return arr
	}
	left := 0
	right := len(arr) - 1
	pivot := len(arr) / 2

	arr[pivot], arr[right] = arr[right], arr[pivot]

	for i := 0; i < len(arr); i++ {
		if arr[i] < arr[right] {
			arr[i], arr[left] = arr[left], arr[i]
			left++
		}
	}

	arr[left], arr[right] = arr[right], arr[left]

	sort(arr[:left])
	sort(arr[left+1:])
	return arr
}

func check(n int) bool {
	var s int
	for n > 0 {
		s += n % 10
		n /= 10
	}
	return s == 10
}

func solution(reader io.Reader, writer io.Writer) {
	var k int
	fmt.Fscanf(reader, "%d\n", &k)
	for i := 19; k > 0; i++ {
		if check(i) {
			k--
		}
		if k == 0 {
			fmt.Println(i)
			return
		}
	}
}

func main() {

	//stdin, err := os.Open("file.in")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdin.Close()
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)

	//stdout, err := os.Create("file.out")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdout.Close()
	stdout := os.Stdout
	writer := bufio.NewWriterSize(stdout, 1024*1024)
	defer writer.Flush()

	solution(reader, writer)
}


source_code:
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)

	v1, v2, t, d := nextInt(), nextInt(), nextInt(), nextInt()
	path, maxSpeed := 0, 0

	for ; t > 0; t-- {
		path += v1
		maxSpeed = v2+d*(t-2)
		// println(path, v1, maxSpeed)

		if maxSpeed > v1 {
			if v1+d > maxSpeed {
				v1 = maxSpeed
			} else {
				v1 += d
			}
		} else if maxSpeed < v1 {
			if v1-d < maxSpeed {
				v1 = maxSpeed
			} else {
				v1 -= d
			}
		}
	}

	println(path)
}

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

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	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 printf(format string, a ...interface{}) {
	fmt.Fprintf(writer, format, a...)
}


source_code:
package main

import (
	"fmt"
)

func main() {
	var n int
	var x, y int64
	fmt.Scan(&n, &x, &y)
	dp := make([]int64, 2*n+1)
	dp[1] = x;
	for i := 2; i <= n; i++ {
		dp[i] = min(dp[i-1]+x, dp[(i+1)/2]+y+int64(i%2)*x)
		dp[i-1] = min(dp[i-1], dp[i]+x)
	}

	fmt.Println(dp[n])
}

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


source_code:
package main

import (
	"fmt"
)

func main() {
	var n, ans int
	fmt.Scanln(&n)

	a := make([]int, n)
	x := make([]interface{}, n)
	for i := range a {
		x[i] = &a[i]
	}
	fmt.Scanln(x...)

	for i := 0; i < n; i++ {
		ans += a[i]
	}
	ans /= n
	fmt.Println(ans)
}


source_code:
package main

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

func main() {
	var line string
	var max int64
	var start [14]int64
	var end [14]int64
	reader := bufio.NewReader(os.Stdin)
	line, _ = reader.ReadString('\n')
	arrStartStrings := strings.Split(strings.TrimSpace(line), " ")
	for i, v := range arrStartStrings {
		start[i], _ = strconv.ParseInt(v, 10, 0)
	}
	for i := 0; i < 14; i++ {
		end[i] = igra(start, i)
	}
	for i := 0; i < 14; i++ {
		if max < end[i]{
			max=end[i]
		}
	}
	fmt.Println(max)
}

func igra(start [14]int64, i int) int64 {
	var n, addToAll, result int64
	n = start[i]
	start[i] = 0
	if n == 0 {
		return 0
	}
	addToAll = n / 14
	n = n % 14
	for i := 0; i < 14; i++ {
		start[i] += addToAll
	}
	for n != 0 {
		if i+1 == 14 {
			i = 0
		} else {
			i++
		}
		start[i]++
		n--
	}
	for i := 0; i < 14; i++ {
		if start[i]%2==0{
			result+=start[i]
		}
	}
	return result
}


source_code:
package main
import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	d:=n%10
	if d>=5 {
		fmt.Print("-O|")
	} else {
		fmt.Print("O-|")
	}
	d%=5
	for i:=0;i<d;i++ {
		fmt.Print("O")
	}
	fmt.Print("-")
	for i:=4-d;i>0;i-- {
		fmt.Print("O")
	}
	fmt.Println()
	n/=10

	for ;n>0; {
		d:=n%10
	if d>=5 {
		fmt.Print("-O|")
	} else {
		fmt.Print("O-|")
	}
	d%=5
	for i:=0;i<d;i++ {
		fmt.Print("O")
	}
	fmt.Print("-")
	for i:=4-d;i>0;i-- {
		fmt.Print("O")
	}
	fmt.Println()
	n/=10
	}
}


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

var n, m, mod int64
var matrix [][]int

func multiply(one, two [][]int) [][]int {
	res := make([][]int, m)
	for i := 0; i < int(m); i++ {
		res[i] = make([]int, m)
	}
	for i := 0; i < int(m); i++ {
		for j := 0; j < int(m); j++ {
			for k := 0; k < int(m); k++ {
				res[i][j] += int(int64(one[i][k]) * int64(two[k][j]) % mod)
				res[i][j] %= int(mod)
			}
		}
	}
	return res
}

func power(exp int64, base [][]int) [][]int {

	if exp == 1 {
		return base
	}

	res := power(exp/2, base)
	res = multiply(res, res)
	if exp&1 == 1 {
		res = multiply(res, base)
	}
	return res
}

func main() {
	defer writer.Flush()
	mod = 1000000007
	scanf("%d %d\n", &n, &m)
	if n < m {
		printf("1")
		return
	}
	if n == m {
		printf("2")
		return
	}
	matrix = make([][]int, m)
	for i := 0; i < int(m); i++ {
		matrix[i] = make([]int, m)
	}
	matrix[0][0] = 1
	matrix[0][m-1] = 1
	for i := 1; i < int(m); i++ {
		matrix[i][i-1] = 1
	}

	fmt.Println(power(n, matrix)[0][0])

}


source_code:
package main

import (
	"fmt"
)

func main() {
	// Read input.
	var N int
	fmt.Scan(&N)
	a := make([]int, N)
	for i := 0; i < N; i++ {
		var tmp int
		fmt.Scan(&tmp)
		a[i] = tmp
	}
	// Start solving.
	if N == 1 && a[0] == 0 {
		fmt.Println("UP")
		return
	}
	if N == 1 && a[0] == 15 {
		fmt.Println("DOWN")
		return
	}
	if N == 1 && a[0] != 0 && a[0] != 15 {
		fmt.Println(-1)
		return
	}
	// From here I assume a has more than two elements.
	if a[N-2] > a[N-1] && a[N-1] != 0 {
		fmt.Println("DOWN")
		return
	}
	if a[N-2] < a[N-1] && a[N-1] != 15 {
		fmt.Println("UP")
		return
	}
	if a[N-1] == 0 {
		fmt.Println("UP")
		return
	}
	if a[N-1] == 15 {
		fmt.Println("DOWN")
		return
	}
}