Mahmoud has n line segments, the i-th of them has length ai. Ehab challenged him to use exactly 3 line segments to form a non-degenerate triangle. Mahmoud doesn't accept challenges unless he is sure he can win, so he asked you to tell him if he should accept the challenge. Given the lengths of the line segments, check if he can choose exactly 3 of them to form a non-degenerate triangle.Mahmoud should use exactly 3 line segments, he can't concatenate two line segments or change any length. A non-degenerate triangle is a triangle with positive area.

The first line contains single integer n (3 ≤ n ≤ 105) — the number of line segments Mahmoud has. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the lengths of line segments Mahmoud has.

In the only line print "YES" if he can choose exactly three line segments and form a non-degenerate triangle with them, and "NO" otherwise.

NoteFor the first example, he can use line segments with lengths 2, 4 and 5 to form a non-degenerate triangle.

package main

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

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

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

func init() {
	if f, err := os.Open("in.goC"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var n int
	for I(&n) == nil {
		solve(n)
	}
}

func solve(n int) {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		I(&a[i])
	}
	sort.Ints(a)
	for i := 0; i < len(a)-2; i++ {
		if a[i]+a[i+1] > a[i+2] {
			O("YES\n")
			return
		}
	}
	O("NO\n")
}

package main

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

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

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

	merge_sort(array, 0, n-1)

	for i := n - 1; i >= 2; i-- {
		if array[i-1]+array[i-2] > array[i] {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}

func merge(buffer []int, start, middle, end int) {
	sorted := make([]int, end-start+1)

	i := start
	j := middle + 1
	k := 0
	for i <= middle && j <= end {
		if buffer[i] <= buffer[j] {
			sorted[k] = buffer[i]
			i++
		} else {
			sorted[k] = buffer[j]
			j++
		}
		k++
	}
	for i <= middle {
		sorted[k] = buffer[i]
		k++
		i++
	}
	for j <= end {
		sorted[k] = buffer[j]
		k++
		j++
	}

	i = start
	k = 0
	for i <= end {
		buffer[i] = sorted[k]
		i++
		k++
	}
}

func merge_sort(buffer []int, start, end int) {
	if end > start {
		middle := (end + start) / 2
		merge_sort(buffer, start, middle)
		merge_sort(buffer, middle+1, end)
		merge(buffer, start, middle, end)
	}
}

package main

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

func solve() {
	n := readInt()
	v := make([]int, n)
	for i := 0; i < n; i++ {
		v[i] = readInt()
	}
	sort.Ints(v)
	for i := 2; i < n; i++ {
		a := int64(v[i-2])
		b := int64(v[i-1])
		c := int64(v[i])
		if a+b > c && a+c > b && b+c > a {
			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 max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// IO

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

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

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

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

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF766B(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n int
	Fscan(in, &n)
	if n > 44 {
		Fprint(out, "YES")
		return
	}
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	sort.Ints(a)
	for i, v := range a[2:] {
		if a[i]+a[i+1] > v {
			Fprint(out, "YES")
			return
		}
	}
	Fprint(out, "NO")
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF766B(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n int
	Fscan(in, &n)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	sort.Ints(a)
	for i, v := range a[2:] {
		if a[i]+a[i+1] > v {
			Fprint(out, "YES")
			return
		}
	}
	Fprint(out, "NO")
}

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

package main

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

var stdReader *bufio.Reader = bufio.NewReader(os.Stdin)

func readInt() (result int) {
	var negative, started bool
READER_LOOP:
	for {
		char, err := stdReader.ReadByte()
		switch {
		case err != nil:
			break READER_LOOP
		case char == '-':
			negative = true
		case unicode.IsDigit(rune(char)):
			started = true
			result = result*10 + int(char&0xf)
		case started:
			break READER_LOOP
		}
	}
	if negative {
		result = -result
	}
	return
}

func main() {
	n := readInt()
	maj := make([]int, n)
	for i := range maj {
		maj[i] = readInt()
	}
	sort.Ints(maj)
	for i := 0; i <= len(maj)-3; i++ {
		if maj[i]+maj[i+1] > maj[i+2] {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}

package main

import "fmt"
import "sort"
import "bufio"
import "os"
import "strconv"

func main() {
	var n int
	fmt.Scan(&n)
	nums := make([]int, n)

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

	for i := 0; scanner.Scan(); i++ {
		num, _ := strconv.Atoi(scanner.Text())
		nums[i] = num
	}
	sort.Ints(nums)

	var canFormTriangle bool
	for i := 2; i < n; i++ {
		if nums[i-2]+nums[i-1] > nums[i] {
			canFormTriangle = true
			break
		}
	}
	if canFormTriangle {
		fmt.Print("YES")
	} else {
		fmt.Print("NO")
	}
}

package main

import (
        "fmt"
        "sort"
        "bufio"
        "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 frst() {
    fmt.Println("YES")
}
func scnd() {
    fmt.Println("NO")
}

func check(a int, b int, c int) bool {
    if a + b > c && b + c > a && a + c > b {
        return true
    } else {
        return false
    }
}

func main() {
    var n int
    scanf("%d\n", &n)
    var a = make([]int, n)
    for i := 0; i < n; i++ {
        scanf("%d", &a[i])
    }
    sort.Ints(a)
    for i := 0; i < n - 2; i++ {
        if check(a[i], a[i + 1], a[i + 2]) == true {
            frst()
            return
        }
    }
    if check(a[n - 2], a[n - 1], a[0]) == true {
        frst()
        return
    }
    if check(a[n - 1], a[0], a[1]) == true {
        frst()
        return
    }
    scnd()
}

package main

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

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

	sort.Ints(A)

	for i := 0; i + 2 < N; i++ {
		if A[i] + A[i + 1] > A[i + 2] {
			io.Println("YES")
			return
		}
	}
	io.Println("NO")
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

package main

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

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

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

func init() {
	if f, err := os.Open("in.goC"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var n int
	for I(&n) == nil {
		solve(n)
	}
}

func solve(n int) {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		I(&a[i])
	}
	sort.Ints(a)
	for i := 0; i < len(a)-2; i++ {
		if a[i]+a[i+1] >= a[i+2] {
			O("YES\n")
			return
		}
	}
	O("NO\n")
}

package main

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

var stdReader *bufio.Reader = bufio.NewReader(os.Stdin)

func readInt() (result int) {
	var negative, started bool
READER_LOOP:
	for {
		char, err := stdReader.ReadByte()
		switch {
		case err != nil:
			break READER_LOOP
		case char == '-':
			negative = true
		case unicode.IsDigit(rune(char)):
			started = true
			result = result*10 + int(char&0xf)
		case started:
			break READER_LOOP
		}
	}
	if negative {
		result = -result
	}
	return
}

func main() {
	n := readInt()
	maj := make([]int, n)
	for i := range maj {
		maj[i] = readInt()
	}
	sort.Ints(maj)
	a, b, c := int64(maj[len(maj)-3]), int64(maj[len(maj)-2]), int64(maj[len(maj)-1])
	if a*a+b*b < c*c {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

package main

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

var stdReader *bufio.Reader = bufio.NewReader(os.Stdin)

func readInt() (result int) {
	var negative, started bool
READER_LOOP:
	for {
		char, err := stdReader.ReadByte()
		switch {
		case err != nil:
			break READER_LOOP
		case char == '-':
			negative = true
		case unicode.IsDigit(rune(char)):
			started = true
			result = result*10 + int(char&0xf)
		case started:
			break READER_LOOP
		}
	}
	if negative {
		result = -result
	}
	return
}

func main() {
	n := readInt()
	maj := make([]int, n)
	for i := range maj {
		maj[i] = readInt()
	}
	sort.Ints(maj)
	a, b, c := int64(maj[0]), int64(maj[1]), int64(maj[len(maj)-1])
	if a*a+b*b < c*c {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

package main

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

var stdReader *bufio.Reader = bufio.NewReader(os.Stdin)

func readInt() (result int) {
	var negative, started bool
READER_LOOP:
	for {
		char, err := stdReader.ReadByte()
		switch {
		case err != nil:
			break READER_LOOP
		case char == '-':
			negative = true
		case unicode.IsDigit(rune(char)):
			started = true
			result = result*10 + int(char&0xf)
		case started:
			break READER_LOOP
		}
	}
	if negative {
		result = -result
	}
	return
}

func main() {
	n := readInt()
	maj := make([]int, n)
	for i := range maj {
		maj[i] = readInt()
	}
	sort.Ints(maj)
	a, b, c := int64(maj[0]), int64(maj[1]), int64(maj[len(maj)-1])
	fmt.Println(a*a+b*b < c*c)
}

package main

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

var stdReader *bufio.Reader = bufio.NewReader(os.Stdin)

func readInt() (result int) {
	var negative, started bool
READER_LOOP:
	for {
		char, err := stdReader.ReadByte()
		switch {
		case err != nil:
			break READER_LOOP
		case char == '-':
			negative = true
		case unicode.IsDigit(rune(char)):
			started = true
			result = result*10 + int(char&0xf)
		case started:
			break READER_LOOP
		}
	}
	if negative {
		result = -result
	}
	return
}

func main() {
	n := readInt()
	maj := make([]int, n)
	for i := range maj {
		maj[i] = readInt()
	}
	sort.Ints(maj)
	a, b, c := int64(maj[len(maj)-3]), int64(maj[len(maj)-2]), int64(maj[len(maj)-1])
	if a*a+b*b > c*c {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


On his free time, Chouti likes doing some housework. He has got one new task, paint some bricks in the yard.There are $$$n$$$ bricks lined in a row on the ground. Chouti has got $$$m$$$ paint buckets of different colors at hand, so he painted each brick in one of those $$$m$$$ colors.Having finished painting all bricks, Chouti was satisfied. He stood back and decided to find something fun with these bricks. After some counting, he found there are $$$k$$$ bricks with a color different from the color of the brick on its left (the first brick is not counted, for sure).So as usual, he needs your help in counting how many ways could he paint the bricks. Two ways of painting bricks are different if there is at least one brick painted in different colors in these two ways. Because the answer might be quite big, you only need to output the number of ways modulo $$$998\,244\,353$$$.

The first and only line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \leq n,m \leq 2000, 0 \leq k \leq n-1$$$) — the number of bricks, the number of colors, and the number of bricks, such that its color differs from the color of brick to the left of it.

Print one integer — the number of ways to color bricks modulo $$$998\,244\,353$$$.

NoteIn the first example, since $$$k=0$$$, the color of every brick should be the same, so there will be exactly $$$m=3$$$ ways to color the bricks.In the second example, suppose the two colors in the buckets are yellow and lime, the following image shows all $$$4$$$ possible colorings.

package main

import "fmt"

type key struct {
	lastIdx    int
	nDifferent int
}

var (
	n, m, k int
	cache   = make(map[key]int64)
)

// colorings will calculate how many different colorings are at a[0]..a[lastIdx], so that nDifferent for 0..lastIdx holds.
func colorings(lastIdx int, nDifferent int) (ret int64) {
	k := key{lastIdx, nDifferent}
	if r, ok := cache[k]; ok {
		return r
	}
	defer func() {
		cache[k] = ret
	}()

	// We have spent all our different brick possibilities.
	if nDifferent < 0 {
		return 0
	}

	if lastIdx == 0 {
		if nDifferent == 0 {
			// If there is only one brick remaining, it can have m different colors.
			return int64(m)
		}
		// But only, if there is exactly zero bricks different on its left.
		return 0
	}

	// There are p combinations for 0..lastIdx-1. For each combination:
	//   - there is (m-1) combinations with nDifferent that is the same
	//   - one combination with nDifferent less.
	lastIdxDifferent := colorings(lastIdx-1, nDifferent-1) * int64(m-1)
	lastIdxSame := colorings(lastIdx-1, nDifferent)
	// dprintf("lastIdx=%d, nDifferent=%d, noDiff=%d, diff=%d", lastIdx, nDifferent, noDiffChange, diffChange)

	return (lastIdxDifferent + lastIdxSame) % 998244353

	// m combinations where [lastIdx-1, lastIdx are the same]
	// m**2 - m combinations where [lastIdx-1 and lastIdx are different]
}

func dprintf(i string, a ...interface{}) {
	if false {
		fmt.Printf(i+"\n", a...)
	}
}

func main() {
	fmt.Scanf("%d %d %d", &n, &m, &k)
	fmt.Println(colorings(n-1, k))
	dprintf("%v", cache)
}

package main

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

const M int64 = 998244353
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 sp(x, y int64) int64 {
  var mul, res int64 = x, 1
  for y != 0 {
    if y % 2 != 0 {
      res = (res * mul) % M
    }
    mul = (mul * mul) % M
    y /= 2
  }
  return res
}

func main() {
  defer writer.Flush()
  var n, m, k int
  scanf("%d%d%d", &n, &m, &k)
  fac := make([]int64, n+1)
  fac[0] = 1
  for i := 1; i <= n; i += 1 {
    fac[i] = (fac[i-1] * int64(i)) % M
  }

  sol := fac[n-1]
  sol = (sol * sp(fac[n-1-k], M-2)) % M
  sol = (sol * sp(fac[k], M-2)) % M
  sol = (sol * sp(int64(m-1), int64(k))) % M
  sol = (sol * int64(m)) % M
  printf("%d\n", sol)
}

package main

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

const (
	mod = 998244353
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n, m, k := 0, 0, 0
	fmt.Fscanf(in, "%d %d %d\n", &n, &m, &k)
	f := make([][]int64, n+1)
	for i := 0; i < n+1; i++ {
		f[i] = make([]int64, k+1)
	}
	f[1][0] = int64(m)
	for i := 2; i < n+1; i++ {
		for j := 0; j < k+1; j++ {
			if j == 0 {
				f[i][j] = f[i-1][j]
			} else {
				f[i][j] = f[i-1][j] + f[i-1][j-1]*int64(m-1)
				f[i][j] %= mod
			}
		}
	}
	fmt.Fprintf(out, "%d\n", f[n][k])
	return
}

package main

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

const M int = 998244353
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 sp(x, y int) int {
  var mul, res int = x, 1
  for y != 0 {
    if y % 2 != 0 {
      res = (res * mul) % M
    }
    mul = (mul * mul) % M
    y /= 2
  }
  return res
}

func main() {
  defer writer.Flush()
  var n, m, k int
  scanf("%d%d%d", &n, &m, &k)

  fac := make([]int, n+1)
  fac[0] = 1
  for i := 1; i <= n; i += 1 {
    fac[i] = (fac[i-1] * i) % M
  }

  sol := fac[n-1]
  sol = (sol * sp(fac[n-1-k], M-2)) % M
  sol = (sol * sp(fac[k], M-2)) % M
  sol = (sol * sp(m-1, k)) % M
  sol = (sol * m) % M
  printf("%d\n", sol)
}

package main

import (
  "fmt"
)

const M int = 998244353

func sp(x, y int) int {
  var mul, res int = x, 1
  for y != 0 {
    if y % 2 != 0 {
      res = (res * mul) % M
    }
    mul = (mul * mul) % M
    y /= 2
  }
  return res
}

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

  fac := make([]int, n+1)
  fac[0] = 1
  for i := 1; i <= n; i += 1 {
    fac[i] = (fac[i-1] * i) % M
  }

  sol := fac[n-1]
  sol = (sol * sp(fac[n-1-k], M-2)) % M
  sol = (sol * sp(fac[k], M-2)) % M
  sol = (sol * sp(m-1, k)) % M
  sol = (sol * m) % M
  fmt.Printf("%d\n", sol)
}

package main

import (
  "fmt"
)

const M int = 998244353

func sp(x, y int) int {
  var mul, res int = x, 1
  for y != 0 {
    if y % 2 != 0 {
      res = (res * mul) % M
    }
    mul = (mul * mul) % M
    y /= 2
  }
  return res
}

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

  fac := make([]int, n+1)
  fac[0] = 1
  for i := 1; i <= n; i += 1 {
    fac[i] = (fac[i-1] * i) % M
  }

  sol := fac[n-1]
  sol = (sol * sp(fac[n-1-k], M-2)) % M
  sol = (sol * sp(fac[k], M-2)) % M
  sol = (sol * sp(m-1, k)) % M
  sol = (sol * m) % M
  fmt.Printf("%d\n", sol)
}

package main

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

const M int = 998244353
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 sp(x, y int) int {
  var mul, res int = x, 1
  for y != 0 {
    if y % 2 != 0 {
      res = (res * mul) % M
    }
    mul = (mul * mul) % M
    y /= 2
  }
  return res
}

func main() {
  defer writer.Flush()
  var n, m, k int
  scanf("%d%d%d", &n, &m, &k)
  printf("%d %d %d\n", n, m, k);
  fac := make([]int, n+1)
  fac[0] = 1
  for i := 1; i <= n; i += 1 {
    fac[i] = (fac[i-1] * i) % M
  }

  sol := fac[n-1]
  sol = (sol * sp(fac[n-1-k], M-2)) % M
  sol = (sol * sp(fac[k], M-2)) % M
  sol = (sol * sp(m-1, k)) % M
  sol = (sol * m) % M
  printf("%d\n", sol)
}


Kurt reaches nirvana when he finds the product of all the digits of some positive integer. Greater value of the product makes the nirvana deeper.Help Kurt find the maximum possible product of digits among all integers from $$$1$$$ to $$$n$$$.

The only input line contains the integer $$$n$$$ ($$$1 \le n \le 2\cdot10^9$$$).

Print the maximum product of digits among all integers from $$$1$$$ to $$$n$$$.

NoteIn the first example the maximum product is achieved for $$$389$$$ (the product of digits is $$$3\cdot8\cdot9=216$$$).In the second example the maximum product is achieved for $$$7$$$ (the product of digits is $$$7$$$).In the third example the maximum product is achieved for $$$999999999$$$ (the product of digits is $$$9^9=387420489$$$).

package main

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

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()
	ch := string("")
	scanf("%s", &ch)
	num := []byte(ch)
	s1 := uint64(1)
	for _, char := range num {
		s, _ := strconv.ParseUint(string(char), 10, 64)
		s1 *= s
	}
	for i, char := range num {
		if char == '0' {
			break
		}
		num1 := make([]byte, len(num))
		copy(num1, num)
		num1[i] = num[i] - 1
		s2 := uint64(1)
		for j, char := range num1 {
			var number uint64
			if j <= i {
				number, _ = strconv.ParseUint(string(char), 10, 64)
				if number == 0 {
					number = 1
				}
			} else {
				number = 9
			}
			s2 *= number
		}
		if s2 > s1 {
			s1 = s2
		}
	}
	printf("%d\n", s1)

}

package main

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

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

	var n int64
	fmt.Fscanf(buf, "%d\n", &n)

	mat := make([]int64, 20)
	len := 0
	for n > 0 {
		mat[len] = n % int64(10)
		n /= 10
		len++
	}
	//for i := len - 1; i >= 0; i-- {
	//	if mat[i] == 0 {
	//		for j := i + 1; j < len; j++ {
	//			mat[j]--
	//			if mat[j] > 0 || (mat[j] == 0 && j == len-1) {
	//				for k := j - 1; k >= 0; k-- {
	//					mat[k] = 9
	//				}
	//				break
	//			}
	//		}
	//		break
	//	}
	//}
	//for i := len; i >= 0; i-- {
	//	if mat[i] > 0 {
	//		len = i + 1
	//		break
	//	}
	//}
	var le int64 = 1
	var ans int64 = 1
	var tmp int64 = 1
	for i := 0; i < len; i++ {
		ans *= mat[i]
		le *= 9
	}
	//fmt.Printf("-%d len=%d %v\n",ans,len,mat)

	for i := len - 1; i >= 0; i-- {
		le /= 9
		if mat[i] > 1 {
			if tmp*(mat[i]-1)*le > ans {
				ans = tmp * (mat[i] - 1) * le
			}
		} else if i == len-1 {
			if le > ans {
				ans = le
			}
		}else {
			break
		}
		tmp *= mat[i]
	}
	fmt.Printf("%d\n", ans)
}

package main

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

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

	var n int64
	fmt.Fscanf(buf, "%d\n", &n)

	mat := make([]int64, 20)
	len := 0
	for n > 0 {
		mat[len] = n % int64(10)
		n /= 10
		len++
	}
	for i := len - 1; i >= 0; i-- {
		if mat[i] == 0 {
			for j := i + 1; j < len; j++ {
				mat[j]--
				if mat[j] > 0 || (mat[j] == 0 && j == len-1) {
					for k := j - 1; k >= 0; k-- {
						mat[k] = 9
					}
					break
				}
			}
			break
		}
	}
//	fmt.Printf("%v\n",mat)
	for i := len; i >= 0; i-- {
		if mat[i] > 0 {
			len = i + 1
			break
		}
	}
	var le int64 = 1
	var ans int64 = 1
	var tmp int64 = 1
	for i := 0; i < len; i++ {
		ans *= mat[i]
		le *= 9
	}
	//fmt.Printf("-%d len=%d %v\n",ans,len,mat)

	for i:=len-1;i>=0;i--{
		le/=9
		if mat[i] > 1{
			if tmp*(mat[i]-1)*le > ans{
				ans=tmp*(mat[i]-1)*le
			}
		}else if i==len-1{
			if le > ans{
				ans =le
			}
		}
		tmp *= mat[i]
	}
	fmt.Printf("%d\n",ans)
}

/*
URL:
https://codeforces.com/problemset/problem/1143/B
*/

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 []rune

	dp [20][2]int64
)

func main() {
	N = ReadRuneSlice()
	n := len(N)

	dp[0][0] = 1
	for i := 0; i < len(N); i++ {
		d := int64(N[i] - '0')

		dp[i+1][0] = dp[i][0] * d
		ChMax(&dp[i+1][1], dp[i][0]*(d-1))
		ChMax(&dp[i+1][1], dp[i][0])
		ChMax(&dp[i+1][1], dp[i][1]*9)
	}

	fmt.Println(Max(dp[n][0], dp[n][1]))
}

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

// 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 *int64, target int64) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

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

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	if n < 10 {
		fmt.Fprintf(out, "%d\n", n)
		return
	}
	a := make([]int, 0)
	for n > 0 {
		a = append(a, n%10)
		n /= 10
	}
	b := make([]int, len(a))
	for i := 0; i < len(a); i++ {
		b[i] = a[len(a)-i-1]
	}
	ans := 1
	for i := 0; i < len(a); i++ {
		ans *= b[i]
	}
	tmp := 1
	for i := 1; i < len(a); i++ {
		tmp *= 9
	}
	if tmp > ans {
		ans = tmp
	}
	// c := make([]int, len(b))
	// for i := 0; i < len(b); i++ {
	// 	c[i] = b[i]
	// }

	for i := 0; i < len(b); i++ {
		if b[i] > 1 {
			tmp := 1
			for j := 0; j < i; j++ {
				tmp *= b[j]
			}
			tmp *= b[i] - 1
			for j := i + 1; j < len(b); j++ {
				tmp *= 9
			}
			if tmp > ans {
				ans = tmp
			}
		}
	}
	fmt.Fprintf(out, "%d\n", ans)
	return
}

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

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

package main

import (
	"fmt"
	"math"
)

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

func power(a int) (int) {
	if a < 10 {
		return a
	}
	//fmt.Println(a)

	order := int(math.Floor(math.Log10(float64(a))))
	addition := max(a / int(math.Pow10(order)) - 1, 1)
	top := int(math.Pow(9.0, float64(order))) * addition

	//fmt.Println("Versus", top, "order", order, "addition", addition)
	return max(top, (a / int(math.Pow10(order))) * power(a % int(math.Pow10(order))))
}

func main() {
	var n int
	fmt.Scan(&n)
	fmt.Println(power(n))
}

package main

import (
	"fmt"
)

func reverseInts(input []int) []int {
	if len(input) == 0 {
		return input
	}
	return append(reverseInts(input[1:]), input[0])
}

func main(){
	var n int
	fmt.Scan(&n)
	var list []int
	ans := 1;
	for ;;{
		if n == 0{
			break
		}
		list=append(list, n % 10)
		ans *= n % 10
		n /= 10
	}

	for index, each := range list{
		tmp := 1
		if each > 0{
			for i := index - 1; i >= 0; i--{
				tmp *= 9
			}
			for i := index + 1; i < len(list); i++{
				tmp *= list[i]
			}
			//fmt.Println(index, each)
			if each == 1 && index == len(list) - 1{

			}else{
				tmp *= each - 1
			}
			if tmp > ans{
				ans = tmp
			}
		}
	}
	fmt.Println(ans)
}

// Author: sighduck
// URL: https://codeforces.com/contest/1143/problem/B

package main

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

func getLength(n int) int {
	length := 0
	for n > 0 {
		n /= 10
		length += 1

	}
	return length
}

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

func product(n int) int64 {
	product := int64(1)
	for n > 0 {
		product *= int64(n % 10)
		n /= 10
	}
	return product
}

func Solve(n int) int64 {
	base := 10
	maxProduct := int64(0)
	for n > 0 {
		maxProduct = max(maxProduct, product(n))
		n -= (n%base + 1)
		base *= 10
	}
	return maxProduct
}

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

	var n int
	fmt.Fscanf(reader, "%d\n", &n)

	fmt.Fprintf(writer, "%d\n", Solve(n))
}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	ch := string("")
	fmt.Scanf("%s", &ch)
	num := []byte(ch)
	s1 := uint64(1)
	for _, char := range num {
		s, _ := strconv.ParseUint(string(char), 10, 64)
		s1 *= s
	}
	for i, char := range num {
		if char == '0' {
			break
		}
		num1 := []byte{}
		num1 = num
		num1[i] = num[i] - 1
		s2 := uint64(1)
		for j, char := range num1 {
			var number uint64
			if j <= i {
				number, _ = strconv.ParseUint(string(char), 10, 64)
				if number == 0 {
					number = 1
				}
			} else {
				number = 9
			}
			s2 *= number
		}
		if s2 > s1 {
			s1 = s2
		}
	}
	println(s1)

}

package main

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

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()
	ch := string("")
	scanf("%s", &ch)
	num := []byte(ch)
	s1 := uint64(1)
	for _, char := range num {
		s, _ := strconv.ParseUint(string(char), 10, 64)
		s1 *= s
	}
	for i, char := range num {
		if char == '0' {
			break
		}
		num1 := []byte{}
		num1 = num
		num1[i] = num[i] - 1
		s2 := uint64(1)
		for j, char := range num1 {
			var number uint64
			if j <= i {
				number, _ = strconv.ParseUint(string(char), 10, 64)
				if number == 0 {
					number = 1
				}
			} else {
				number = 9
			}
			s2 *= number
		}
		if s2 > s1 {
			s1 = s2
		}
	}
	printf("%d\n", s1)

}

package main

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

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

	var n int64
	fmt.Fscanf(buf, "%d\n", &n)

	mat := make([]int64, 20)
	len := 0
	for n > 0 {
		mat[len] = n % int64(10)
		n /= 10
		len++
	}
	for i := len - 1; i >= 0; i-- {
		if mat[i] == 0 {
			for j := i + 1; j < len; j++ {
				mat[j]--
				if mat[j] > 0 || (mat[j] == 0 && j == len-1) {
					for k := j - 1; k >= 0; k-- {
						mat[k] = 9
					}
					break
				}
			}
			break
		}
	}
	//fmt.Printf("%v\n",mat)
	for i := len; i >= 0; i-- {
		if mat[i] > 0 {
			len = i + 1
			break
		}
	}
	var le int64 = 1
	var ans int64 = 1
	var tmp int64 = 1
	for i := 0; i < len; i++ {
		ans *= mat[i]
		le *= 9
	}
	//fmt.Printf("-%d len=%d %v\n",ans,len,mat)

	for i:=len-1;i>=0;i--{
		le/=9
		if mat[i] > 1{
			if tmp*(mat[i]-1)*le > ans{
				ans=tmp*(mat[i]-1)*le
			}
		}
		tmp *= mat[i]
	}
	fmt.Printf("%d\n",ans)
}


You are given an array of $$$n$$$ integers: $$$a_1, a_2, \ldots, a_n$$$. Your task is to find some non-zero integer $$$d$$$ ($$$-10^3 \leq d \leq 10^3$$$) such that, after each number in the array is divided by $$$d$$$, the number of positive numbers that are presented in the array is greater than or equal to half of the array size (i.e., at least $$$\lceil\frac{n}{2}\rceil$$$). Note that those positive numbers do not need to be an integer (e.g., a $$$2.5$$$ counts as a positive number). If there are multiple values of $$$d$$$ that satisfy the condition, you may print any of them. In case that there is no such $$$d$$$, print a single integer $$$0$$$.Recall that $$$\lceil x \rceil$$$ represents the smallest integer that is not less than $$$x$$$ and that zero ($$$0$$$) is neither positive nor negative.

The first line contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of elements in the array. The second line contains $$$n$$$ space-separated integers $$$a_1, a_2, \ldots, a_n$$$ ($$$-10^3 \le a_i \le 10^3$$$).

Print one integer $$$d$$$ ($$$-10^3 \leq d \leq 10^3$$$ and $$$d \neq 0$$$) that satisfies the given condition. If there are multiple values of $$$d$$$ that satisfy the condition, you may print any of them. In case that there is no such $$$d$$$, print a single integer $$$0$$$.

NoteIn the first sample, $$$n = 5$$$, so we need at least $$$\lceil\frac{5}{2}\rceil = 3$$$ positive numbers after division. If $$$d = 4$$$, the array after division is $$$[2.5, 0, -1.75, 0.5, 1.5]$$$, in which there are $$$3$$$ positive numbers (namely: $$$2.5$$$, $$$0.5$$$, and $$$1.5$$$).In the second sample, there is no valid $$$d$$$, so $$$0$$$ should be printed.

package main

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

func getNumFromOneLine(ir *bufio.Reader) int {
	stream, _ := ir.ReadString('\n')
	// Trims the stream and then splits
	trimmedStream := strings.TrimSpace(stream)
	num, _ := strconv.Atoi(trimmedStream)
	return num
}

func getNumsFromOneLine(ir *bufio.Reader) []int {
	stream, _ := ir.ReadString('\n')
	// Trims the stream and then splits
	trimmedStream := strings.TrimSpace(stream)
	splitArr := strings.Split(trimmedStream, " ")
	// convert strings to integers and store them in a slice
	nums := make([]int, len(splitArr))
	for index, val := range splitArr {
		nums[index], _ = strconv.Atoi(val)
	}
	return nums
}

func main() {
	ir := bufio.NewReader(os.Stdin)
	_ = getNumFromOneLine(ir)
	nums := getNumsFromOneLine(ir)

	pos, neg := 0, 0
	for _, num := range nums {
		if num > 0 {
			pos += 1
		} else if num < 0 {
			neg += 1
		}
	}

	if neg >= (len(nums)+1)/2 {
		fmt.Println(-1)
	} else if pos >= (len(nums)+1)/2 {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}

package main

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

func cleanString(stream string, seperator string) []int{
	// Trims the stream and then splits
	trimmedStream := strings.TrimSpace(stream)
	splitArr := strings.Split(trimmedStream, seperator)
	// convert strings to integers and store them in a slice
	nums := make([]int, len(splitArr))
	for index,val := range splitArr{
		nums[index], _ = strconv.Atoi(val)
	}
	return nums
}

func main() {
	ir := bufio.NewReader(os.Stdin)
	input, _ := ir.ReadString('\n')
	_, _ = strconv.Atoi(strings.TrimSpace(input))
	var nums []int
	lineInput, _ := ir.ReadString('\n')
	nums = cleanString(lineInput, " ")
	pos, neg := 0, 0
	for _, num := range nums {
		if num > 0 {
			pos += 1
		} else if num < 0 {
			neg += 1
		}
	}
	if neg >= (len(nums) + 1) / 2 {
		fmt.Println(-1)
	} else if pos >= (len(nums) + 1) / 2 {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}

package main

import (
 "fmt"
)

func main() {
    var n int = 0;
    fmt.Scan(&n);
    var plus, minus, zero int = 0,0,0;
    for n > 0 {
        var x int = 0;
        fmt.Scan(&x);
        if (x < 0) {
            minus++;
        } else if (x > 0) {
            plus++;
        } else {
            zero++;
        }
        n--;
    }
    if (plus >= minus + zero) {
        fmt.Println(1);
    } else if (minus >= plus + zero) {
        fmt.Println(-1);
    } else {
        fmt.Println(0);
    }
}

package main

import (
	"fmt"
)

func calc(n,z,p,t int) int{
	var val int
	if t&1==1{
		val = t/2 + 1
	}else{
		val = t/2
	}

	if n >=val{
		return -1
	}else if p>=val{
		return 1
	}
	return 0
}

func main(){
	var t int
	fmt.Scan(&t)
	var neg int
	var zero int
	var pos int

	for i:=0;i<t;i++{
		var temp int
		fmt.Scan(&temp)
		if temp==0{
			zero++
		}else if temp<0{
			neg++
		}else{
			pos++
		}
	}
	fmt.Print(calc(neg,zero,pos,t))
}

package main

import "fmt"

func main() {

	var n, tmp, neg, zer, pos int

	fmt.Scan(&n)

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

		switch {
		case tmp < 0:
			neg++
		case tmp == 0:
			zer++
		case tmp > 0:
			pos++
		}
	}

	if pos >= (n+1)/2 {
		fmt.Println(1)
	} else if neg >= (n+1)/2 {
		fmt.Println(-1)
	} else {
		fmt.Println(0)
	}
}

package main

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

type Seg struct {

}

type Prob struct {
    in *bufio.Reader
}

func (prob *Prob) NextLine() string {
    line, _, _ := prob.in.ReadLine()
    return string(line[:])
}

func (prob *Prob) NextByte() byte {
    bt, _ := prob.in.ReadByte()
    return bt
}

func (prob *Prob) Next() string {
    var buff bytes.Buffer
    bt := prob.NextByte()
    for bt == '\n' || bt == ' ' {
        bt = prob.NextByte()
    }
    for bt != '\n' && bt != ' ' {
        buff.WriteByte(bt)
        bt = prob.NextByte()
    }
    return buff.String()
}

func (prob *Prob) NextInt() int {
    var x int
    bt := prob.NextByte()
    for bt > '9' || bt < '0' {
        if bt == '-' {
            return -prob.NextInt()
        }
        bt = prob.NextByte()
    }
    for bt >= '0' && bt <= '9' {
        x = x * 10 + int(bt - '0')
        bt = prob.NextByte()
    }
    return x
}

func (prob Prob) Solve() {
    n := prob.NextInt()
    po := 0
    ne := 0
    for i := 0; i < n; i++ {
        d := prob.NextInt()
        if d > 0 {
            po++
        } else if d < 0 {
            ne++
        }
    }
    if po >= (n + 1) / 2 {
        fmt.Println("1")
    } else if ne >= (n + 1) / 2 {
        fmt.Println("-1")
    } else {
        fmt.Println(0)
    }
}

func main() {
    Prob{in: bufio.NewReader(os.Stdin)}.Solve()
}

package main

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

func main()  {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n int
	var x int
//	a := make([]int,0)
	fmt.Fscanln(in,&n)
	ps := 0
	mn := 0
	for i := 0 ;i  < n ;i++{
		fmt.Fscan(in,&x)
		if(x >= 1){
			ps ++
		}else{
				if(x <= -1){
					mn ++
				}
		}
	}
	if(ps > mn){
		if(ps >= (n + 1) / 2){
			fmt.Fprint(out,1)
		}else{
			fmt.Fprint(out,0)
		}
		return
	}else{
		if mn >= (n + 1) / 2{
			fmt.Fprint(out,-1)
		}else{
			fmt.Fprint(out,0)
		}
		return
	}

}
func min1(x1,x2 int) int  {
	if(x1 < x2){
		return x1
	}else{
		return x2
	}
}

package main

import "fmt"

func main() {
	var n, a, x, y int
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a)
		if a < 0 {
			x++
		} else if a > 0 {
			y++
		}
	}
	if x >= (int)((n + 1) / 2) {
		fmt.Println("-1")
	} else if y >= (int)((n + 1) / 2) {
		fmt.Println("1")
	} else {
		fmt.Println("0")
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d", &a[i])
	}
	fmt.Fscanf(in, "\n")
	need := n/2 + n%2
	for j := -1000; j <= 1000; j++ {
		if j != 0 {
			cur := float64(0)
			for i := 0; i < n; i++ {
				if float64(a[i])/float64(j) > 0 {
					cur += 1
				}
			}
			if cur >= float64(need) {
				fmt.Fprintf(out, "%d\n", j)
				return
			}
		}
	}
	fmt.Fprintf(out, "%d\n", 0)
	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])
	}
}

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()
	a := make([]int, n)
	for i := range a {
		a[i] = readi()
	}
	var pos, neg, zero int
	for _, v := range a {
		if v == 0 {
			zero++
		} else if v < 0 {
			neg++
		} else {
			pos++
		}
	}
	m := n / 2
	if n%2 != 0 {
		m++
	}
	if m <= pos {
		println(1)
	} else if m <= neg {
		println(-1)
	} else {
		println(0)
	}
}

