iidai/codenet huggingface dataset:
Language: Go

package main

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

func main() {
	INF := int(math.Pow10(11))
	A := nextInt()
	B := nextInt()
	Q := nextInt()
	s := make([]int, A+2)
	s[0], s[A+1] = -INF, INF
	for i := 1; i <= A; i++ {
		s[i] = nextInt()

	}

	t := make([]int, B+2)
	t[0], t[B+1] = -INF, INF
	for i := 1; i <= B; i++ {
		t[i] = nextInt()
	}

	for i := 0; i < Q; i++ {
		x := nextInt()
		b, d := sort.SearchInts(s, x), sort.SearchInts(t, x)
		res := INF
		for _, S := range []int{s[b-1], s[b]} {
			for _, T := range []int{t[d-1], t[d]} {
				d1, d2 := abs(S-x)+abs(T-S), abs(T-x)+abs(S-T)
				res = min(res, min(d1, d2))
			}
		}

		fmt.Println(res)
	}
}

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextFloat() float64 {
	sc.Scan()
	f64, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}

	return f64
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}


Example test case(s):
input: 2 3 4
100
600
400
900
1000
150
2000
899
799

output: 350
1400
301
399
Language: Go

package main

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

func main() {
	N, K := ReadInt(), ReadInt()
	As := ReadInts(N)
	Fs := ReadInts(N)

	sort.Ints(As)
	sort.Sort(sort.Reverse(sort.IntSlice(Fs)))
	scores := make([]int, N)
	for i := 0; i < N; i++ {
		scores[i] = As[i] * Fs[i]
	}
	sort.Sort(sort.Reverse(sort.IntSlice(scores)))

	ok := scores[0]
	ng := -1
	for ok-ng > 1 {
		mid := (ok + ng) / 2

		isOK := true
		k := K
		for i := 0; isOK && i < N; i++ {
			if As[i]*Fs[i] > mid {
				k -= As[i] - mid/Fs[i]
			}
			if k < 0 {
				isOK = false
			}
		}

		if isOK {
			ok = mid
		} else {
			ng = mid
		}

	}
	fmt.Println(ok)
}

func ReadInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = ReadInt()
	}
	return ret
}

var sc = bufio.NewScanner(os.Stdin)

func init()        { sc.Buffer(make([]byte, 256), 1e9); sc.Split(bufio.ScanWords) }
func Read() string { sc.Scan(); return sc.Text() }

func ReadInt() int {
	v, e := strconv.Atoi(Read())
	if e != nil {
		panic(e.Error())
	}
	return v
}


Example test case(s):
input: 3 5
4 2 1
2 3 1

output: 2
Language: Go

package main

import "fmt"

func main() {
	var x int
	fmt.Scan(&x)
	fmt.Println(x * x * x)
}


Example test case(s):
input: 2

output: 8
Language: Go

package main

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

func main() {
	var N int
	fmt.Scan(&N)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	v := make([]int, N)
	var a int

	for i := 1; i < N; i++ {
		scanner.Scan()
		a, _ = strconv.Atoi(scanner.Text())
		v[a-1]++
	}

	w := bufio.NewWriter(os.Stdout)
	for _, e := range v {
		fmt.Fprintln(w, e)
	}
	w.Flush()

}


Example test case(s):
input: 5
1 1 2 2

output: 2
2
0
0
0
Language: Go

package main

import "fmt"

func main() {

	var r, D, x int
	fmt.Scan(&r, &D, &x)

	for i := 1; i <= 10; i++ {
		fmt.Println(r*x - D)
		x = r*x - D
	}
}


Example test case(s):
input: 2 10 20

output: 30
50
90
170
330
650
1290
2570
5130
10250
Language: Go

package main

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

var (
	s string
)

func main() {
	fmt.Scan(&s)

	for i := 0; i < len(s); i++ {
		if strings.Contains(s[i+1:], string(s[i])) {
			fmt.Println("no")
			os.Exit(0)
		}
	}

	fmt.Println("yes")
}


Example test case(s):
input: uncopyrightable

output: yes
Language: Go

package main

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

func genid(a, b int) int {
	if b < a {
		a, b = b, a
	}
	return a*100000 + b
}

