Polycarpus has a ribbon, its length is n. He wants to cut the ribbon in a way that fulfils the following two conditions:   After the cutting each ribbon piece should have length a, b or c.  After the cutting the number of ribbon pieces should be maximum. Help Polycarpus and find the number of ribbon pieces after the required cutting.

The first line contains four space-separated integers n, a, b and c (1 ≤ n, a, b, c ≤ 4000) — the length of the original ribbon and the acceptable lengths of the ribbon pieces after the cutting, correspondingly. The numbers a, b and c can coincide.

Print a single number — the maximum possible number of ribbon pieces. It is guaranteed that at least one correct ribbon cutting exists.

NoteIn the first example Polycarpus can cut the ribbon in such way: the first piece has length 2, the second piece has length 3.In the second example Polycarpus can cut the ribbon in such way: the first piece has length 5, the second piece has length 2.

package main

import "fmt"
import "sort"

func main() {
	var n, a, b, c int
	fmt.Scan(&n, &a, &b, &c)
	//maxP := bruteForce(n, a, b, c)
	maxP := dp(n, a, b, c)
	fmt.Print(maxP)
}

func dp(n, a, b, c int) int {
	dp := make([]int, 4001)
	dp[a] = 1
	dp[b] = 1
	dp[c] = 1
	for i := 1; i <= n; i++ {
		dp[i] = max(dp, i, i-a, i-b, i-c)
	}
	return dp[n]
}

func max(dp []int, nrs ...int) int {
	m := dp[nrs[0]]
	for _, nr := range nrs[1:] {
		if nr < 0 || dp[nr] == 0 {
			continue
		}
		if dp[nr]+1 > m {
			m = dp[nr] + 1
		}
	}
	return m
}

func bruteForce(n, a, b, c int) int {
	var maxP int
	ls := []int{a, b, c}
	sort.Sort(sort.Reverse(sort.IntSlice(ls)))
	for i := 0; i <= n/ls[0]; i++ {
		for j := 0; j <= n/ls[1]; j++ {
			d := n - i*ls[0] - j*ls[1]
			if d%ls[2] == 0 {
				k := d / ls[2]
				if maxP < i+j+k {
					maxP = i + j + k
				}
			}
		}
	}
	return maxP
}

package main

import "fmt"
import "sort"

func main() {
	var n, a, b, c int
	fmt.Scan(&n, &a, &b, &c)
	var maxP int
	ls := []int{a, b, c}
	sort.Sort(sort.Reverse(sort.IntSlice(ls)))
	for i := 0; i <= n/ls[0]; i++ {
		for j := 0; j <= n/ls[1]; j++ {
			d := n - i*ls[0] - j*ls[1]
			if d%ls[2] == 0 {
				k := d / ls[2]
				if maxP < i+j+k {
					maxP = i + j + k
				}
			}
		}
	}
	fmt.Print(maxP)
}

package main

import (
	"math"
	"fmt"
)

const maxN = 4000

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

	return a
}

func resolver(a, b, c, n int) int {
	if n > maxN {
		panic("Limit exceeded")
	}

	memo := make([]int, maxN + 1)
	units := make([]int, 3)

	units[0], units[1], units[2] = a, b, c
	memo[0] = 0
	memo[a] = 1
	memo[b] = 1
	memo[c] = 1

	for i := 1; i <= n; i++ {
		var localMax int = math.MinInt32

		for _, v := range(units) {
			if delta := i - v; delta >= 0 && delta <= n {
				var localMaxCand int = intMax(localMax, memo[delta] + 1)

				if localMaxCand > localMax {
					localMax = localMaxCand
					memo[i] = localMax
				}
			}
		}

		memo[i] = localMax
	}

	return memo[n]
}

func main() {
	var n, a, b, c int
	fmt.Scanln(&n, &a, &b, &c)

	fmt.Println(resolver(a, b, c, n))
}

package main

import "fmt"

var dp [8005]int

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

	dp[a], dp[b], dp[c] = 1, 1, 1
	for i := 1; i <= n; i++ {
		if dp[i] > 0 {
			dp[i+a] = max(dp[i+a], dp[i]+1)
			dp[i+b] = max(dp[i+b], dp[i]+1)
			dp[i+c] = max(dp[i+c], dp[i]+1)
		}
	}

	fmt.Println(dp[n])
}

func max(x, y int) int {
	if x < y {
		x = y
	}

	return x
}

package main

import "fmt"

var dp [4005]int

func main() {
	var n, a, b, c int
	fmt.Scan(&n, &a, &b, &c)
	if a > b {
		a, b = b, a
	}
	if a > c {
		a, c = c, a
	}
	if b > c {
		b, c = c, b
	}

	for i := 1; i < len(dp); i++ {
		dp[i] = -100000
	}
	for i := a; i <= n; i++ {
		dp[i] = max(dp[i], dp[i-a]+1)
		if i >= b {
			dp[i] = max(dp[i], dp[i-b]+1)
		}
		if i >= c {
			dp[i] = max(dp[i], dp[i-c]+1)
		}
	}

	fmt.Println(dp[n])
}

func max(x, y int) int {
	if x < y {
		x = y
	}

	return x
}

package main

import "fmt"

func main() {
	var n, a, b, c int
	fmt.Scan(&n, &a, &b, &c)
	if a > b {
		a, b = b, a
	}
	if a > c {
		a, c = c, a
	}
	if b > c {
		b, c = c, b
	}

	n1 := n / a
	n2 := n / b
	n3 := n / c
	if n%a == 0 || (a == b && b == c) {
		fmt.Println(n1)
		return
	}

	max := 0
	if a == b || b == c {
		for i := 0; i <= n1; i++ {
			for j := 0; j <= n3; j++ {
				v := i*a + j*c
				if v >= n {
					if v == n && i+j > max {
						max = i + j
					}
					break
				}
			}
		}
		fmt.Println(max)
		return
	}

	for i := 0; i <= n1; i++ {
		for j := 0; j <= n2; j++ {
			for k := 0; k <= n3; k++ {
				v := i*a + j*b + k*c
				if v >= n {
					if v == n && i+j+k > max {
						max = i + j + k
					}
					break
				}
			}
		}
	}

	fmt.Println(max)
}

package main

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

var reader *bufio.Reader

func init() {
	stdin := os.Stdin
	// stdin, _ = os.Open("1.in")
	reader = bufio.NewReaderSize(stdin, 1<<20)
}

var n int
var a [3]int

func main() {
	fmt.Fscan(reader, &n, &a[0], &a[1], &a[2])
	dp := make([]int, n+1)
	ok := make([]bool, n+1)
	ok[0] = true
	for i := 1; i <= n; i++ {
		for j := 0; j < 3; j++ {
			if i >= a[j] && dp[i] < dp[i-a[j]]+1 && ok[i-a[j]] {
				dp[i] = dp[i-a[j]] + 1
				ok[i] = true
			}
		}
	}
	fmt.Println(dp[n])
}

package main

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

var DEBUG = true

func main() {
	defer Flush()

	n := readi()
	a := readi()
	b := readi()
	c := readi()

	dp := make([]int, n+1)
	for i := range dp {
		dp[i] = -1
	}
	dp[0] = 0

	for i := 0; i <= n; i++ {
		if dp[i] < 0 {
			continue
		}
		for _, v := range []int{a, b, c} {
			j := i + v
			if n < j {
				continue
			}
			dp[j] = max(dp[j], dp[i]+1)
		}
	}
	println(dp[n])
}

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

// 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[:len(b):len(b)]
}

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

// Read next line as []byte.  Trailing '\n' will not be included.
// See also comments on readb()
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(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...)
}

func dbgf(f string, args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintf(os.Stderr, f, args...)
}

func dbg(args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintln(os.Stderr, args...)
}

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

// Utilities

func sumSlice(a []int) int {
	var res int
	for _, v := range a {
		res += v
	}
	return res
}

func sumSlicell(a []int64) int64 {
	var res int64
	for _, v := range a {
		res += v
	}
	return res
}

func readInts(N int) (int, []int) {
	if N == 0 {
		N = readi()
	}
	a := make([]int, N)
	for i := range a {
		a[i] = readi()
	}
	return N, a
}

func readIntsll(N int) (int, []int64) {
	if N == 0 {
		N = readi()
	}
	a := make([]int64, N)
	for i := range a {
		a[i] = readll()
	}
	return N, a
}

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

// 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 minf(a, b float64) float64 {
	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 maxf(a, b float64) float64 {
	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
}

func absf(a float64) float64 {
	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)
}

package main

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

var DEBUG = true

func main() {
	defer Flush()

	n := readi()
	a := readi()
	b := readi()
	c := readi()

	var ans int
	for i := 0; i*a <= n; i++ {
		for j := 0; j*b <= n-i*a; j++ {
			m := n - i*a - j*b
			if m%c == 0 {
				ans = max(ans, i+j+m/c)
			}
		}
	}
	println(ans)
}

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

// 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[:len(b):len(b)]
}

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

// Read next line as []byte.  Trailing '\n' will not be included.
// See also comments on readb()
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(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...)
}

func dbgf(f string, args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintf(os.Stderr, f, args...)
}

func dbg(args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintln(os.Stderr, args...)
}

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

// Utilities

func sumSlice(a []int) int {
	var res int
	for _, v := range a {
		res += v
	}
	return res
}

func sumSlicell(a []int64) int64 {
	var res int64
	for _, v := range a {
		res += v
	}
	return res
}

func readInts(N int) (int, []int) {
	if N == 0 {
		N = readi()
	}
	a := make([]int, N)
	for i := range a {
		a[i] = readi()
	}
	return N, a
}

func readIntsll(N int) (int, []int64) {
	if N == 0 {
		N = readi()
	}
	a := make([]int64, N)
	for i := range a {
		a[i] = readll()
	}
	return N, a
}

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

// 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 minf(a, b float64) float64 {
	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 maxf(a, b float64) float64 {
	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
}

func absf(a float64) float64 {
	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)
}

package main

import (
	"fmt"
)

func main() {
	var n,a,b,c int
	s:=0
	fmt.Scan(&n,&a,&b,&c)
	for i:=0;i<=n/a;i++ {
		z:=n-i*a
		for k:=0; k<=z/b;k++ {
			h:=i+k+(z-k*b)/c
			if (z-k*b)%c==0 && h>s {
				s=h
			}
		}
	}
	fmt.Println(s)
}