package main

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

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

	var a []int = make([]int, n)
	pos, neg := 0, 0
	for i := range a {
		fmt.Fscanf(rbuf, "%d", &a[i])
		if (a[i] > 0) {
			pos += 1
		}
		if (a[i] < 0) {
			neg += 1
		}
	}

	if pos * 2 >= n {
		fmt.Println(1)
	} else if neg * 2 >= n {
		fmt.Println(-1)
	} else {
		fmt.Println(0)
	}
}

// http://codeforces.com/problemset/problem/1130/A
package main

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

func main() {
	var inputs int
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	inputs, _ = strconv.Atoi(scanner.Text())
	scanner.Scan()
	line := scanner.Text()
	var zeros int = 0
	var positives int = 0
	var negatives int = 0
	for _, num := range strings.Split(line, " ") {
		if num == "0" {
			zeros++
		} else if strings.Count(num, "-") == 1 {
			negatives++
		} else {
			positives++
		}
	}
	c := math.Ceil(float64(inputs)/2)
	if float64(positives) >= c {
		fmt.Printf("1")
	} else if float64(negatives) >= c {
		fmt.Printf("-1")
	} else {
		fmt.Printf("0")
	}
}

package main

import (
	`fmt`
)

func main() {
	var n int
	fmt.Scan(&n)
	pos := 0
	neg := 0
	for i := 0; i < n; i++ {
		x := 0
		fmt.Scan(&x)
		if x > 0 {
			pos += 1
		}
		if x < 0 {
			neg += 1
		}
	}
	if float64(neg) >= float64(n) / 2 {
		fmt.Println(-1)
	} else if float64(pos) >= float64(n) / 2. {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}

package main

import (
	"bufio"
	"os"
	"fmt"
)
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 readLine()(string,error) 			{ return reader.ReadString('\n') }

func main() {
	defer writer.Flush()
	var n int
	scanf("%d\n", &n)
	k := n/2 + n%2
	a := make([]int,n)
	for i := 0; i < n; i++ {
		scanf("%d", &a[i])
	}
	for i := -1000; i <= 1000; i++ {
			x := 0
			for _, j := range a {
				if ((i > 0 && j > 0) || (i < 0 && j < 0)) {
					x++
				}
			}
			if x >= k {
				fmt.Println(i)
				return
			}

	}
	fmt.Println(0)
}

package main

import (
    "fmt"
)

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

    pos := 0
    neg := 0
    for i := 0; i <= n; i++ {
        var nmb int
        fmt.Scanf("%d", &nmb)
        if nmb > 0 {
            pos++
        }
        if nmb < 0 {
            neg++
        }
    }

    if neg < (n + 1) / 2 && pos < (n + 1) / 2 {
        fmt.Println(0)
    } else if neg >= (n + 1) / 2 {
        fmt.Println(-1)
    } else if pos >= (n + 1) / 2 {
        fmt.Println(1)
    }

}