func main() {
	N := readInt()

	ab := make([][2]int, N-1)
	edges := make([][]int, N)
	for i := 0; i < N-1; i++ {
		a := readInt() - 1
		b := readInt() - 1
		ab[i][0], ab[i][1] = a, b
		edges[a] = append(edges[a], b)
		edges[b] = append(edges[b], a)
	}

	colors := make(map[int]int)
	q := make([][3]int, 0)
	q = append(q, [3]int{0, -1, -1})
	for len(q) != 0 {
		currentNode, usedColor, parentNode := q[len(q)-1][0], q[len(q)-1][1], q[len(q)-1][2]
		q = q[:len(q)-1]
		color := 1
		for _, childNode := range edges[currentNode] {
			if childNode == parentNode {
				continue
			}
			if color == usedColor {
				color++
			}
			colors[genid(currentNode, childNode)] = color
			q = append(q, [3]int{childNode, color, currentNode})
			color++
		}
	}

	K := -1
	for i := 0; i < N; i++ {
		t := len(edges[i])
		if t > K {
			K = t
		}
	}
	fmt.Println(K)

	for i := 0; i < N-1; i++ {
		fmt.Println(colors[genid(ab[i][0], ab[i][1])])
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

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

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Example test case(s):
input: 3
1 2
2 3

output: 2
1
2
Language: Go

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	ans := 0
	for i := 1; i*i < n; i++ {
		if n%i == 0 && n%(n/i-1) == i {
			ans += n/i - 1
		}
	}
	fmt.Println(ans)
}


Example test case(s):
input: 8

output: 10
Language: Go

package main

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

func Run(r io.Reader, w io.Writer) {
	sc := NewScanner(r)

	a := sc.ReadLine().Ints()
	N, D := a[0], a[1]

	lines := sc.ReadLines(N).Ints()

	count := 0
	for _, line := range lines {
		d := math.Sqrt(float64(line[0]*line[0] + line[1]*line[1]))
		if float64(D) >= d {
			count++
		}
	}
	fmt.Fprintln(w, count)
}

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner(r io.Reader) *Scanner {
	return &Scanner{sc: bufio.NewScanner(r)}
}

func (s *Scanner) ReadLine() Value {
	if s.sc.Scan() {
		return Value(s.sc.Text())
	}
	panic("scan error")
}

func (s *Scanner) ReadLines(n int) Values {
	var a Values
	for i := 0; i < n; i++ {
		a = append(a, s.ReadLine())
	}
	return a
}

type Value string

func (v Value) String() string {
	return string(v)
}

func (v Value) Int() int {
	n, err := strconv.Atoi(v.String())
	if err != nil {
		panic(err)
	}
	return n
}

func (v Value) Float64() float64 {
	f, err := strconv.ParseFloat(v.String(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func (v Value) Strings() []string {
	return strings.Split(v.String(), " ")
}

func (v Value) Ints() []int {
	var a []int
	for _, s := range v.Strings() {
		n, err := strconv.Atoi(s)
		if err != nil {
			panic(err)
		}
		a = append(a, n)
	}
	return a
}

func (v Value) Float64s() []float64 {
	var a []float64
	for _, s := range v.Strings() {
		f, err := strconv.ParseFloat(s, 64)
		if err != nil {
			panic(err)
		}
		a = append(a, f)
	}
	return a
}

func (v Value) Runes() []rune {
	return []rune(v.String())
}

type Values []Value

func (v Values) Strings() [][]string {
	var a [][]string
	for _, value := range v {
		a = append(a, value.Strings())
	}
	return a
}

func (v Values) Ints() [][]int {
	var a [][]int
	for _, value := range v {
		a = append(a, value.Ints())
	}
	return a
}

func (v Values) Float64s() [][]float64 {
	var a [][]float64
	for _, value := range v {
		a = append(a, value.Float64s())
	}
	return a
}

func (v Values) Runes() [][]rune {
	var a [][]rune
	for _, value := range v {
		a = append(a, value.Runes())
	}
	return a
}


Example test case(s):
input: 4 5
0 5
-2 4
3 4
4 -4

output: 3
Language: Go

package main

import "fmt"

var e [][]int
var n, m int

func printEdge(e [][]int) {
	for i := 1; i < n+1; i++ {
		fmt.Printf("%d: ", i)
		for _, v := range e[i] {
			fmt.Printf("%d ", v)
		}
		fmt.Println()
	}
}

func dfs(v int, visited []bool) int {

	comp := true
	for i := 1; i < n+1; i++ {
		if !visited[i] {
			comp = false
		}
	}

	if comp {
		return 1
	}

	count := 0
	for _, ne := range e[v] {

		if visited[ne] {
			continue
		}
		visited[ne] = true

		rst := dfs(ne, visited)

		count += rst
		visited[ne] = false
	}
	return count
}

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

	e = make([][]int, n+1)
	for i := 1; i < n+1; i++ {
		e[i] = make([]int, 0)
	}
	for i := 0; i < m; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		e[a] = append(e[a], b)
		e[b] = append(e[b], a)
	}

	visited := make([]bool, n+1)
	visited[1] = true
	count := dfs(1, visited)
	fmt.Println(count)
}


Example test case(s):
input: 3 3
1 2
1 3
2 3

output: 2
Language: Go

package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	switch S {
	case "Sunny":
		fmt.Println("Cloudy")
	case "Cloudy":
		fmt.Println("Rainy")
	case "Rainy":
		fmt.Println("Sunny")

	}
}


Example test case(s):
input: Sunny

output: Cloudy
Language: Go

package main

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

var inf int = 1e14

func main() {
	log.SetFlags(log.Lshortfile)
	next := newScanner()
	n := next.Int()
	x := next.Int()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = next.Int()
	}
	v := make([]int, n)
	copy(v, a)
	ans := inf
	for k := 0; k < n; k++ {
		kans := 0
		for i := 0; i < n; i++ {
			if i-k < 0 {
				v[i] = min(v[i], a[n+i-k])
			} else {
				v[i] = min(v[i], a[i-k])
			}
			kans += v[i]
		}
		ans = min(ans, kans+k*x)
	}

	fmt.Println(ans)
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a < p[j].a {
		return true
	} else if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return false
}