package main

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

func MaxOf(vars ...int) int {
	max := vars[0]

	for _, i := range vars {
		if max < i {
			max = i
		}
	}

	return max
}

func main() {
	var reader io.Reader
	var writer io.Writer

	reader = os.Stdin
	writer = os.Stdout

	//file, _ := os.Open("input.txt")
	//reader = file

	var n, a, b, c int

	fmt.Fscanf(reader, "%d %d %d %d", &n, &a, &b, &c)

	f := make([]int, n+a+b+c+1)
	f[a] = 1
	f[b] = 1
	f[c] = 1

	for i := 0; i <= n; i++ {
		if i >= a && f[i-a] != 0 {
			f[i] = MaxOf(f[i-a]+1, f[i])
		}
		if i >= b && f[i-b] != 0 {
			f[i] = MaxOf(f[i-b]+1, f[i])
		}
		if i >= c && f[i-c] != 0 {
			f[i] = MaxOf(f[i-c]+1, f[i])
		}
	}

	fmt.Fprintln(writer, f[n])

}

package main

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

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

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

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

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

func pri(n int)    { w.WriteString(strconv.Itoa(n)) }
func prll(n int64) { w.WriteString(strconv.FormatInt(n, 10)) }
func sp()          { w.WriteByte(' ') }
func endl()        { w.WriteByte('\n') }

func main() {
  sc.Split(bufio.ScanWords)
  n, a, b, c := ni(), ni(), ni(), ni()
  max := 0
  for i := 0; i*a <= n; i++ {
    for j := 0; j*b <= n-i*a; j++ {
      n2 := n - i*a - j*b
      if n2%c == 0 && n2/c+i+j > max {
        max = n2/c + i + j
      }
    }
  }
  pri(max)
  w.Flush()
}

package main

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

func Readln(r *bufio.Reader) (string, error) {
	var (
		isPrefix bool  = true
		err      error = nil
		line, ln []byte
	)
	for isPrefix && err == nil {
		line, isPrefix, err = r.ReadLine()
		ln = append(ln, line...)
	}
	return string(ln), err
}

func readIntArray(line string) []int {

	numStrings := strings.Split(strings.TrimSpace(string(line)), " ")

	numbers := make([]int, 0)

	for _, v := range numStrings {
		var converted int

		fmt.Sscanf(v, "%d", &converted)
		numbers = append(numbers, converted)
	}

	return numbers
}

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

	line, _ := Readln(reader)
	numbers := readIntArray(line)

	length := numbers[0]
	lengths := numbers[1:]

	cache := make(map[int]int, 0)
	sort.Ints(lengths)
	fmt.Println(Cut(length, lengths, 0, cache))
}

func Cut(length int, lengths []int, pieces int, cache map[int]int) int {

	if cached, ok := cache[length]; ok {
		return cached
	}

	maxPieces := pieces
	isCut := false
	for _, ln := range lengths {
		if (length - ln) >= 0 {
			newPieces := Cut(length - ln, lengths, pieces + 1, cache)
			if maxPieces < newPieces {
				isCut = true
				maxPieces = newPieces
			}
		}
	}

	if (!isCut) && length > 0 {
		maxPieces = -1
		cache[length] = maxPieces
	} else if isCut {
		cache[length] = maxPieces
	}

	return maxPieces
}

package main

import "fmt"

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

func main() {

    var n int

    var a [3]int

    fmt.Scan(&n,&a[0],&a[1],&a[2])

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

    dp[0] = 0

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

        dp[i] = -999999999

        for k := 0; k < 3; k++ {

            if (i-a[k]) >= 0 {

                dp[i] = max(dp[i],1+dp[i-a[k]])

            }

        }

    }

    fmt.Println(dp[n])

}

package main

import "fmt"

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

func main() {
	var n int
	var a [3]int
	fmt.Scan(&n, &a[0], &a[1], &a[2])
	dp := make([]int, n+1)
	dp[0] = 0
	for i := 1; i <= n; i++ {
		dp[i] = -999999999
		for k := 0; k < 3; k++ {
			if (i - a[k]) >= 0 {
				dp[i] = max(dp[i], 1+dp[i-a[k]])
			}
		}
	}
	fmt.Println(dp[n])
}

package main

import "fmt"

const maxn = 4000 + 10

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

func main() {
	var n, a, b, c int
	var dp [maxn]int
	fmt.Scan(&n, &a, &b, &c)
	dp[0] = 0
	for i := 1; i <= n; i++ {
		dp[i] = -0x3f3f3f3f
	}
	for i := 1; i <= n; i++ {
		if i >= a {
			dp[i] = max(dp[i], dp[i-a]+1)
		}
		if i >= b {
			dp[i] = max(dp[i], dp[i-b]+1)
		}
		if i >= c {
			dp[i] = max(dp[i], dp[i-c]+1)
		}
	}
	if dp[n] < 0 {
		dp[n] = 0
	}
	fmt.Printf("%d\n", dp[n])
}

package main

import "fmt"

// https://codeforces.com/problemset/problem/189/A
// комментарии к решению
// Задача решается полным перебором. Для сокращения кол-ва операций
// итерируемся с максимального возможного вниз, т.к. в цикле for
// вычисления из init производяться один раз (сокращается кол-во операций)
func taskSolution(n, a, b, c int) int {
	max := 0
	for i := n / a; i >= 0; i -= 1 {
		for j := (n - i*a) / b; j >= 0; j -= 1 {
			left := n - i*a - j*b
			if left%c == 0 && max < i+j+left/c {
				max = i + j + left/c
			}
		}
	}
	return max
}

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

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

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

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

func main() {
  defer writer.Flush()
  var n, a, b, c int
  scanf("%d %d %d %d\n", &n, &a, &b, &c)

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

  for i, _ := range dp {
    dp[i] = -1
  }
  dp[0] = 0

  for i:=1; i <= n; i++ {
    for _, j := range []int{a, b, c} {
      if i-j >= 0 && dp[i-j] != -1 {
        dp[i] = max(dp[i], dp[i-j]+1)
      }
    }
  }
  printf("%d\n", dp[n])
}

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

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

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

const (
	MOD = 1e9 + 7
)

type (

)

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

	return b
}

func main () {
	var (
		n, a, b, c int
	)

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

	fmt.Fscanln(input, &n, &a, &b, &c)

	dp := make([]struct{cnt, l int}, 1e4 + 1)

	dp[0].l = n
	dp[0].l = n
	dp[0].l = n

	for i := 0; i <= n; i++ {
		if dp[i].cnt + 1 > dp[i + a].cnt && dp[i].l - a >= 0 {
			dp[i + a].cnt = dp[i].cnt + 1
			dp[i + a].l = dp[i].l - a
		}

		if dp[i].cnt + 1 > dp[i + b].cnt && dp[i].l - b >= 0 {
			dp[i + b].cnt = dp[i].cnt + 1
			dp[i + b].l = dp[i].l - b
		}

		if dp[i].cnt + 1 > dp[i + c].cnt && dp[i].l - c >= 0 {
			dp[i + c].cnt = dp[i].cnt + 1
			dp[i + c].l = dp[i].l - c
		}
	}

	fmt.Println(max(max(dp[n].cnt, dp[n].cnt), dp[n].cnt))
}

package main

import (
	"fmt"
)

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

func main() {
	var n, a, b, c int
	t := []int{0}
	fmt.Scanf("%d %d %d %d \n", &n, &a, &b, &c)
	for i := 1; i <= n; i++ {
		t = append(t, -1)
		if i >= a && t[i-a] != -1 {
			t[i] = max(t[i], t[i-a]+1)
		}
		if i >= b && t[i-b] != -1 {
			t[i] = max(t[i], t[i-b]+1)
		}
		if i >= c && t[i-c] != -1 {
			t[i] = max(t[i], t[i-c]+1)
		}
	}
	fmt.Print(t[n])
}

package main

import "fmt"

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

func main() {
    var n int
    var a [3]int
    fmt.Scan(&n,&a[0],&a[1],&a[2])
    dp := make([]int,n+1)
    dp[0] = 0
    for i := 1; i <= n; i++ {
        dp[i] = -999999999
        for k := 0; k < 3; k++ {
            if (i-a[k]) >= 0 {
                dp[i] = max(dp[i],1+dp[i-a[k]])
            }
        }
    }
    fmt.Println(dp[n])
}

package main

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

var n, a, b, c int
var res []int

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	raw := scanner.Text()
	segs := strings.Split(raw, " ")
	n, _ = strconv.Atoi(segs[0])
	a, _ = strconv.Atoi(segs[1])
	b, _ = strconv.Atoi(segs[2])
	c, _ = strconv.Atoi(segs[3])

	d := Do()
	fmt.Println(d)
}

func Do() int {
	res = make([]int, n+1, n+1)
	for idx := 1; idx <= n; idx++ {
		res[idx] = Cut(idx)
		// fmt.Println("res", idx, res)
	}
	return res[n]
}

func Cut(idx int) int {
	if idx == 0 {
		return 0
	}
	max := 0
	if idx >= a {
		left := idx - a
		if left == 0 {
			max = 1
			goto bnote
		} else {
			if res[left] == 0 {
				max = 0
				goto bnote
			} else {
				max = 1 + res[left]
			}
		}
	}
bnote:
	bmax := 0
	{
		if idx >= b {
			left := idx - b
			if left == 0 {
				bmax = 1
				goto cnote
			} else {
				if res[left] == 0 {
					bmax = 0
					goto cnote
				} else {
					bmax = 1 + res[left]
				}
			}
		}
	}
cnote:
	cmax := 0
	{
		if idx >= c {
			left := idx - c
			if left == 0 {
				cmax = 1
				goto over
			} else {
				if res[left] == 0 {
					cmax = 0
					goto over
				} else {
					cmax = 1 + res[left]
				}
			}
		}
	}
over:
	{
		zhi := max3(max, bmax, cmax)
		return zhi
	}
}

func max3(a, b, c int) int {
	res := []int{a, b, c}
	// fmt.Println(res)
	sort.Ints(res)
	return res[2]
}

package main

import "fmt"

func Max(a, b int) int {
    result := a
    if b > a {
        result = b
    }

    return result
}