package main

import (
 "fmt"
)

func main() {
    var n int = 0;
    fmt.Scan(&n);
    var plus, minus, zero int = 0,0,0;
    for n > 0 {
        var x int = 0;
        fmt.Scan(&x);
        if (x < 0) {
            minus++;
        } else if (x > 0) {
            plus++;
        } else {
            zero++;
        }
        n--;
    }
    if (plus > minus + zero) {
        fmt.Println(1);
    } else if (minus > plus + zero) {
        fmt.Println(-1);
    } else {
        fmt.Println(0);
    }
}

package main

import "fmt"

func main() {

	var n, tmp, neg, zer, pos int

	fmt.Scan(&n)

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

		switch {
		case tmp < 0:
			neg++
		case tmp == 0:
			zer++
		case tmp > 0:
			pos++
		}
	}

	if pos >= n/2 {
		fmt.Println(1)
	} else if neg >= n/2 {
		fmt.Println(-1)
	} else {
		fmt.Println(0)
	}
}

package main

import (
    "fmt"
)

func solve() {
    var n int
    fmt.Scanf("%d", &n)
    po := 0
    ne := 0
    for i := 0; i < n; i++ {
        var d int
        fmt.Scanf("%d", &d)
        if d > 0 {
            po++
        } else if d < 0 {
            ne++
        }
    }
    if po >= (n + 1) / 2 {
        fmt.Println("1")
    } else if ne >= (n + 1) / 2 {
        fmt.Println("-1")
    } else {
        fmt.Println(0)
    }
}