func in(c, a, z int) bool {
	return c >= a && c < z
}

func btoi(b bool) int {
	if b {
		return 1
	}
	return 0
}

func itob(a int) bool {
	if a == 0 {
		return false
	}
	return true
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

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

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

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

func sum(a ...int) int {
	r := a[0]
	if len(a) > 1 {
		for i := 1; i < len(a); i++ {
			r += a[i]
		}
	}
	return r
}

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

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	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) Line() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) Int() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) Int64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
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
		}
	}
}


Example test case(s):
input: 2 10
1 100

output: 12
Language: Go

package main

import "fmt"

func main() {
	var a string
	fmt.Scan(&a)
	var ans = "Good"
	for i := 0; i < 3; i++ {
		if a[i] == a[i+1] {
			ans = "Bad"
		}
	}
	fmt.Println(ans)
}


Example test case(s):
input: 3776

output: Bad
Language: Go

package main

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

func main() {
	fsc := NewFastScanner()
	A, B, C := fsc.NextInt(), fsc.NextInt(), fsc.NextInt()
	if B-A == C-B {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

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

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
}

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
}


Example test case(s):
input: 2 4 6

output: YES
Language: Go

package main

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

type Block struct {
	Value string
	Len   int
}

func main() {
	var N, K, ans int
	fmt.Scan(&N, &K)
	var S string
	s := bufio.NewScanner(os.Stdin)
	b := make([]byte, 1000000)
	s.Buffer(b, 1000000)
	s.Scan()
	S = s.Text()
	blocks := RunLength(S)
	sum, zero, l := 0, 0, 0
	for r := 0; r < len(blocks); r++ {
		sum += blocks[r].Len
		if blocks[r].Value == "0" {
			zero++
		}
		for K < zero {
			sum -= blocks[l].Len
			if blocks[l].Value == "0" {
				zero--
			}
			l++
		}
		ans = Max(ans, sum)
	}
	fmt.Println(ans)
}