func main() {
    var n, a, b, c int
    fmt.Scanln(&n, &a, &b, &c)

    arr := []int{a, b, c}
    dp := make([]int, n + 1)
    dp[0] = 1

    for i := 1; i <= n; i++ {
        var max int = 0
        for _, v := range arr {
            var cur_i int = i - v
            if cur_i >= 0 && dp[cur_i] != 0 {
                max = Max(max, dp[cur_i] + 1)
            }
        }

        dp[i] = max
    }

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

package main

import "fmt"
import "sort"

func main() {
	var n, a, b, c int
	fmt.Scan(&n, &a, &b, &c)
	//maxP := bruteForce(n, a, b, c)
	maxP := dp(n, a, b, c)
	fmt.Print(maxP)
}

func dp(n, a, b, c int) int {
	dp := make([]int, n+1)
	dp[a] = 1
	dp[b] = 1
	dp[c] = 1
	for i := 1; i <= n; i++ {
		if i-a > 0 && a != 0 {
			dp[i] = max(dp[i], dp[i-a]+1)
			continue
		}
		if i-b > 0 && b != 0 {
			dp[i] = max(dp[i], dp[i-b]+1)
			continue
		}
		if i-c > 0 && c != 0 {
			dp[i] = max(dp[i], dp[i-c]+1)
			continue
		}
	}
	return dp[n]
}

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

func bruteForce(n, a, b, c int) int {
	var maxP int
	ls := []int{a, b, c}
	sort.Sort(sort.Reverse(sort.IntSlice(ls)))
	for i := 0; i <= n/ls[0]; i++ {
		for j := 0; j <= n/ls[1]; j++ {
			d := n - i*ls[0] - j*ls[1]
			if d%ls[2] == 0 {
				k := d / ls[2]
				if maxP < i+j+k {
					maxP = i + j + k
				}
			}
		}
	}
	return maxP
}

package main

import (
	"math"
	"fmt"
)

const maxN = 4000

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

	return a
}

func resolver(a, b, c, n int) int {
	if n > maxN {
		panic("Limit exceeded")
	}

	memo := make([]int, n+1)
	units := make([]int, 3)

	units[0], units[1], units[2] = a, b, c
	memo[0] = 0
	memo[a] = 1
	memo[b] = 1
	memo[c] = 1

	for i := 1; i <= n; i++ {
		var localMax int = math.MinInt32

		for _, v := range(units) {
			if delta := i - v; delta >= 0 {
				var localMaxCand int = intMax(memo[i], memo[delta] + 1)

				if localMaxCand > localMax {
					localMax = localMaxCand
					memo[i] = localMax
				}
			}
		}

		memo[i] = localMax
	}

	return memo[n]
}

func main() {
	var n, a, b, c int
	fmt.Scanln(&n, &a, &b, &c)

	fmt.Println(resolver(a, b, c, n))
}

package main

import "fmt"

var dp [4005]int

func main() {
	var n, a, b, c int
	fmt.Scan(&n, &a, &b, &c)
	if a > b {
		a, b = b, a
	}
	if a > c {
		a, c = c, a
	}
	if b > c {
		b, c = c, b
	}

	for i := 1; i < len(dp); i++ {
		dp[i] = -100000
	}
	for i := a; i <= n; i++ {
		dp[i] = dp[i-a] + 1
		if i > b {
			dp[i] = max(dp[i], dp[i-b]+1)
		}
		if i > c {
			dp[i] = max(dp[i], dp[i-c]+1)
		}
	}

	fmt.Println(dp[n])
}

func max(x, y int) int {
	if x < y {
		x = y
	}

	return x
}

package main

import "fmt"

var dp [4005]int

func main() {
	var n, a, b, c int
	fmt.Scan(&n, &a, &b, &c)
	if a > b {
		a, b = b, a
	}
	if a > c {
		a, c = c, a
	}
	if b > c {
		b, c = c, b
	}

	dp[a], dp[b], dp[c] = 1, 1, 1
	for i := a; i <= n; i++ {
		dp[i] = dp[i-a] + 1
		if i > b {
			dp[i] = max(dp[i], dp[i-b]+1)
		}
		if i > c {
			dp[i] = max(dp[i], dp[i-c]+1)
		}
	}

	fmt.Println(dp[n])
}

func max(x, y int) int {
	if x < y {
		x = y
	}

	return x
}

package main

import "fmt"

func main() {
	var n, a, b, c int
	fmt.Scan(&n, &a, &b, &c)
	if a > b {
		a, b = b, a
	}
	if a > c {
		a, c = c, a
	}
	if b > c {
		b, c = c, b
	}

	n1 := n / a
	n2 := n / b
	n3 := n / c
	if n%a == 0 || (a == b && b == c) {
		fmt.Println(n1)
		return
	}

	max := 0
	if a == b || b == c {
		for i := 0; i < n1; i++ {
			for j := 0; j < n3; j++ {
				v := i*a + j*c
				if v >= n {
					if v == n && i+j > max {
						max = i + j
					}
					break
				}
			}
		}
		fmt.Println(max)
		return
	}

	for i := 0; i <= n1; i++ {
		for j := 0; j <= n2; j++ {
			for k := 0; k <= n3; k++ {
				v := i*a + j*b + k*c
				if v >= n {
					if v == n && i+j+k > max {
						max = i + j + k
					}
					break
				}
			}
		}
	}

	fmt.Println(max)
}

package main

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

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

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

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

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

func pri(n int)    { w.WriteString(strconv.Itoa(n)) }
func prll(n int64) { w.WriteString(strconv.FormatInt(n, 10)) }
func sp()          { w.WriteByte(' ') }
func endl()        { w.WriteByte('\n') }

func dioph(b, c, n int) (int, bool) {
  max := 0
  noerr := false
  for k := 0; k*b <= n; k++ {
    if (n-k*b)%c == 0 && k+(n-k*b)/c > max {
      max = k + (n-k*b)/c
      noerr = true
    }
  }
  return max, noerr
}

func main() {
  sc.Split(bufio.ScanWords)
  n, a, b, c := ni(), ni(), ni(), ni()
  max := 0
  for k := 0; k*a <= n; k++ {
    k2, noerr := dioph(b, c, n-k*a)
    if noerr && k+k2 > max {
      max = k + k2
    }
  }
  pri(max)
  w.Flush()
}

package main

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

func Readln(r *bufio.Reader) (string, error) {
	var (
		isPrefix bool  = true
		err      error = nil
		line, ln []byte
	)
	for isPrefix && err == nil {
		line, isPrefix, err = r.ReadLine()
		ln = append(ln, line...)
	}
	return string(ln), err
}

func readIntArray(line string) []int {

	numStrings := strings.Split(strings.TrimSpace(string(line)), " ")

	numbers := make([]int, 0)

	for _, v := range numStrings {
		var converted int

		fmt.Sscanf(v, "%d", &converted)
		numbers = append(numbers, converted)
	}

	return numbers
}

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

	line, _ := Readln(reader)
	numbers := readIntArray(line)

	length := numbers[0]
	lengths := numbers[1:]

	cache := make(map[int]int, 0)
	fmt.Println(Cut(length, lengths, 0, cache))
}

func Cut(length int, lengths []int, pieces int, cache map[int]int) int {

	if cached, ok := cache[length]; ok {
		return cached
	}

	maxPieces := pieces
	isCut := false
	for _, ln := range lengths {
		if (length - ln) >= 0 {
			newPieces := Cut(length - ln, lengths, pieces + 1, cache)
			if maxPieces < newPieces {
				isCut = true
				maxPieces = newPieces
			}
		}
	}

	if (!isCut) && length > 0 {
		maxPieces = -1
		cache[length] = maxPieces
	} else if isCut {
		cache[length] = maxPieces
	}

	return maxPieces
}

package main

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

func Readln(r *bufio.Reader) (string, error) {
	var (
		isPrefix bool  = true
		err      error = nil
		line, ln []byte
	)
	for isPrefix && err == nil {
		line, isPrefix, err = r.ReadLine()
		ln = append(ln, line...)
	}
	return string(ln), err
}

func readIntArray(line string) []int {

	numStrings := strings.Split(strings.TrimSpace(string(line)), " ")

	numbers := make([]int, 0)

	for _, v := range numStrings {
		var converted int

		fmt.Sscanf(v, "%d", &converted)
		numbers = append(numbers, converted)
	}

	return numbers
}

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

	line, _ := Readln(reader)
	numbers := readIntArray(line)

	length := numbers[0]
	lengths := numbers[1:]

	cache := make(map[int]int, 0)
	fmt.Println(Cut(length, lengths, 0, cache))
}

func Cut(length int, lengths []int, pieces int, cache map[int]int) int {

	if cached, ok := cache[length]; ok {
		return cached
	}

	maxPieces := pieces
	isCut := false
	for _, ln := range lengths {
		if (length - ln) >= 0 {
			isCut = true
			newPieces := Cut(length - ln, lengths, pieces + 1, cache)
			if maxPieces < newPieces {
				maxPieces = newPieces
			}
		}
	}

	if (isCut == false) && length > 0 {
		maxPieces = -1
		cache[length] = maxPieces
	} else if isCut {
		cache[length] = maxPieces
	}

	return maxPieces
}

package main

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

func Readln(r *bufio.Reader) (string, error) {
	var (
		isPrefix bool  = true
		err      error = nil
		line, ln []byte
	)
	for isPrefix && err == nil {
		line, isPrefix, err = r.ReadLine()
		ln = append(ln, line...)
	}
	return string(ln), err
}

func readIntArray(line string) []int {

	numStrings := strings.Split(strings.TrimSpace(string(line)), " ")

	numbers := make([]int, 0)

	for _, v := range numStrings {
		var converted int

		fmt.Sscanf(v, "%d", &converted)
		numbers = append(numbers, converted)
	}

	return numbers
}

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

	line, _ := Readln(reader)
	numbers := readIntArray(line)

	length := numbers[0]
	lengths := numbers[1:]

	cache := make(map[int]int, 0)
	fmt.Println(Cut(length, lengths, 0, cache))
}

func Cut(length int, lengths []int, pieces int, cache map[int]int) int {

	if cached, ok := cache[length]; ok {
		return cached
	}

	maxPieces := pieces
	isCut := false
	for _, ln := range lengths {
		if (length - ln) >= 0 {
			isCut = true
			newPieces := Cut(length - ln, lengths, pieces + 1, cache)
			if maxPieces < newPieces {
				maxPieces = newPieces
			}
		}
	}

	if (isCut == false) && length > 0 {
		maxPieces = -1
	}

	cache[length] = maxPieces

	return maxPieces
}