func main() {
    solve()
}

package main

import (
    "fmt"
)

func solve() {
    var n int
    fmt.Scanf("%d", &n)
    po := 0
    ne := 0
    for i := 0; i < n; i++ {
        var d int
        fmt.Scanf("%d", &d)
        if d > 0 {
            po++
        } else if d < 0 {
            ne++
        }
    }
    fmt.Printf("%d %d %d\n", po, ne, (n + 1) / 2)
    if po >= (n + 1) / 2 {
        fmt.Println("1")
    } else if ne >= (n + 1) / 2 {
        fmt.Println("-1")
    } else {
        fmt.Println(0)
    }
}

func main() {
    solve()
}

package main

import (
    "fmt"
)

func solve() {
    var n int
    fmt.Scanf("%d", &n)
    po := 0
    ne := 0
    for i := 0; i < n; i++ {
        var d int
        fmt.Scanf("%d", &d)
        fmt.Printf("%d\n", d)
        if d > 0 {
            po++
        } else if d < 0 {
            ne++
        }
    }
    fmt.Printf("%d %d %d\n", po, ne, (n + 1) / 2)
    if po >= (n + 1) / 2 {
        fmt.Println("1")
    } else if ne >= (n + 1) / 2 {
        fmt.Println("-1")
    } else {
        fmt.Println(0)
    }
}