func RunLength(s string) []Block {
	var r []Block
	if len(s) == 0 {
		return r
	}
	t := Block{Value: string(s[0]), Len: 1}
	for _, v := range s[1:] {
		if t.Value == string(v) {
			t.Len++
		} else {
			r = append(r, t)
			t = Block{Value: string(v), Len: 1}
		}
	}
	r = append(r, t)
	return r
}

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


Example test case(s):
input: 5 1
00010

output: 4
Language: Go

package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	k := sc.ReadInt()

	total := int64(0)
	for i := k; i <= n+1; i++ {
		total += combi(n, i)
		total = total % (Pow64(10, 9) + 7)
	}
	fmt.Println(total)
}

func combi(n int, k int) int64 {
	min := int64(k-1) * int64(k) / 2
	max := int64(2*n-k+1) * int64(k) / 2
	return max - min + 1
}

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Abs64(x int64) int64 {
	if x >= 0 {
		return x
	}
	return -x
}

func Min64(values ...int64) int64 {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max64(values ...int64) int64 {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow64(base int64, exponent uint) int64 {
	answer := int64(1)
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *Scanner) ReadInt64() int64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseInt(text, 10, 64)
	if err != nil {
		panic(err)
	}
	return num
}


Example test case(s):
input: 3 2

output: 10
Language: Go

package main

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

const mod = 998244353
const facNum = 300001

func main() {
	sc := newScanner(os.Stdin)
	N := sc.i()
	sum := 0
	for i := 1; i <= N; i++ {
		if i%3 == 0 || i%5 == 0 {
			continue
		}
		sum += i
	}
	fmt.Println(sum)
}

type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}

func Pow(a, n int) int {
	ans := 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = ans * a % mod
		}
		a = a * a % mod
		n = n >> 1
	}
	return ans
}

func Gcd(a, b int) int {
	if a < b {
		return Gcd(b, a)
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

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

func combination(n, k int, fac, ifac []int) int {
	if n < k || n < 0 {
		return 0
	}
	if k == 0 {
		return 1
	}

	ans := ifac[k] * ifac[n-k] % mod
	return ans * fac[n] % mod
}

func factorial() (fac []int, ifac []int) {
	fac = make([]int, facNum)
	fac[0] = 1
	ifac = make([]int, facNum)
	ifac[0] = 1
	for i := 1; i < facNum; i++ {
		fac[i] = fac[i-1] * i % mod
		ifac[i] = ifac[i-1] * Pow(i, mod-2) % mod
	}
	return
}

func lowerBound(vs []int, v int) (index int) {
	n := len(vs) / 2
	m := len(vs)
	for m != n {
		if vs[n] < v {
			n = (m-n+1)/2 + n

		} else {
			m = n
			n = n / 2
		}
	}
	return n
}

func IntSlice(n, init int) []int {
	r := make([]int, n)
	for i := range r {
		r[i] = init
	}
	return r
}


Example test case(s):
input: 15

output: 60
Language: Go

package main

import (
	"fmt"
	"math"
)

func main() {
	var n float64
	var k float64
	fmt.Scan(&n, &k)

	var x float64 = 0.0
	for {
		under := math.Pow(k, x)
		upper := math.Pow(k, x+1)

		if under <= n && n < upper {
			fmt.Println(x + 1)
			return
		}
		x++
	}

}


Example test case(s):
input: 11 2

output: 4
Language: Go

package main

import (
	"fmt"
)

func solution(n, m int) int {
	n = n - 2
	m = m - 2
	if n < 0 {
		n = 1
	}
	if m < 0 {
		m = 1
	}
	return n * m
}

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


Example test case(s):
input: 2 2

output: 0
Language: Go

package main

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

type node struct {
	key    int
	parent *node
	left   *node
	right  *node
}

type tree struct {
	root *node
}

func (tree *tree) insert(key int) {
	if tree.root == nil {
		tree.root = &node{key: key}
		return
	}

	var currentNode, prevNode *node
	currentNode = tree.root
	for currentNode != nil {
		prevNode = currentNode
		if currentNode.key < key {
			currentNode = currentNode.right
		} else {
			currentNode = currentNode.left
		}
	}

	newNode := &node{key: key}
	newNode.parent = prevNode
	if prevNode.key < key {
		prevNode.right = newNode
	} else {
		prevNode.left = newNode
	}
}

func (tree tree) print() {
	var acc []int
	if tree.root == nil {
		fmt.Println("")
		fmt.Println("")
	} else {
		fmt.Println(" " + strings.Join(isToAs(visitInorder(tree.root, acc)), " "))
		fmt.Println(" " + strings.Join(isToAs(visitPreorder(tree.root, acc)), " "))
	}
}

func visitPreorder(node *node, acc []int) []int {
	if node == nil {
		return acc
	}
	acc = append(acc, int(node.key))
	if node.left != nil {
		acc = visitPreorder(node.left, acc)
	}
	if node.right != nil {
		acc = visitPreorder(node.right, acc)
	}
	return acc
}

func visitInorder(node *node, acc []int) []int {
	if node == nil {
		return acc
	}
	if node.left != nil {
		acc = visitInorder(node.left, acc)
	}
	acc = append(acc, int(node.key))
	if node.right != nil {
		acc = visitInorder(node.right, acc)
	}
	return acc
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}

	tree := &tree{}
	for i := 0; i < n; i++ {
		command := nextText(sc)
		switch command {
		case "insert":
			key, err := nextInt(sc)
			if err != nil {
				panic(err)
			}
			tree.insert(key)
		case "print":
			tree.print()
		default:
			panic("unknown command: " + command)
		}
	}
}

func nextText(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextInt(sc *bufio.Scanner) (int, error) {
	return strconv.Atoi(nextText(sc))
}

func isToAs(is []int) []string {
	n := len(is)
	as := make([]string, n)
	for i := 0; i < n; i++ {
		as[i] = strconv.Itoa(is[i])
	}
	return as
}


Example test case(s):
input: 8
insert 30
insert 88
insert 12
insert 1
insert 20
insert 17
insert 25
print

output:  1 12 17 20 25 30 88
 30 12 1 20 17 25 88
Language: Go

package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	if a*b%2 == 0 {
		fmt.Println("Even")
	} else {
		fmt.Println("Odd")
	}
}


Example test case(s):
input: 3 4

output: Even
Language: Go

package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)