package main

import "fmt"

func sortThree(a, b, c int) (int, int, int) {
	if a > b {
		a, b = b, a
	}
	if b > c {
		b, c = c, b
	}
	if a > b {
		a, b = b, a
	}
	return a, b, c
}

// https://codeforces.com/problemset/problem/189/A
// комментарии к решению
// Задача решается перебором. Для сокращения кол-ва комбинаций
// пытаемся сначала разрезать ленту на максимальное кол-во мелких кусочков,
// уменьшая их кол-во с каждой итерацией пробуем разрезать оставшуюся часть
// на ленты среднего размера, проводя аналогичный критерий выбора для
// среднего/крупного размера.
// Первое найденное целочисленное решение и будет ответом
func taskSolution(n, a, b, c int) int {
	a, b, c = sortThree(a, b, c)
	for i := n / a; i >= 0; i -= 1 {
		for j := (n - i*a) / b; j >= 0; j -= 1 {
			for k := (n - i*a - j*b) / c; k >= 0; k -= 1 {
				if n == i*a+j*b+k*c {
					return i + j + k
				}
			}
		}
	}
	return 0
}

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

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

package main

import (
	"fmt"
)

func main() {
	var n,a,b,c int
	s:=0
	fmt.Scan(&n,&a,&b,&c)
	for i:=0;i<=n/a;i++ {
		z:=n-i*a
		for k:=0; k<=z/b;k++ {
			h:=i+k+(z-k*b)/c
			if (z-k*b)%c!=0 && h>s {
				s=h
			}
		}
	}
	fmt.Println(s)
}

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

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

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

const (
	MOD = 1e9 + 7
)

type (

)

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

	return b
}

func main () {
	var (
		n, a, b, c int
	)

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

	fmt.Fscanln(input, &n, &a, &b, &c)

	dp := make([]struct{cnt, l int}, 1e4 + 1)

	dp[0].l = n
	dp[0].l = n
	dp[0].l = n

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

		if dp[i].l - a == a || dp[i].l - a == b || dp[i].l - a == c || dp[i].l - a == 0{
			if dp[i].cnt + 1 > dp[i + a].cnt {
				dp[i + a].cnt = dp[i].cnt + 1
				dp[i + a].l = dp[i].l - a
			}
		}

		if dp[i].l - b == a || dp[i].l - b == b || dp[i].l - b == c || dp[i].l - b == 0{
			if dp[i].cnt + 1 > dp[i + b].cnt {
				dp[i + b].cnt = dp[i].cnt + 1
				dp[i + b].l = dp[i].l - b
			}
		}

		if dp[i].l - c == a || dp[i].l - c == b || dp[i].l - c == c || dp[i].l - c == 0{
			if dp[i].cnt + 1 > dp[i + c].cnt {
				dp[i + c].cnt = dp[i].cnt + 1
				dp[i + c].l = dp[i].l - c
			}
		}

	}

	fmt.Println(max(max(dp[n].cnt, dp[n].cnt), dp[n].cnt))
}

package main

import "fmt"

func main() {
    var n int
    var a [3]int
    fmt.Scan(&n,&a[0],&a[1],&a[2])
    dp := make([]int,n+1)
    dp[0] = 1
    for k := 0; k < 3; k++ {
        for i := 1; i <= n; i++ {
            if (i-a[k]) >= 0 {
                dp[i] += dp[i-a[k]]
            }
        }
    }
    fmt.Println(dp[n])
}

package main

import "fmt"
import "sort"

func main() {
	var n, a, b, c int
	fmt.Scan(&n, &a, &b, &c)
	var maxP int
	ls := []int{a, b, c}
	sort.Sort(sort.Reverse(sort.IntSlice(ls)))
	fmt.Println(ls)
	var i, j, k int
	for i = 0; i <= n/ls[0]; i++ {
		for j = 0; j <= n/ls[1]; j++ {
			for k = 0; k <= n/ls[2]; k++ {
				if n == i*ls[0]+j*ls[1]+k*ls[2] {
					if maxP < i+j+k {
						maxP = i + j + k
					}
				}
			}
		}
	}
	fmt.Print(maxP)
}


You've got a rectangular table with length a and width b and the infinite number of plates of radius r. Two players play the following game: they take turns to put the plates on the table so that the plates don't lie on each other (but they can touch each other), and so that any point on any plate is located within the table's border. During the game one cannot move the plates that already lie on the table. The player who cannot make another move loses. Determine which player wins, the one who moves first or the one who moves second, provided that both players play optimally well.

A single line contains three space-separated integers a, b, r (1 ≤ a, b, r ≤ 100) — the table sides and the plates' radius, correspondingly.

If wins the player who moves first, print "First" (without the quotes). Otherwise print "Second" (without the quotes).

NoteIn the first sample the table has place for only one plate. The first player puts a plate on the table, the second player can't do that and loses.  In the second sample the table is so small that it doesn't have enough place even for one plate. So the first player loses without making a single move.

package main

import "fmt"

func main() {
	a, b, r := 0, 0, 0
	fmt.Scanf("%d %d %d\n", &a, &b, &r)
	if a >= r*2 && b >= r*2 {
		fmt.Printf("First\n")
	} else {
		fmt.Printf("Second\n")
	}
}

package main

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

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

	if a >= r*2 && b >= r*2 {
		fmt.Printf("First\n")
	} else {
		fmt.Printf("Second\n")
	}
}

package main

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

func scanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	x, _ := strconv.Atoi(scanner.Text())
	return x
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	a, b, r := scanInt(scanner), scanInt(scanner), scanInt(scanner)
	if a >= 2*r && b >= 2*r {
		writer.WriteString("First\n")
	} else {
		writer.WriteString("Second\n")
	}
}

package main

import (
	"fmt"
)

func main() {
	a, b, r := 0, 0, 0
	fmt.Scanf("%d %d %d\n", &a, &b, &r)
	winner := "Second"
	var xDiameter float32
	if a > b {
		xDiameter = float32(a) / float32(r*2)
	} else {
		xDiameter = float32(b) / float32(r*2)
	}
	if xDiameter >= 1 && int32((xDiameter-1)/1.5)%2 == 0 {
		winner = "First"
	}
	fmt.Printf("%s\n", winner)
}


Arpa is taking a geometry exam. Here is the last problem of the exam.You are given three points a, b, c.Find a point and an angle such that if we rotate the page around the point by the angle, the new position of a is the same as the old position of b, and the new position of b is the same as the old position of c.Arpa is doubting if the problem has a solution or not (i.e. if there exists a point and an angle satisfying the condition). Help Arpa determine if the question has a solution or not.

The only line contains six integers ax, ay, bx, by, cx, cy (|ax|, |ay|, |bx|, |by|, |cx|, |cy| ≤ 109). It's guaranteed that the points are distinct.

Print "Yes" if the problem has a solution, "No" otherwise. You can print each letter in any case (upper or lower).

NoteIn the first sample test, rotate the page around (0.5, 0.5) by .In the second sample test, you can't find any solution.

package main

import "fmt"

func main() {
	var ax,ay,bx,by,cx,cy int64
	fmt.Scanf("%d%d%d%d%d%d",&ax,&ay,&bx,&by,&cx,&cy)
	ax*=2
	ay*=2
	bx*=2
	by*=2
	cx*=2
	cy*=2
	dx:=(ax+cx)/2
	dy:=(ay+cy)/2
	ux := bx - ax
	uy := by - ay
	vx := bx - cx
	vy := by - cy
	ra := ux * ux + uy * uy;
	rc := vx * vx + vy * vy;
	if !(dx == bx && dy == by) && ra == rc {
		fmt.Printf("Yes")
	}else{
		fmt.Printf("No")
	};
}

// Codeforces 785 B Anton and Classes done
package main

import (
	"bufio"
	"fmt"
	"strings"
	"strconv"
	"os"
)
var in *bufio.Reader

func readFive() (int,int,int,int,int) {
	var a [5]int
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("first read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for i:=0; i<len(ss); i++ {
		a[i], err = strconv.Atoi(ss[i])
		if err != nil {
			fmt.Println("n atoi failure", err)
			panic(err)
		}
	}
	return a[0],a[1],a[2],a[3],a[4]
}

func readLineNumbs(n int) []int {
	a := make([]int, n)
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for j:=0; j<n; j++ {
		aa,err := strconv.Atoi(ss[j])
		if err != nil {
			fmt.Println("aa conv failed", err)
			panic(err)
		}
		a[j] = aa
	}
	return a
}

var ax,ay,bx,by,cx,cy int64
var haveSol bool

func readData() {
	in = bufio.NewReader(os.Stdin)
	a := readLineNumbs(6)
	ax = int64(a[0])
	ay = int64(a[1])
	bx = int64(a[2])
	by = int64(a[3])
	cx = int64(a[4])
	cy = int64(a[5])
}

func dist2(ax,ay,bx,by int64) int64 {
	dx := bx-ax
	dx = dx*dx
	dy := by-ay
	dy = dy*dy
	return dx+dy
}

func solve() {
	dab := dist2(ax,ay,bx,by)
	dbc := dist2(bx,by,cx,cy)
	if dab!=dbc {
		haveSol = false
		return
	}
	if ((ax-bx)==(bx-cx)) && ((ay-by)==(by-cy)) {
		haveSol = false
	} else {
		haveSol = true
	}
}