func main() {
    solve()
}

package main

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

func main()  {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n int
	var x int
	a := make([]int,0)
	fmt.Fscanln(in,&n)
	ps := 0
	for i := 0 ;i  < n ;i++{
		fmt.Fscan(in,&x)
		a = append(a,x)
		if(x >= 1){
			ps ++
		}
	}
	if(ps >= (n + 1) / 2){
		fmt.Fprint(out,1)
	}else{
		fmt.Fprint(out,0)
	}

}
func min1(x1,x2 int) int  {
	if(x1 < x2){
		return x1
	}else{
		return x2
	}
}

package main

import "fmt"

func main() {
	var n, a, x, y int
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a)
		if a < 0 {
			x++
		} else if a > 0 {
			y++
		}
	}
	if x >= (n / 2) {
		fmt.Println("-1")
	} else if y >= (n / 2) {
		fmt.Println("1")
	} else {
		fmt.Println("0")
	}
}

package main

import "fmt"

func main() {
	var n, a, x, y int
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a)
		if a < 0 {
			x++
		} else if a > 0 {
			y++
		}
	}
	if x > (n / 2) {
		fmt.Println("-1")
	} else if y > (n / 2) {
		fmt.Println("1")
	} else {
		fmt.Println("0")
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d %d\n", &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d\n", &a[i])
	}
	need := n/2 + n%2
	for j := -1000; j <= 1000; j++ {
		if j != 0 {
			cur := float64(0)
			for i := 0; i < n; i++ {
				if float64(a[i])/float64(j) > 0 {
					cur += float64(a[i]) / float64(j)
				}
			}
			if cur >= float64(need) {
				fmt.Fprintf(out, "%d\n", j)
				return
			}
		}
	}
	fmt.Fprintf(out, "%d\n", 0)
	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])
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d", &a[i])
	}
	fmt.Fscanf(in, "\n")
	need := n/2 + n%2
	for j := -1000; j <= 1000; j++ {
		if j != 0 {
			cur := float64(0)
			for i := 0; i < n; i++ {
				if float64(a[i])/float64(j) > 0 {
					cur += float64(a[i]) / float64(j)
				}
			}
			if cur >= float64(need) {
				fmt.Fprintf(out, "%d\n", j)
				return
			}
		}
	}
	fmt.Fprintf(out, "%d\n", 0)
	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])
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d\n", &a[i])
	}
	need := n/2 + n%2
	for j := -1000; j <= 1000; j++ {
		if j != 0 {
			cur := float64(0)
			for i := 0; i < n; i++ {
				if float64(a[i])/float64(j) > 0 {
					cur += float64(a[i]) / float64(j)
				}
			}
			if cur >= float64(need) {
				fmt.Fprintf(out, "%d\n", j)
				return
			}
		}
	}
	fmt.Fprintf(out, "%d\n", 0)
	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])
	}
}

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()
	a := make([]int, n)
	for i := range a {
		a[i] = readi()
	}
	var pos, neg, zero int
	for _, v := range a {
		if v == 0 {
			zero++
		} else if v < 0 {
			neg++
		} else {
			pos++
		}
	}
	m := n / 2
	if n%2 != 0 {
		m++
	}
	if m <= zero {
		println(0)
	} else if m <= pos {
		println(1)
	} else if m <= neg {
		println(-1)
	} else {
		println(0)
	}
}

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()
	a := make([]int, n)
	for i := range a {
		a[i] = readi()
	}
	var pos, neg, zero int
	for _, v := range a {
		if v == 0 {
			zero++
		} else if v < 0 {
			neg++
		} else {
			pos++
		}
	}
	m := n / 2
	if n%2 != 0 {
		m++
	}
	if m <= zero {
		println(0)
	} else if m <= pos {
		println(1)
	} else {
		println(-1)
	}
}