func NextLine() string {
	var line, buffer []byte
	var isPrefix bool = true
	var err error
	for isPrefix {
		line, isPrefix, err = reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
	}
	return string(buffer)
}
func NextInt() int {
	var n int
	n, _ = strconv.Atoi(NextLine())
	return n
}
func Write(s interface{}) {
	fmt.Fprintln(writer, s)
}
func Output() {
	_ = writer.Flush()
}

func Bipartite(S *[]string) bool {
	N := len((*S))
	D := make([]int, N)
	D[0] = 1
	Q := make([]int, N)
	ret := true
	pos := 1
	for i := 0; i < N; i++ {
		if !ret {
			break
		}
		q := Q[i]
		for j, s := range (*S)[q] {
			if s == '0' {
				continue
			}
			if D[j] == 0 {
				D[j] = D[q] + 1
				Q[pos] = j
				pos++
				continue
			}
			if D[j]%2 == D[q]%2 {
				ret = false
				break
			}
		}
	}
	return ret
}

func WarshallFloyd(S *[]string) int {
	N := len(*(S))
	G := make([][]int, N)
	for i := range G {
		G[i] = make([]int, N)
		for j := range G[i] {
			if i == j {
				continue
			}
			if (*S)[i][j] == '0' {
				G[i][j] = N
			} else {
				G[i][j] = 1
			}
		}
	}
	for k := 0; k < N; k++ {
		for i := 0; i < N; i++ {
			for j := 0; j < N; j++ {
				if G[i][k]+G[k][j] < G[i][j] {
					G[i][j] = G[i][k] + G[k][j]
				}
			}
		}
	}
	ans := 0
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			if ans < G[i][j] {
				ans = G[i][j]
			}
		}
	}
	return ans + 1
}

func main() {
	N := NextInt()
	S := make([]string, N)
	for i := range S {
		S[i] = NextLine()
	}
	if !Bipartite(&S) {
		Write(-1)
	} else {
		Write(WarshallFloyd(&S))
	}
	Output()
}


Example test case(s):
input: 2
01
10

output: 2