func printRes() {
	if haveSol {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func main() {
	readData()
	solve()
	printRes()
}

package main

import (
        "fmt"
)

var (
        ax int64
        ay int64
        bx int64
        by int64
        cx int64
        cy int64
)

func main() {
        fmt.Scanf("%d %d %d %d %d %d\n", &ax, &ay, &bx, &by, &cx, &cy)
        if ((ax-bx)*(ax-bx)+(ay-by)*(ay-by)) == ((bx-cx)*(bx-cx)+(by-cy)*(by-cy)) && (bx-ax)*(cy-by) != (by-ay)*(cx-bx) {
                fmt.Printf("YES\n")
        } else {
                fmt.Printf("NO\n")
        }
}

package main

import "fmt"

func main() {
	var ax, ay, bx, by, cx, cy int64
	fmt.Scan(&ax, &ay, &bx, &by, &cx, &cy)
	cx -= bx
	cy -= by
	bx -= ax
	by -= ay
	if bx*bx+by*by == cx*cx+cy*cy && (bx != cx || by != cy) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

package main

import (
        "fmt"
)

var (
        ax int64
        ay int64
        bx int64
        by int64
        cx int64
        cy int64
)

func main() {
        fmt.Scanf("%d %d %d %d %d %d\n", &ax, &ay, &bx, &by, &cx, &cy)
        if ((ax-bx)*(ax-bx)+(ay-by)*(ay-by)) == ((bx-cx)*(bx-cx)+(by-cy)*(by-cy)) && (bx-ax)*(cy-ay) != (by-ay)*(cx-bx) {
                fmt.Printf("YES\n")
        } else {
                fmt.Printf("NO\n")
        }
}

package main

import "fmt"

func main() {
	var ax, ay, bx, by, cx, cy int
	fmt.Scan(&ax, &ay, &bx, &by, &cx, &cy)
	cx -= bx
	cy -= by
	bx -= ax
	by -= ay
	if bx*bx+by*by == cx*cx+cy*cy && bx != cx {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

package main

import "fmt"

func main() {
	var ax, ay, bx, by, cx, cy int64
	fmt.Scan(&ax, &ay, &bx, &by, &cx, &cy)
	cx -= bx
	cy -= by
	bx -= ax
	by -= ay
	if bx*bx+by*by == cx*cx+cy*cy && bx != cx {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Mashmokh works in a factory. At the end of each day he must turn off all of the lights. The lights on the factory are indexed from 1 to n. There are n buttons in Mashmokh's room indexed from 1 to n as well. If Mashmokh pushes button with index i, then each light with index not less than i that is still turned on turns off.Mashmokh is not very clever. So instead of pushing the first button he pushes some of the buttons randomly each night. He pushed m distinct buttons b1, b2, ..., bm (the buttons were pushed consecutively in the given order) this night. Now he wants to know for each light the index of the button that turned this light off. Please note that the index of button bi is actually bi, not i.Please, help Mashmokh, print these indices.

The first line of the input contains two space-separated integers n and m (1 ≤ n, m ≤ 100), the number of the factory lights and the pushed buttons respectively. The next line contains m distinct space-separated integers b1, b2, ..., bm (1 ≤ bi ≤ n). It is guaranteed that all lights will be turned off after pushing all buttons.

Output n space-separated integers where the i-th number is index of the button that turns the i-th light off.

NoteIn the first sample, after pressing button number 4, lights 4 and 5 are turned off and lights 1, 2 and 3 are still on. Then after pressing button number 3, light number 3 is turned off as well. Pressing button number 1 turns off lights number 1 and 2 as well so pressing button number 2 in the end has no effect. Thus button number 4 turned lights 4 and 5 off, button number 3 turned light 3 off and button number 1 turned light 1 and 2 off.

package main

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

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

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

	n, m := nextInt(), nextInt()

	lights := make([]int, n)
	buttonOff := 0

	for i:=0; i<m; i++ {
		buttonOff = nextInt()

		for j:= buttonOff-1; j<n && lights[j]==0; j++ {
			lights[j] = buttonOff
		}
	}

	for i:=0; i<n; i++ {
		print(lights[i], " ")
	}
}

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

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

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

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

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

package main

import (
	"fmt"
	//"sort"
)

func main() {
	var n,m,x int
	fmt.Scan(&n,&m)
	a:=make([]int,101)
	for i:=0;i<m;i++ {
		fmt.Scan(&x)
		for j:=x;j<=n;j++ {
			if a[j]==0 {
				a[j]=x
			}
		}
	}
	for i:=1;i<=n;i++ {
		fmt.Print(a[i]," ")
	}
}

package main

import (
    "fmt"
)

func main() {
    var t, n, m, cnt int
    var light [110]int
    fmt.Scan(&n, &m)
    cnt = 100000
    for i := 0; i < m; i++ {
        fmt.Scan(&t)
        if t < cnt {
            cnt = t
            light[t] = 1
        }
    }
    for i := 1; i <= n; i++ {
        if light[i] == 1 {
            cnt = i
        }
        fmt.Printf("%d ", cnt)
    }
}

package main

import (
    "fmt"
)

func main() {
    var t, n, m, cnt int
    var light [110]int
    fmt.Scanf("%d %d", &n, &m)
    cnt = 100000
    for i := 0; i < m; {
        c, _ := fmt.Scanf("%d", &t)
        if c == 0 {
            continue
        }
        if t < cnt {
            cnt = t
            light[t] = 1
        }
        i++
    }
    for i := 1; i <= n; i++ {
        if light[i] == 1 {
            cnt = i
        }
        fmt.Printf("%d ", cnt)
    }
}

package main

import "fmt"

func main() {
    var n,m,b int
    var a [105]int
    fmt.Scan(&n,&m)
    for i := 0; i < m; i++ {
        fmt.Scan(&b)
        for j := b; j <= n; j++ {
            if a[j] == 0 { a[j] = b }
        }
    }
    for i := 1; i <= n; i++ {
        fmt.Print(a[i])
        if i == n { fmt.Println() } else { fmt.Print(" ") }
    }
}

package main

import (
	"fmt"
)

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

    fmt.Scan(&n, &m)
    var light []int = make([]int, n)

    for i := 0; i < n; i++ {
        light[i] = 0
    }

    for l := 0; l < m; l++ {
        fmt.Scan(&b)

        b = b - 1
        for i := b; (i < n) && (light[i] == 0); i++ {
            light[i] = b + 1
        }
    }

    for i := 0; i < n; i++ {
        fmt.Printf("%d", light[i])
        if i == n - 1 {
            fmt.Println()
        } else {
            fmt.Printf(" ")
        }
    }

    return
}

package main

import (
	"fmt"
)

/*Simulating the problem of mashmokh and the lights
lights array will contain the current state of the light -1 / -2
0 -> ON
if any other number is present, then the light is switched off with that swtich*/
func main() {
    var n,m,b int
    var light [200]int

    fmt.Scan(&n, &m)

    for l := 0; l < m; l++ {
        fmt.Scan(&b)

        b = b - 1
        for i := b; i < n; i++ {
            if light[i] == 0 {
                light[i] = b + 1
            }
        }
    }

    for i := 0; i < n; i++ {
        fmt.Printf("%d", light[i])
        if i == n - 1 {
            fmt.Println()
        } else {
            fmt.Printf(" ")
        }
    }

    return
}

// 415A-mic
package main

import (
    "fmt"
)

func main() {
    var n, m, x int
    fmt.Scan(&n, &m)
    a := make([]int, n+1)
    v := make([]int, n+1)

    for i := 0; i <= n; i++ {
        v[i] = 0
    }
    for i := 0; i < m; i++ {
        fmt.Scan(&x)
        for j := x; j <= n; j++ {
            if v[j] == 0 {
                a[j] = x
                v[j] = 1
            }
        }
    }

    for i := 1; i <= n; i++ {
        fmt.Print(a[i])
        fmt.Print(" ")
    }

    fmt.Println()

}

package main

import (
	"fmt"
)

func main() {
	var light [200]int;
	var n, m, button int;
	fmt.Scanf("%d %d", &n, &m);
	for i := 1; i <= m; {
		retN, _ := fmt.Scanf("%d", &button);
		if retN == 0 {
			continue;
		}
		for j := button; j <= n; j = j + 1 {
			if light[j] == 0 {
				light[j] = button;
			}
		}
		i = i + 1;
	}

	for i := 1; i <= n; i = i + 1 {
		fmt.Printf("%d ", light[i]);
	}
}

package main

import (
    "fmt"
)

func main() {
    var t, n, m, cnt int
    var light [110]int
    fmt.Scanf("%d %d", &n, &m)
    cnt = 100000
    for i := 0; i < m; i++ {
        c, _ := fmt.Scanf("%d", &t)
        if c == 0 {
            continue
        }
        if t < cnt {
            cnt = t
            light[t] = 1
        }
    }
    for i := 1; i <= n; i++ {
        if light[i] == 1 {
            cnt = i
        }
        fmt.Printf("%d ", cnt)
    }
}

package main

import (
    "fmt"
)

func main() {
    var t, n, m, cnt int
    var light [110]int
    fmt.Scanf("%d%d", &n, &m)
    cnt = 100000
    for i := 0; i < m; i++ {
        fmt.Scanf("%d", &t)
        if t < cnt {
            cnt = t
            light[t] = 1
        }
    }
    for i := 1; i <= n; i++ {
        if light[i] == 1 {
            cnt = i
        }
        fmt.Printf("%d ", cnt)
    }
}

package main

import (
	"fmt"
)

func main() {
	var n, m int

	fmt.Scanf("%d %d", &n, &m)

	pushes := make([]int, m + 10)
	lightstatus := make([] int, n + 10)

	for i := 0; i < m; i++ {
		fmt.Scanf("%d", &pushes[i])
	}

	for i := 0; i < m; i++ {
		for j := pushes[i]; j <= n && lightstatus[j] == 0; j ++ {
			lightstatus[j] = pushes[i]
		}
	}

	for i := 1; i <= n; i++ {
		fmt.Printf("%d ", lightstatus[i])
	}

}

package main

import (
	"fmt"
)

func main() {
	var light [200]int;
	var n, m, button int;
	fmt.Scanf("%d %d", &n, &m);
	for i := 1; i <= m; i = i + 1 {
		fmt.Scanf("%d", &button);
		for j := button; j <= n; j = j + 1 {
			if light[j] == 0 {
				light[j] = button;
			}
		}
	}

	for i := 1; i <= n; i = i + 1 {
		fmt.Printf("%d ", light[i]);
	}
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	var pushes, lightstatus [200]int

	fmt.Scanf("%d %d", &n, &m)

//	pushes := make([]int, m + 10)
//	lightstatus := make([] int, n + 10)

	for i := 0; i < m; i++ {
		ret, _ := fmt.Scanf("%d", &pushes[i])
		if ret == 0 {
			continue
		}
	}

	for i := 0; i < m; i++ {
		for j := pushes[i]; j <= n && lightstatus[j] == 0; j ++ {
			lightstatus[j] = pushes[i]
		}
	}

	for i := 1; i <= n; i++ {
		fmt.Printf("%d ", lightstatus[i])
	}

}

package main

import (
	"fmt"
)

func main() {
	var n, m int

	fmt.Scanf("%d %d", &n, &m)

	pushes := make([]int, m + 10)
	lightstatus := make([] int, n + 10)

	for i := 0; i < m; i++ {
		ret, _ := fmt.Scanf("%d", &pushes[i])
		if ret == 0 {
			continue
		}
	}

	for i := 0; i < m; i++ {
		for j := pushes[i]; j <= n && lightstatus[j] == 0; j ++ {
			lightstatus[j] = pushes[i]
		}
	}

	for i := 1; i <= n; i++ {
		fmt.Printf("%d ", lightstatus[i])
	}

}

package main

import (
	"fmt"
)

/*Simulating the problem of mashmokh and the lights
lights array will contain the current state of the light -1 / -2
0 -> ON
if any other number is present, then the light is switched off with that swtich*/
func main() {
    var n,m,b int
    fmt.Scanf("%d %d", &n, &m)
    var light []int = make([]int, n)
    for i := 0; i < n; i++ {
        light[i] = -1
    }

    for l := 0; l < m; l++ {
        retN, _ := fmt.Scanf("%d", &b)
        if retN == 0 {
            continue
        }

        b = b - 1
        for i := b; (i < n ) && (light[i] == -1); i++ {
            light[i] = b + 1
        }
    }

    for i := 0; i < n; i++ {
        fmt.Printf("%d ", light[i])
        if i == n {
            fmt.Println()
        } else {
            fmt.Printf(" ")
        }
    }

    return
}

package main

import (
	"fmt"
)

func main() {
	var n, m int

	fmt.Scanf("%d %d", &n, &m)

	pushes := make([]int, m + 10)
	lightstatus := make([] int, n + 10)

	for i := 0; i < m; i++ {
		fmt.Scanf("%d", &pushes[i])
	}

	for i := 0; i < m; i++ {
		for j := pushes[i]; j <= n && lightstatus[j] == 0; j ++ {
			lightstatus[j] = pushes[i]
		}
	}

	fmt.Println(lightstatus[1:n + 1])

}


A + B is often used as an example of the easiest problem possible to show some contest platform. However, some scientists have observed that sometimes this problem is not so easy to get accepted. Want to try?

The input contains two integers a and b (0 ≤ a, b ≤ 103), separated by a single space.

package main

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

func main(){
	var a, b int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	a, _ = strconv.Atoi(r.Text())
	r.Scan()
	b, _ = strconv.Atoi(r.Text())
	w.WriteString(strconv.Itoa(a+b)+"\n")
	w.Flush()
}

package main
import "fmt"

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

package main

import "fmt"

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

// 409H
package main

import (
	"fmt"
)

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

package main

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

const INF  = 1000000001

type Pair struct {
	first, second int
}

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

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

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

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

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

func solution(reader io.Reader, writer io.Writer) {
	var a, b int
	fmt.Fscanf(reader, "%d %d\n", &a, &b)
	fmt.Println(a + b)

}

func main() {

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

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

	solution(reader, writer)
}

package main
import "fmt"

func main(){
  var a,b int; fmt.Scan(&a,&b); fmt.Print(a+b)
}

package main

import "fmt"

func main() {
    var a, b int
    fmt.Scanf("%d %d", &a, &b)
    fmt.Printf("%d ", a+b)
}

package main

import "fmt"

func main(){
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Print(a+b, " ")
}

package main

import "fmt"

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

package main
import "fmt"

func main(){
  fmt.Println("test1")
}

package main
import "fmt"

func main(){
  fmt.Println("attempt1")
}

// 409H
package main

import (
	"fmt"
)

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

package main

import "fmt"

func main(){
  var a,b,c int64
  fmt.Scan(&a,&b)
  c=a+b
  fmt.Println(c)
}

// 409H
package main

import (
	"fmt"
)

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

// 409H
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scanf("d%d", &a, &b)
	fmt.Printf("%d", a+b)
}

// 409H
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scanf("d%d", &a, &b)
	fmt.Print(a + b)
}

// 409H
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scanf("d%d", &a, &b)
	fmt.Printf("%d", a-(-b))
}

package main
import "fmt"

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

package main
import "fmt"

func main(){
  var a,b int
    fmt.Scanf("%d %d",&a,&b)
      fmt.Println(a+b)
      }

package main

import (
    "fmt"
)

func main() {
    var a, b []byte
    fmt.Scanf("%s %s\n", &a, &b)
    const (
        zero byte = 48
    )
    var i, j int = len(a) - 1, len(b) - 1
    var (
        rev   []byte
        k     byte
        carry bool = false
    )

    for ; i >= 0 && j >= 0; i, j = i-1, j-1 {
        k, carry = add(a[i], b[j], carry)
        rev = append(rev, k)
    }
    for ; i >= 0; i-- {
        k, carry = add(a[i], zero, carry)
        rev = append(rev, k)
    }
    for ; j >= 0; j-- {
        k, carry = add(b[j], zero, carry)
        rev = append(rev, k)
    }

    for i, j = 0, len(rev)-1; i < j; i, j = i+1, j-1 {
        rev[i], rev[j] = rev[j], rev[i]
    }
    fmt.Printf("%s", rev)
}

func add(i byte, j byte, b bool) (k byte, c bool) {
    const (
        zero byte = 48
        ten  byte = 58
    )

    k += i + j - zero
    if b {
        k++
    }
    if k >= ten {
        k -= ten - zero
        c = true
    } else {
        c = false
    }
    return
}

package main

import (
    "fmt"
    "math/big"
)

func main() {
    var (
        a, b, c = new(big.Int), new(big.Int), new(big.Int)
    )
    fmt.Scanf("%d %d", a, b)
    fmt.Printf("%d ", c.Add(a, b))
}

package main

import (
    "fmt"
    "math/big"
)

func main() {
    var (
        a, b, c = new(big.Int), new(big.Int), new(big.Int)
    )
    fmt.Scanf("%d %d\n", a, b)
    fmt.Printf("%d ", c.Add(a, b))
}

package main

import (
    "fmt"
)

func main() {
    var a, b []byte
    fmt.Scanf("%s %s\n", &a, &b)
    const (
        zero byte = 48
    )
    var i, j int = len(a) - 1, len(b) - 1
    var (
        rev   []byte
        k     byte
        carry bool = false
    )

    for ; i >= 0 && j >= 0; i, j = i-1, j-1 {
        k, carry = add(a[i], b[j], carry)
        rev = append(rev, k)
    }
    for ; i >= 0; i-- {
        k, carry = add(a[i], zero, carry)
        rev = append(rev, k)
    }
    for ; j >= 0; j-- {
        k, carry = add(b[j], zero, carry)
        rev = append(rev, k)
    }

    for i, j = 0, len(rev)-1; i < j; i, j = i+1, j-1 {
        rev[i], rev[j] = rev[j], rev[i]
    }
    fmt.Printf("%s\n", rev)
}

func add(i byte, j byte, b bool) (k byte, c bool) {
    const (
        zero byte = 48
        ten  byte = 58
    )

    k += i + j - zero
    if b {
        k++
    }
    if k >= ten {
        k -= ten - zero
        c = true
    } else {
        c = false
    }
    return
}

package main

import (
    "fmt"
    "math/big"
)

func main() {
    var (
        a, b, c = new(big.Int), new(big.Int), new(big.Int)
    )
    fmt.Scanf("%d %d\n", a, b)
    fmt.Println(c.Add(a, b))
}


Fangy collects cookies. Once he decided to take a box and put cookies into it in some way. If we take a square k × k in size, divided into blocks 1 × 1 in size and paint there the main diagonal together with cells, which lie above it, then the painted area will be equal to the area occupied by one cookie k in size. Fangy also has a box with a square base 2n × 2n, divided into blocks 1 × 1 in size. In a box the cookies should not overlap, and they should not be turned over or rotated. See cookies of sizes 2 and 4 respectively on the figure:    To stack the cookies the little walrus uses the following algorithm. He takes out of the repository the largest cookie which can fit in some place in the box and puts it there. Everything could be perfect but alas, in the repository the little walrus has infinitely many cookies of size 2 and larger, and there are no cookies of size 1, therefore, empty cells will remain in the box. Fangy wants to know how many empty cells will be left in the end.

The first line contains a single integer n (0 ≤ n ≤ 1000).

Print the single number, equal to the number of empty cells in the box. The answer should be printed modulo 106 + 3.

NoteIf the box possesses the base of 23 × 23 (as in the example), then the cookies will be put there in the following manner:

//70A
package main
import (
	"fmt"
	"os"
	"bufio"
	"strconv"
)

func main() {
	var nn, a int64
	a=1
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	r.Scan()
	nn, _ = strconv.ParseInt(r.Text(), 0, 64)
	if nn==1 {
		a=1
	} else {
		for i:=2; int64(i)<=nn; i++ {
			a=(a*3)%1000003
		}
	}
	fmt.Println(a)
}

// 70A
package main

import (
	"fmt"
)

func main() {
	var m int
	e := 1
	fmt.Scan(&m)
	for j := 1; j <= m-1; j++ {
		e = (3 * e) % 1000003
	}
	fmt.Print(e)
}


The last stage of Football World Cup is played using the play-off system.There are n teams left in this stage, they are enumerated from 1 to n. Several rounds are held, in each round the remaining teams are sorted in the order of their ids, then the first in this order plays with the second, the third — with the fourth, the fifth — with the sixth, and so on. It is guaranteed that in each round there is even number of teams. The winner of each game advances to the next round, the loser is eliminated from the tournament, there are no draws. In the last round there is the only game with two remaining teams: the round is called the Final, the winner is called the champion, and the tournament is over.Arkady wants his two favorite teams to play in the Final. Unfortunately, the team ids are already determined, and it may happen that it is impossible for teams to meet in the Final, because they are to meet in some earlier stage, if they are strong enough. Determine, in which round the teams with ids a and b can meet.

The only line contains three integers n, a and b (2 ≤ n ≤ 256, 1 ≤ a, b ≤ n) — the total number of teams, and the ids of the teams that Arkady is interested in.  It is guaranteed that n is such that in each round an even number of team advance, and that a and b are not equal.

In the only line print "Final!" (without quotes), if teams a and b can meet in the Final. Otherwise, print a single integer — the number of the round in which teams a and b can meet. The round are enumerated from 1.

NoteIn the first example teams 1 and 2 meet in the first round.In the second example teams 2 and 6 can only meet in the third round, which is the Final, if they win all their opponents in earlier rounds.In the third example the teams with ids 7 and 5 can meet in the second round, if they win their opponents in the first round.

package main

import "fmt"

func main() {
	var n, a, b, cnt uint
	for {
		_, err := fmt.Scanln(&n, &a, &b)
		if err != nil {
			break
		}
		if a > b {
			a, b = b, a
		}
		if (b & 1) > 0 {
			b++
		}
		res := b - a
		cnt = 1
		for res > 1 {
			a = (a + 1) >> 1
			b = (b + 1) >> 1
			if (b & 1) > 0 {
				b++
			}
			res = b - a
			cnt++
		}
		if n == (1 << cnt) {
			fmt.Println("Final!")
		} else {
			fmt.Println(cnt)
		}
	}
}

package main

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

func Init() {
}

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

	rounds := 0
	rem := N
	for rem > 1 {
	  rounds++
	  rem >>= 1
	}

	teams := make([]int, 0)
	for i := 1; i <= N; i++ {
	  teams = append(teams, i)
	}

	which := -1
	for r := 1; which < 0; r++ {
	  next := make([]int, 0)
	  for i := 0; i < len(teams); i += 2 {
	    if isOr(A, teams[i], teams[i + 1]) && isOr(B, teams[i], teams[i + 1]) {
	      which = r
	      break
	    }
	    if isOr(A, teams[i], teams[i + 1]) {
	      next = append(next, A)
	    } else if isOr(B, teams[i], teams[i + 1]) {
	      next = append(next, B)
	    } else {
	      next = append(next, teams[i])
	    }
	  }
	  teams = next
	}

	if which == rounds {
	  io.Println("Final!")
	} else {
	  io.Println(which)
	}
}

func isOr(x, a, b int) bool {
  return x == a || x == b
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

package main

import "fmt"

func main() {
	var n, a, b int
	for {
		_, err := fmt.Scanln(&n, &a, &b)
		if err != nil {
			break
		}

		if a%2 == 1 {
			a += 1
		}
		if b%2 == 1 {
			b += 1
		}

		rest := a - b
		if rest < 0 {
			rest = -rest
		}
		cnt := 1
		for rest > 1 {
			rest >>= 1
			cnt++
		}
		max := 0
		for n > 1 {
			n >>= 1
			max++
		}
		if cnt < max {
			fmt.Println(cnt)
		} else {
			fmt.Println("Final!")
		}
	}
}

package main

import "fmt"

func main() {
	var n, a, b int
	for {
		_, err := fmt.Scanln(&n, &a, &b)
		if err != nil {
			break
		}

		if a%2 == 1 {
			a += 1
		}
		if b%2 == 1 {
			b += 1
		}

		rest := a - b
		if rest < 0 {
			rest = -rest
		}
		if n-rest*2 <= 0 {
			fmt.Println("Final!")
		} else {
			cnt := 1
			for rest > 1 {
				rest >>= 1
				cnt++
			}
			fmt.Println(cnt)
		}
	}
}

package main

import "fmt"

func main() {
	var n, a, b int
	for {
		_, err := fmt.Scanln(&n, &a, &b)
		if err != nil {
			break
		}
		rest := a - b
		if rest < 0 {
			rest = -rest
		}
		if n/rest == 2 {
			fmt.Println("Final!")
		} else {
			cnt := 0
			for rest > 0 {
				rest >>= 1
				cnt++
			}
			fmt.Println(cnt)
		}
	}
}

package main

import "fmt"

func main() {
	var n, a, b int
	for {
		_, err := fmt.Scanln(&n, &a, &b)
		if err != nil {
			break
		}
		rest := a - b
		if rest < 0 {
			rest = -rest
		}
		if n-rest*2 <= 0 {
			fmt.Println("Final!")
		} else {
			cnt := 0
			for rest > 0 {
				rest >>= 1
				cnt++
			}
			fmt.Println(cnt)
		}
	}
}

package main

import "fmt"

func main() {
	var n, a, b int
	for {
		_, err := fmt.Scanln(&n, &a, &b)
		if err != nil {
			break
		}
		rest := a - b
		if rest < 0 {
			rest = -rest
		}
		if n/rest <= 2 {
			fmt.Println("Final!")
		} else {
			cnt := 0
			for rest > 0 {
				rest >>= 1
				cnt++
			}
			fmt.Println(cnt)
		}
	}
}

package main

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

func Init() {
}

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

	rounds := 0
	rem := N
	for rem > 1 {
	  rounds++
	  rem >>= 1
	}

	which := 0
	for i := uint(0); ; i++ {
	  bitA := (A >> i) & 1
	  bitB := (B >> i) & 1
	  if bitA != bitB {
	    which = int(i + 1)
	    break
	  }
	}

	if which == rounds {
	  io.Println("Final!")
	} else {
	  io.Println(which)
	}
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


Fox Ciel is playing a game with numbers now. Ciel has n positive integers: x1, x2, ..., xn. She can do the following operation as many times as needed: select two different indexes i and j such that xi > xj hold, and then apply assignment xi = xi - xj. The goal is to make the sum of all numbers as small as possible.Please help Ciel to find this minimal sum.

The first line contains an integer n (2 ≤ n ≤ 100). Then the second line contains n integers: x1, x2, ..., xn (1 ≤ xi ≤ 100).

Output a single integer — the required minimal sum.

NoteIn the first example the optimal way is to do the assignment: x2 = x2 - x1.In the second example the optimal sequence of operations is: x3 = x3 - x2, x2 = x2 - x1.

package main

import (
	"fmt"
)

func GCD(x, y int) int {
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func main() {
	var n, gcd int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var x int
		fmt.Scan(&x)
		if i == 0 {
			gcd = x
		} else {
			gcd = GCD(gcd, x)
		}
	}
	fmt.Println(n * gcd)
}

package main

import (
	"fmt"
)

func main() {
	var n int

	fmt.Scan(&n)

	x := make([]int, n)

	for i := range x {
		fmt.Scan(&x[i])
	}

	for x[0] != x[1] {
		if x[0] > x[1] {
			x[0] -= x[1]
		} else {
			x[1] -= x[0]
		}
	}

	gcd := x[0]

	for i:=2; i<len(x); i++ {
		for x[i] != gcd {
			if x[i] > gcd {
				x[i] -= gcd
			} else {
				gcd -= x[i]
			}
		}
	}

	fmt.Println(gcd*len(x))
}

package main

import (
	"fmt"
)
func gcd(x, y int) int {
    for y != 0 {
        x, y = y, x%y
    }
    return x
}

func main() {
	var n,g,x int
	fmt.Scan(&n,&g)
	for i:=1;i<n;i++ {
		fmt.Scan(&x)
		g=gcd(g,x)
	}
	fmt.Println(g*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; i < n && scanner.Scan(); i++ {
		a, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}
		array[i] = a
	}

	has_inequality := true
	for has_inequality {
		has_inequality = false
		for i := 0; i < n; i++ {
			for j := i + 1; j < n; j++ {
				if array[i] != array[j] {
					has_inequality = true
					c := sub_algorithm(array[i], array[j])
					array[i] = c
					array[j] = c
				}
			}
		}
	}

	sum := 0
	for i := 0; i < n; i++ {
		sum += array[i]
	}
	fmt.Println(sum)
}

func sub_algorithm(a, b int) int {
	if a == b {
		return a
	} else if b > a {
		a, b = b, a
	}
	return sub_algorithm(a-b, b)
}

package main

import "fmt"

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

func main() {
    var n,x int
    fmt.Scan(&n)
    a := -1
    for i := 0; i < n ; i++ {
        fmt.Scan(&x)
        if a == -1 { a = x } else { a = gcd(a,x) }
    }
    fmt.Println(a*n)
}

// 389A-mic
package main

import (
    "fmt"
    "math/big"
)

func gcd(x, y int64) int64 {
    return new(big.Int).GCD(nil, nil, big.NewInt(x), big.NewInt(y)).Int64()
}

func main() {
    var n, g, k, i int64
    fmt.Scan(&n, &g)
    for i = 1; i < n; i++ {
        fmt.Scan(&k)
        g = gcd(g, k)
    }
    fmt.Println(g * n)
}


n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if he has at least two pillows less than some of his neighbors have. Frodo will sleep on the k-th bed in the row. What is the maximum number of pillows he can have so that every hobbit has at least one pillow, every pillow is given to some hobbit and no one is hurt?

The only line contain three integers n, m and k (1 ≤ n ≤ m ≤ 109, 1 ≤ k ≤ n) — the number of hobbits, the number of pillows and the number of Frodo's bed.

Print single integer — the maximum number of pillows Frodo can have so that no one is hurt.

NoteIn the first example Frodo can have at most two pillows. In this case, he can give two pillows to the hobbit on the first bed, and one pillow to each of the hobbits on the third and the fourth beds.In the second example Frodo can take at most four pillows, giving three pillows to each of the others.In the third example Frodo can take three pillows, giving two pillows to the hobbit in the middle and one pillow to the hobbit on the third bed.

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

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

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

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

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

var n, m, k int64

func solve(n int64) {
	I(&m, " ")
	I(&k, "\n")
	if n == m {
		O(1, "\n")
		return
	}
	if n == 1 {
		O(m, "\n")
		return
	}
	ans := int64(2)
	m -= n + 1
	h := int64(1)
	l := k - 1
	r := n - k
	for m > 0 {
		if l > 0 {
			h++
			l--
		}
		if r > 0 {
			h++
			r--
		}
		if r <= 0 && l <= 0 {
			ans += m / h
			m = 0
		} else {
			m -= h
			if m >= 0 {
				ans++
			}
		}
	}
	O(ans, "\n")
}

package main

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

func solve() {
	people := readInt()
	pillow := readInt()
	k := readInt()
	if people == 1 {
		fmt.Println(pillow)
		return
	}
	pillow -= people
	left := int64(k - 1)
	right := int64(people - k)
	best := 0
	lo := 0
	hi := pillow
	for lo <= hi && pillow > 0 {
		mi := lo + (hi-lo)/2
		rest := int64(pillow - mi)
		step := int64(mi - 1)
		var sum1 int64
		var sum2 int64
		if left > 0 && step > 0 {
			t := left
			if step < t {
				t = step
			}
			sum1 = int64(step-t+1+step) * t / 2
		}
		if right > 0 && step > 0 {
			t := right
			if step < t {
				t = step
			}
			sum2 = int64(step-t+1+step) * t / 2
		}
		if sum1+sum2 <= rest {
			best = mi
			lo = mi + 1
		} else {
			hi = mi - 1
		}
	}
	fmt.Println(best + 1)
}

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

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

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

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

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

func solve(n int64) {
	var m, k int64
	I(&m, " ")
	I(&k, "\n")
	fair := m / n
	arr := make([]int64, n+1)
	for i := int64(1); i <= n; i++ {
		arr[i] = fair
	}
	for i := int64(1); i < k; i++ {
		if arr[i] > 1 {
			arr[i]--
			arr[i+1]++
		}
	}
	if k != n {
		for i := n; i > k; i-- {
			if arr[i] > 1 {
				arr[i]--
				arr[i-1]++
			}
		}
	}
	arr[k] += m % n
	if k > 0 {
		ooo := int64(1)
		for arr[k]-arr[k-1] > 1 && k != ooo {
			arr[k]--
			ooo %= k
			if ooo == int64(0) {
				ooo++
			}
			arr[ooo]++
			ooo++
		}
	}
	if k < 0 {
		ooo := int64(n)
		for arr[k]-arr[k+1] > 1 && k != ooo {
			arr[k]--
			if ooo == int64(k) {
				ooo = n
			}
			arr[ooo]++
			ooo--
		}
	}
	O(arr[k], "\n")
}

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

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

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

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

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

var n, m, k int64

func solve(n int64) {
	I(&m, " ")
	I(&k, "\n")
	p := k - (n - k)
	o := (k * (k + 1) / 2) + (k*(k-1))/2 - (p * (p - 1) / 2)
	ans := k
	if o < m {
		ans += (m - o) / n
	} else if o > m {
		ans -= (o-m)/n + 1
	}
	if m == n {
		ans = 1
	}
	O(ans, "\n")
}

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

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

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

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

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

func solve(n int64) {
	var m, k int64
	I(&m, " ")
	I(&k, "\n")
	fair := m / n
	arr := make([]int64, n+1)
	for i := int64(1); i <= n; i++ {
		arr[i] = fair
	}
	for i := int64(1); i < k; i++ {
		if arr[i] > 1 {
			arr[i]--
			arr[i+1]++
		}
	}
	if k != n {
		for i := n; i > k; i-- {
			if arr[i] > 1 {
				arr[i]--
				arr[i-1]++
			}
		}
	}
	arr[k] += m % n
	if k != 1 {
		ooo := int64(1)
		for arr[k]-arr[k-1] > 1 {
			arr[k]--
			arr[ooo]++
			ooo++
			ooo %= k
			if ooo == int64(0) {
				ooo++
			}
		}
	}
	if k != n {
		ooo := int64(n)
		for arr[k]-arr[k+1] > 1 {
			arr[k]--
			arr[ooo]++
			ooo--
			if ooo == int64(k) {
				ooo = n
			}
		}
	}
	O(arr[k], "\n")
}

package main

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

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

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

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

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

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

var n, m, k int64

func solve(n int64) {
	I(&m, " ")
	I(&k, "\n")
	p := k - (n - k)
	o := (k * (k + 1) / 2) + (k*(k-1))/2 - (p * (p - 1) / 2)
	ans := k
	if o < m {
		ans += (m - o) / n
	} else if o > m {
		ans -= (o-m)/n + 1
	}
	O(ans, "\n")
}

package main

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

func solve() {
	people := readInt()
	pillow := readInt()
	k := readInt()
	if people == 1 {
		fmt.Println(pillow)
		return
	}
	pillow -= people
	left := int64(k - 1)
	right := int64(people - k)
	lo := 0
	hi := pillow
	best := 0
	for lo <= hi && pillow > 0 {
		mi := lo + (hi-lo)/2
		rest := int64(pillow - mi)
		step := int64(mi - 1)
		var sum1 int64
		var sum2 int64
		if left > 0 && step > 0 {
			if step < left {
				left = step
			}
			sum1 = int64(step-left+1+step) * left / 2
		}
		if right > 0 && step > 0 {
			if step < right {
				right = step
			}
			sum2 = int64(step-right+1+step) * right / 2
		}
		if sum1 < 0 || sum2 < 0 {
			panic("sum1 < 0")
		}
		if sum1+sum2 <= rest {
			lo = mi + 1
			if best < mi {
				best = mi
			}
		} else {
			hi = mi - 1
		}
	}

	fmt.Println(best + 1)
}

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

func solve() {
	people := readInt()
	pillow := readInt()
	k := readInt()
	pillow -= people
	left := k - 1
	right := people - k
	lo := 0
	hi := math.MaxInt32
	best := 0
	for lo <= hi && pillow > 0 {
		mi := lo + (hi-lo)/2
		rest := pillow - mi
		step := mi - 1
		var sum1 int
		var sum2 int
		if left > 0 && step > 0 {
			if step < left {
				left = step
			}
			sum1 = (step - left + 1 + step) * left / 2
		}
		if right > 0 && step > 0 {
			if step < right {
				right = step
			}
			sum2 = (step - right + 1 + step) * right / 2
		}
		if sum1+sum2 <= rest {
			lo = mi + 1
			if best < mi {
				best = mi
			}
		} else {
			hi = mi - 1
		}
	}

	fmt.Println(best + 1)
}

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

func solve() {
	people := readInt()
	pillow := readInt()
	k := readInt()
	if people == 1 {
		fmt.Println(pillow)
		return
	}
	pillow -= people
	left := k - 1
	right := people - k
	lo := 0
	hi := math.MaxInt32
	best := 0
	for lo <= hi && pillow > 0 {
		mi := lo + (hi-lo)/2
		rest := pillow - mi
		step := mi - 1
		var sum1 int
		var sum2 int
		if left > 0 && step > 0 {
			if step < left {
				left = step
			}
			sum1 = (step - left + 1 + step) * left / 2
		}
		if right > 0 && step > 0 {
			if step < right {
				right = step
			}
			sum2 = (step - right + 1 + step) * right / 2
		}
		if sum1+sum2 <= rest {
			lo = mi + 1
			if best < mi {
				best = mi
			}
		} else {
			hi = mi - 1
		}
	}

	fmt.Println(best + 1)
}

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"
	"os"
	"strconv"
)

func solve() {
	people := readInt()
	pillow := readInt()
	k := readInt()
	if people == 1 {
		fmt.Println(pillow)
		return
	}
	pillow -= people
	left := int64(k - 1)
	right := int64(people - k)
	lo := 0
	hi := pillow
	best := 0
	for lo <= hi && pillow > 0 {
		mi := lo + (hi-lo)/2
		rest := int64(pillow - mi)
		step := int64(mi - 1)
		var sum1 int64
		var sum2 int64
		if left > 0 && step > 0 {
			if step < left {
				left = step
			}
			sum1 = int64(step-left+1+step) * left / 2
		}
		if right > 0 && step > 0 {
			if step < right {
				right = step
			}
			sum2 = int64(step-right+1+step) * right / 2
		}
		if sum1+sum2 <= rest {
			lo = mi + 1
			if best < mi {
				best = mi
			}
		} else {
			hi = mi - 1
		}
	}
	fmt.Println(best + 1)
}

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
}