// http://codeforces.com/problemset/problem/1130/A
package main

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

func main() {
	var inputs int
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	inputs, _ = strconv.Atoi(scanner.Text())
	scanner.Scan()
	line := scanner.Text()
	var zeros int = 0
	var positives int = 0
	var negatives int = 0
	for _, num := range strings.Split(line, " ") {
		if num == "0" {
			zeros++
		} else if strings.Count(num, "-") == 1 {
			negatives++
		} else {
			positives++
		}
	}
	c := math.Ceil(float64(inputs)/2)
	if float64(zeros) >= c {
		fmt.Printf("0")
	} else if float64(negatives) >= c {
		fmt.Printf("-1")
	} else {
		fmt.Printf("1")
	}
}

// http://codeforces.com/problemset/problem/1130/A
package main

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

func main() {
	var inputs int
	fmt.Scanf("%d\n", &inputs)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	line := scanner.Text()
	var zeros int = 0
	var positives int = 0
	var negatives int = 0
	for _, num := range strings.Split(line, " ") {
		if num == "0" {
			zeros++
		} else if strings.Count(num, "-") == 1 {
			negatives++
		} else {
			positives++
		}
	}
	if zeros >= inputs {
		fmt.Printf("0")
	} else if negatives >= inputs {
		fmt.Printf("-1")
	} else {
		fmt.Printf("1")
	}
}