You've got a rectangular parallelepiped with integer edge lengths. You know the areas of its three faces that have a common vertex. Your task is to find the sum of lengths of all 12 edges of this parallelepiped.

The first and the single line contains three space-separated integers — the areas of the parallelepiped's faces. The area's values are positive ( > 0) and do not exceed 104. It is guaranteed that there exists at least one parallelepiped that satisfies the problem statement.

Print a single number — the sum of all edges of the parallelepiped.

NoteIn the first sample the parallelepiped has sizes 1 × 1 × 1, in the second one — 2 × 2 × 3.

package main

import (
    "fmt"
    "math"
)

func main() {
    var ab, ac, bc int64
    fmt.Scanf("%d %d %d", &ab, &ac, &bc)
    abc := int64(math.Sqrt(float64(ab*ac*bc)))
    fmt.Print(4*(abc/bc + abc/ac + abc/ab))
}

 package main

 import (
 	"fmt"
 	"math"
 )

 func main() {
 	var x,y,z,t float64
 	fmt.Scan(&x,&y,&z)
 	t= math.Sqrt(x*y*z)
 	t= t/x+t/y+t/z
 	t*=4
 		fmt.Println(t)
 }

package main

import (
	"fmt"
	"math"
)

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

	a := math.Sqrt(float64(x * z / y))
	b := math.Sqrt(float64(x * y / z))
	c := math.Sqrt(float64(y * z / x))

	fmt.Println(4 * int32(a+b+c))
}