package main

import (
	`bufio`
	`fmt`
	`os`
)

func main() {
	buf := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscanf(buf, "%d", &n)
	pos := 0
	neg := 0
	for i := 0; i < n; i++ {
		x := 0
		fmt.Fscanf(buf, "%d", &x)
		if x > 0 {
			pos += 1
		}
		if x < 0 {
			neg += 1
		}
	}
	if neg >= n / 2 {
		fmt.Println(-1)
	} else if pos >= n / 2 {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}

package main

import (
	"bufio"
	"os"
	"fmt"
)
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 readLine()(string,error) 			{ return reader.ReadString('\n') }

func main() {
	defer writer.Flush()
	var n int
	scanf("%d\n", &n)
	k := n/2 + n%2
	a := make([]int,n)
	for i := 0; i < n; i++ {
		scanf("%d", &a[i])
	}
	for i := -1000; i <= 1000; i++ {
		if (i != 0){
			x := 0
			for _, j := range a {
				if (((i > 0 && j > 0) || (i < 0 && j < 0)) && j%i != 0) {
					x++
				}
			}
			if x == k {
				fmt.Println(i)
				return
			}
		}
	}
	fmt.Println(0)
}

package main

import (
    "fmt"
)

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

    pos := 0
    neg := 0
    for i := 0; i < n; i++ {
        var nmb int
        fmt.Scanf("%d", &nmb)
        if nmb > 0 {
            pos++
        }
        if nmb < 0 {
            neg++
        }
    }

    if neg < (n + 1) / 2 && pos < (n + 1) / 2 {
        fmt.Println(0)
    } else if neg >= (n + 1) / 2 {
        fmt.Println(-1)
    } else if pos >= (n + 1) / 2 {
        fmt.Println(1)
    }

}


Today Patrick waits for a visit from his friend Spongebob. To prepare for the visit, Patrick needs to buy some goodies in two stores located near his house. There is a d1 meter long road between his house and the first shop and a d2 meter long road between his house and the second shop. Also, there is a road of length d3 directly connecting these two shops to each other. Help Patrick calculate the minimum distance that he needs to walk in order to go to both shops and return to his house.  Patrick always starts at his house. He should visit both shops moving only along the three existing roads and return back to his house. He doesn't mind visiting the same shop or passing the same road multiple times. The only goal is to minimize the total distance traveled.

The first line of the input contains three integers d1, d2, d3 (1 ≤ d1, d2, d3 ≤ 108) — the lengths of the paths.    d1 is the length of the path connecting Patrick's house and the first shop;  d2 is the length of the path connecting Patrick's house and the second shop;  d3 is the length of the path connecting both shops.

Print the minimum distance that Patrick will have to walk in order to visit both shops and return to his house.

NoteThe first sample is shown on the picture in the problem statement. One of the optimal routes is: house  first shop  second shop  house.In the second sample one of the optimal routes is: house  first shop  house  second shop  house.

package main

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

func main() {
	var d1, d2, d3 int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &d1, &d2, &d3)
	d1, d2, d3 = sorta(d1, d2, d3)
	if d1+d2 < d3 {
		fmt.Println((d1 + d2) * 2)
	} else {
		fmt.Println(d1 + d2 + d3)
	}
}

func sorta(a, b, c int) (int, int, int) {
	aa := make([]int, 0)
	aa = append(aa, a)
	aa = append(aa, b)
	aa = append(aa, c)
	sort.Slice(aa, func(i, j int) bool {
		return aa[i] < aa[j]
	})
	return aa[0], aa[1], aa[2]
}

package main

import (
	"fmt"
	"sort"
)

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

func main() {
	d := []int{0, 0, 0}
	fmt.Scanf("%d %d %d \n", &d[0], &d[1], &d[2])
	sort.Ints(d)
	r := d[0] + d[1] + min(d[2], d[0]+d[1])
	fmt.Print(r)
}

package main

import "fmt"

func min(a ...int) int {
    r := a[0]
    for _, v := range a {
        if r > v {
            r = v
        }
    }
    return r
}

func main() {
    // 总共4种情况，求个min就行了。
    var d1, d2, d3 int
    fmt.Scanf("%d %d %d", &d1, &d2, &d3);
    result := min(d1+d2+d3, 2*(d1+d2), 2*(d1+d3), 2*(d2+d3))
    fmt.Println(result)
}

package main

import "fmt"

func main() {
	var d [3]int
	fmt.Scan(&d[0], &d[1], &d[2])

	id := 0
	sum := d[0]
	for i := 1; i < 3; i++ {
		if d[id] < d[i] {
			id = i
		}
		sum += d[i]
	}

	l := 0
	if 2*d[id] > sum {
		l = 2 * (sum - d[id])
	} else {
		l = sum
	}

	fmt.Println(l)
}

package main

import (
	"fmt"
	"log"
)

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

func main() {
	var d1, d2, d3 int
	_, err := fmt.Scanf("%d %d %d", &d1, &d2, &d3)
	if err != nil {
		log.Fatal(err)
	}
	if d1+d3 < d2 {
		fmt.Println(2 * (d1 + d3))
		return
	} else if d2+d3 < d1 {
		fmt.Println(2 * (d2 + d3))
		return
	}
	fmt.Println(min(2*d1+2*d2, d1+d2+d3))
}

package main

import (
	"fmt"
)

func main() {
	var d1, d2, d3 int
	fmt.Scanf("%d %d %d", &d1, &d2, &d3)

	dis := []int{
		d1 + d2 + d3,
		2*d1 + 2*d2,
		2*d1 + 2*d3,
		2*d2 + 2*d3,
	}

	ans := int(2e9)
	for _, d := range dis {
		if ans > d {
			ans = d
		}
	}

	fmt.Println(ans)
}

package main

import "fmt"

func main(){
	var d1, d2, d3 int
	fmt.Scanf("%d%d%d", &d1, &d2, &d3)
	s := d1+d2+d3
	t := 2*(d1+d3)
	if s > t{
		s = t
	}
	t = 2*(d2+d3)
	if s > t{
		s = t
	}
	t = 2*(d1+d2)
	if s > t{
		s = t
	}
	fmt.Printf("%d\n", s)
}

package main;

import (
    "fmt"
)

func main() {
    var a, b, c int
    fmt.Scanf("%d%d%d", &a, &b, &c)
    dis := []int{
        a + b + c,
        2 * a + 2 * b,
        2 * a + 2 * c,
        2 * b + 2 * c,
    }

    ans := 0x3f3f3f3f
    for _, value := range dis {
        if value < ans {
            ans = value
        }
    }
    fmt.Println(ans)
}

package main

import (
    "fmt"
    )

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

func main() {
    var d1, d2, d3 uint
    fmt.Scan(&d1, &d2, &d3)

    dis1 := d1 + d2 + d3
    dis2 := 2*d1 + 2*d2
    dist := min(dis1, dis2)
    dis3 := 2*d2 + 2*d3
    dist = min(dist, dis3)
    dis4 := 2*d1 + 2*d3
    dist = min(dist, dis4)

    fmt.Println(dist)
}

package main

import "fmt"

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

func main() {
	var d1, d2, d3 int
	fmt.Scanf("%d %d %d", &d1, &d2, &d3)

	ret := min(d1 + min(d1 + 2 * d2, d3 + min(d2, d3 + d1)),
			   d2 + min(d2 + 2 * d1, d3 + min(d1, d3 + d2)))
	fmt.Printf("%d", ret)
}

package main

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

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

type MySlice [][2]int

func (slice MySlice) Len() int           { return len(slice) }
func (slice MySlice) Less(i, j int) bool { return slice[i][1] < slice[j][1] }
func (slice MySlice) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}

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

	d1 := scanInt()
	d2 := scanInt()
	d3 := scanInt()

	result := min(d1 + d2 + d3, min(2 * (d1 + d2), min(2 * (d2 + d3), 2 * (d1 + d3))))
	writer.WriteString(strconv.Itoa(result))

	return
}

func binSearch(a []int, key int) int {
	l := -1
	r := len(a)
	for l < r-1 {
		m := (l + r) / 2
		if a[m] < key {
			l = m
		} else {
			r = m
		}
	}

	if a[r] != key {
		return -1
	}

	return r
}

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

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

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

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

package main

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

func main() {
	var d1, d2, d3 int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &d1, &d2, &d3)
	if d1+d2 < d3 {
		fmt.Println((d1 + d2) * 2)
	} else {
		fmt.Println(d1 + d2 + d3)
	}
}

package main

import "fmt"

func main() {
	var d [3]int
	fmt.Scan(&d[0], &d[1], &d[2])

	id := 0
	sum := d[0]
	for i := 1; i < 3; i++ {
		if d[id] < d[i] {
			id = i
		}
		sum += d[i]
	}

	l := 0
	if 3*d[id] > 2*sum {
		l = 2 * (sum - d[id])
	} else {
		l = sum
	}

	fmt.Println(l)
}

package main

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

func main() {
	var d1, d2 ,d3, s uint16
	in := bufio.NewReader(os.Stdin)
	fmt.Fscanf(in, "%d %d %d\n", &d1,&d2, &d3)
	if d1 > d2 && d1 > d3{
		s += d2 * 2
		s += d3 * 2
	}else if d2 > d1 && d2 > d3{
		s += d1 * 2
		s += d3 * 2
	}else if d3 > d1 && d3 > d2{
		s += d1 * 2
		s += d2 * 2
	}else{
		if d2 >= d3{
			s += d1 * 2
			s += d2 * 2
		}
	}
	fmt.Println(s)
}

package main

import (
	"fmt"
	"log"
)

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

func main() {
	var d1, d2, d3 int
	_, err := fmt.Scanf("%d %d %d", &d1, &d2, &d3)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(min(2*d1+2*d2, d1+d2+d3))
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var d [3]int
	fmt.Fscanln(os.Stdin, &d[0], &d[1], &d[2])

	if d[0]+d[1]+d[2] <= 2*(d[0]+d[1]) {
		fmt.Println(d[0] + d[1] + d[2])
	} else {
		fmt.Println(2 * (d[0] + d[1]))
	}
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var d [3]int
	fmt.Fscanln(os.Stdin, &d[0], &d[1], &d[2])

	if d[0]+d[1]+d[2] < 2*(d[0]+d[1]) {
		fmt.Println(d[0] + d[1] + d[2])
	} else {
		fmt.Println(2 * (d[0] + d[1]))
	}
}

package main

import (
	"fmt"
)

func main() {
	var d1, d2, d3 int
	fmt.Scanf("%d %d %d", &d1, &d2, &d3)

	if d1*2+d2*2 < d1+d2+d3 {
		fmt.Println(d1*2 + d2*2)
	} else {
		fmt.Println(d1 + d2 + d3)
	}
}

package main;

import (
    "fmt"
)

func main() {
    var a, b, c int
    fmt.Scanf("%d%d%d", &a, &b, &c)
    x := 2 * a + 2 * b
    y := a + b + c
    if x < y {
        fmt.Println(x)
    } else {
        fmt.Println(y)
    }
}

package main

import "fmt"

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

func main() {
	var d1, d2, d3 int
	fmt.Scanf("%d %d %d", &d1, &d2, &d3)

	ret := min(d1 + min(d1 + 2 * d2, d3 + d2),
			   d2 + min(d2 + 2 * d1, d3 + d1))
	fmt.Printf("%d", ret)
}

package main

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

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

type MySlice [][2]int

func (slice MySlice) Len() int           { return len(slice) }
func (slice MySlice) Less(i, j int) bool { return slice[i][1] < slice[j][1] }
func (slice MySlice) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}

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

	d1 := scanInt()
	d2 := scanInt()
	d3 := scanInt()

	if d3+d2+d1 < 2*(d1+d2) {
		writer.WriteString(strconv.Itoa(d3 + d2 + d1))
	} else {
		writer.WriteString(strconv.Itoa(2 * (d1 + d2)))
	}

	return
}

func binSearch(a []int, key int) int {
	l := -1
	r := len(a)
	for l < r-1 {
		m := (l + r) / 2
		if a[m] < key {
			l = m
		} else {
			r = m
		}
	}

	if a[r] != key {
		return -1
	}

	return r
}

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