package main

import (
    "fmt"
    "math"
)

func main() {
    var a,b,c int
    fmt.Scan(&a,&b,&c)
    y := int(math.Sqrt(float64((a*c)/b)))
    x := (y*b)/c
    z := b/x
    fmt.Println(4*(x+y+z))
}

package main

import (
    "fmt"
    "math"
)

func main() {
    var a, b, c float64
    fmt.Scanf("%f%f%f", &a, &b, &c)
    fmt.Print(4 * (math.Sqrt(a * b / c) + math.Sqrt(a * c / b) + math.Sqrt(b * c / a)))
}

// 224A-mic
package main

import (
    "fmt"
    "math"
)

func main() {
    var s1, s2, s3 int
    fmt.Scan(&s1, &s2, &s3)
    a := int(math.Sqrt(float64(s1 * s3 / s2)))
    b := int(math.Sqrt(float64(s1 * s2 / s3)))
    c := int(math.Sqrt(float64(s2 * s3 / s1)))
    fmt.Println(4 * (a + b + c))
}

package main

import (
    "fmt"
    "math"
)

func main() {
    var ab, ac, bc int
    fmt.Scanf("%d %d %d", &ab, &ac, &bc)
    abc := int(math.Sqrt(float64(ab*ac*bc)))
    fmt.Print(4*(abc/bc + abc/ac + abc/ab))
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    var n,k int
    fmt.Scan(&n,&k)
    a := make([]int,n+1)
    ok := true
    for i := 1; i <= n; i++ {
        scanner.Scan()
        a[i], _ = strconv.Atoi(scanner.Text())
        if (i > k) && (a[i] != a[k]) {
            ok = false
        }
    }
    if ok {
        ans := k
        for a[ans-1] == a[k] { ans-- }
        fmt.Println(ans-1)
    } else {
        fmt.Println(-1)
    }
}