A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car. Masha came to test these cars. She could climb into all cars, but she liked only the smallest car. It's known that a character with size a can climb into some car with size b if and only if a ≤ b, he or she likes it if and only if he can climb into this car and 2a ≥ b.You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars.

You are given four integers V1, V2, V3, Vm(1 ≤ Vi ≤ 100) — sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3.

Output three integers — sizes of father bear's car, mother bear's car and son bear's car, respectively. If there are multiple possible solutions, print any. If there is no solution, print "-1" (without quotes).

NoteIn first test case all conditions for cars' sizes are satisfied.In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20.

package main

import (
	"fmt"
)

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

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

func main() {
	var v1,v2,v3,vm,f int
	fmt.Scanf("%d%d%d%d",&v1,&v2,&v3,&vm)
	if v1*2>=max(v1,vm*2+1) {
		v1=v1*2
	} else {
		f=1
	}
	if v2*2>=max(v2,vm*2+1) {
		v2=v2*2
	} else {
		f=1
	}
	if min(v3*2,vm*2)>=max(v3,vm) {
		v3=min(v3*2,vm*2)
	} else {
		f=1
	}
	if f==0 {
		fmt.Printf("%d\n%d\n%d",v1,v2,v3)
	} else {
		fmt.Printf("-1")
	}
}

package main

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

func solve() {
	v1 := readInt()
	v2 := readInt()
	v3 := readInt()
	vm := readInt()

	maxv1 := 2 * v1
	minv1 := v1

	maxv2 := 2 * v2
	minv2 := v2

	maxv3 := 2 * v3
	minv3 := v3

	maxvm := 2 * vm
	//	maxv3 = min(2*v3, 2*vm)
	//	minv3 = max(v3, vm)

	//	fmt.Println("[", minv3, maxv3, "]")
	//	fmt.Println("[", minv2, maxv2, "]")
	//	fmt.Println("[", minv1, maxv1, "]")

	for i := 1; i <= 200; i++ {
		if i < vm {
			continue
		}
		if i > 2*vm {
			break
		}
		for i3 := i; i3 <= maxv3; i3++ {
			if i3 < minv3 {
				continue
			}
			if i3 > maxvm {
				continue
			}
			for i2 := i3 + 1; i2 <= maxv2; i2++ {
				if i2 < minv2 {
					continue
				}
				if i2 <= maxvm {
					// masha can't like this car
					continue
				}
				for i1 := i2 + 1; i1 <= maxv1; i1++ {
					if i1 < minv1 {
						continue
					}
					if i2 <= maxvm {
						// masha can't like this car
						continue
					}
					fmt.Println(i1)
					fmt.Println(i2)
					fmt.Println(i3)
					return
				}
			}
		}
	}
	fmt.Println("-1")
}

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

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

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

package main

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

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

  var v1, v2, v3, vm = ReadInt32(), ReadInt32(), ReadInt32(), ReadInt32()
  for i1 := v1; i1 <= 2 * v1; i1++ {
    for i2 := v2; i2 <= 2 * v2 && i2 < i1; i2++ {
      for i3 := v3; i3 <= 2 * v3 && i3 < i2; i3++ {
        if vm <= i1 && vm <= i2 && vm <= i3 && 2 * vm >= i3 && 2 * vm < i1 && 2 * vm < i2 {
          fmt.Printf("%d\n%d\n%d", i1, i2, i3)
          return
        }
      }
    }
  }
  fmt.Println(-1);
}

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

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

func PrintInts(ints ...int) {
  for _, value := range ints {
    writer.WriteString(strconv.Itoa(value))
    writer.WriteByte(' ')
  }
}

package main

import (
	"errors"
	"fmt"
)

var impossibleErr = errors.New("Not possible")

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

func getRightSize(a int, minSize int) (int, error) {
	size := maxInt(a, minSize)
	if size > 2*a {
		return -1, impossibleErr
	}
	return size, nil
}

func main() {
	bearSizes := make([]int, 3)
	for i := 0; i < 3; i++ {
		fmt.Scanf("%d", &bearSizes[i])
	}
	var mashaSize int
	fmt.Scanf("%d", &mashaSize)

	carSizes := make([]int, 3)

	minimumSize := mashaSize
	for i := 2; i >= 0; i-- {
		var err error
		carSizes[i], err = getRightSize(bearSizes[i], minimumSize)
		if err != nil {
			fmt.Println("-1")
			return
		}
		if i == 2 {
			if carSizes[i] > 2*mashaSize {
				fmt.Println(-1)
				return
			}
			minimumSize = maxInt(carSizes[i]+1, 2*mashaSize+1)
		} else {
			minimumSize = carSizes[i] + 1
		}
	}

	for i := 0; i < 3; i++ {
		fmt.Println(carSizes[i])
	}

}

package main

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

func solve() {
	v1 := readInt()
	v2 := readInt()
	v3 := readInt()
	vm := readInt()

	maxv1 := 2 * v1
	minv1 := v1

	maxv2 := 2 * v2
	minv2 := v2

	maxv3 := 2 * v3
	minv3 := v3

	maxvm := 2 * vm
	//	maxv3 = min(2*v3, 2*vm)
	//	minv3 = max(v3, vm)

	//	fmt.Println("[", minv3, maxv3, "]")
	//	fmt.Println("[", minv2, maxv2, "]")
	//	fmt.Println("[", minv1, maxv1, "]")

	for i := 1; i <= 200; i++ {
		if i < vm {
			continue
		}
		if i > 2*vm {
			break
		}
		for i3 := i; i3 <= maxv3; i3++ {
			if i3 < minv3 {
				continue
			}
			for i2 := i3 + 1; i2 <= maxv2; i2++ {
				if i2 < minv2 {
					continue
				}
				if i2 <= maxvm {
					// masha can't like this car
					continue
				}
				for i1 := i2 + 1; i1 <= maxv1; i1++ {
					if i1 < minv1 {
						continue
					}
					if i2 <= maxvm {
						// masha can't like this car
						continue
					}
					fmt.Println(i1)
					fmt.Println(i2)
					fmt.Println(i3)
					return
				}
			}
		}
	}
	fmt.Println("-1")
}

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

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

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

package main

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

func solve() {
	v1 := readInt()
	v2 := readInt()
	v3 := readInt()
	vm := readInt()

	maxv1 := 2 * v1
	minv1 := v1

	maxv2 := 2 * v2
	minv2 := v2

	maxv3 := 2 * v3
	minv3 := v3

	maxv3 = min(2*v3, 2*vm)
	minv3 = max(v3, vm)

	//	fmt.Println("[", minv3, maxv3, "]")
	//	fmt.Println("[", minv2, maxv2, "]")
	//	fmt.Println("[", minv1, maxv1, "]")

	if minv3 > maxv3 {
		fmt.Println("-1")
		return
	}

	for i3 := minv3; i3 <= maxv3; i3++ {
		for i2 := i3 + 1; i2 <= maxv2; i2++ {
			if i2 < minv2 {
				continue
			}
			for i1 := i2 + 1; i1 <= maxv1; i1++ {
				if i1 < minv1 {
					continue
				}
				fmt.Println(i1)
				fmt.Println(i2)
				fmt.Println(i3)
				return
			}
		}
	}
	fmt.Println("-1")
}

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

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

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

package main

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

func solve() {
	v1 := readInt()
	v2 := readInt()
	v3 := readInt()
	vm := readInt()

	maxv1 := 2 * v1
	minv1 := v1

	maxv2 := 2 * v2
	minv2 := v2

	maxv3 := 2 * v3
	minv3 := v3

	//	maxv3 = min(2*v3, 2*vm)
	//	minv3 = max(v3, vm)

	//	fmt.Println("[", minv3, maxv3, "]")
	//	fmt.Println("[", minv2, maxv2, "]")
	//	fmt.Println("[", minv1, maxv1, "]")

	for i := 1; i <= 200; i++ {
		if i < vm {
			continue
		}
		if i > 2*vm {
			break
		}
		for i3 := i; i3 <= maxv3; i3++ {
			if i3 < minv3 {
				continue
			}
			for i2 := i3 + 1; i2 <= maxv2; i2++ {
				if i2 < minv2 {
					continue
				}
				for i1 := i2 + 1; i1 <= maxv1; i1++ {
					if i1 < minv1 {
						continue
					}
					fmt.Println(i1)
					fmt.Println(i2)
					fmt.Println(i3)
					return
				}
			}
		}
	}
	fmt.Println("-1")
}

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

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

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

package main

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

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

  var v1, v2, v3, vm = ReadInt32(), ReadInt32(), ReadInt32(), ReadInt32()
  for i1 := v1; i1 <= 2 * v1; i1++ {
    for i2 := v2; i2 <= 2 * v2; i2++ {
      for i3 := v3; i3 <= 2 * v3; i3++ {
        if vm <= i1 && vm <= i2 && vm <= i3 && 2 * vm >= i3 && 2 * vm < i1 && 2 * vm < i2 {
          fmt.Printf("%d\n%d\n%d", i1, i2, i3)
          return
        }
      }
    }
  }
  fmt.Println(-1);
}

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

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

func PrintInts(ints ...int) {
  for _, value := range ints {
    writer.WriteString(strconv.Itoa(value))
    writer.WriteByte(' ')
  }
}

package main

import (
	"errors"
	"fmt"
)

var impossibleErr = errors.New("Not possible")

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

func getRightSize(a int, minSize int) (int, error) {
	size := maxInt(a, minSize)
	if size > 2*a {
		return -1, impossibleErr
	}
	return size, nil
}

func main() {
	bearSizes := make([]int, 3)
	for i := 0; i < 3; i++ {
		fmt.Scanf("%d", &bearSizes[i])
	}
	var mashaSize int
	fmt.Scanf("%d", &mashaSize)

	carSizes := make([]int, 3)

	minimumSize := mashaSize
	for i := 2; i >= 0; i-- {
		var err error
		carSizes[i], err = getRightSize(bearSizes[i], minimumSize)
		if err != nil {
			fmt.Println("-1")
			return
		}
		minimumSize = carSizes[i]
	}

	for i := 0; i < 3; i++ {
		fmt.Println(carSizes[i])
	}

}

package main

import (
	"errors"
	"fmt"
)

var impossibleErr = errors.New("Not possible")

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

func getRightSize(a int, minSize int) (int, error) {
	size := maxInt(a, minSize)
	if size > 2*a {
		return -1, impossibleErr
	}
	return size, nil
}

func main() {
	bearSizes := make([]int, 3)
	for i := 0; i < 3; i++ {
		fmt.Scanf("%d", &bearSizes[i])
	}
	var mashaSize int
	fmt.Scanf("%d", &mashaSize)

	carSizes := make([]int, 3)

	minimumSize := mashaSize
	for i := 2; i >= 0; i-- {
		var err error
		carSizes[i], err = getRightSize(bearSizes[i], minimumSize)
		if err != nil {
			fmt.Println("-1")
			return
		}
		if i == 2 {
			minimumSize = maxInt(carSizes[i]+1, 2*mashaSize+1)
		} else {
			minimumSize = carSizes[i] + 1
		}
	}

	for i := 0; i < 3; i++ {
		fmt.Println(carSizes[i])
	}

}


You are given a sequence of integers of length $$$n$$$ and integer number $$$k$$$. You should print any integer number $$$x$$$ in the range of $$$[1; 10^9]$$$ (i.e. $$$1 \le x \le 10^9$$$) such that exactly $$$k$$$ elements of given sequence are less than or equal to $$$x$$$.Note that the sequence can contain equal elements.If there is no such $$$x$$$, print "-1" (without quotes).

The first line of the input contains integer numbers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$0 \le k \le n$$$). The second line of the input contains $$$n$$$ integer numbers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the sequence itself.

Print any integer number $$$x$$$ from range $$$[1; 10^9]$$$ such that exactly $$$k$$$ elements of given sequence is less or equal to $$$x$$$. If there is no such $$$x$$$, print "-1" (without quotes).

NoteIn the first example $$$5$$$ is also a valid answer because the elements with indices $$$[1, 3, 4, 6]$$$ is less than or equal to $$$5$$$ and obviously less than or equal to $$$6$$$.In the second example you cannot choose any number that only $$$2$$$ elements of the given sequence will be less than or equal to this number because $$$3$$$ elements of the given sequence will be also less than or equal to this number.

package main

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

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

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

func main() {
	//STDOUT MUST BE FLUSHED MANUALLY
	defer writer.Flush()

	var n, k int
	scanf("%d %d\n", &n, &k)
	array := make([]int, n, int(2*math.Pow(10, 5)))

	for i := 0; i < n; i++ {
		scanf("%d", &array[i])
	}

	sort.Ints(array)

	answer := 0

	// printf("sorted array: %v\n", array)

	if k == 0 {
		answer = array[0] - 1
	} else {
		answer = array[k-1]
	}

	// printf("answer: %v\n", answer)

	counter := 0

	for _, val := range array {
		if val <= answer {
			counter++
		}
	}

	if answer < 1 || counter != k {
		printf("-1\n")
	} else {
		printf("%v\n", answer)
	}

	// example
	// var a, b int
	// scanf("%d %d", &a, &b)
	// printf("%d\n", a+b)
}

package main

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

func main() {
	rdr := bufio.NewReader(os.Stdin)
	var n, k int
	fmt.Fscan(rdr, &n, &k)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(rdr, &a[i])
	}
	sort.Ints(a)
	if k == 0 {
		if a[0] == 1 {
			fmt.Println(-1)
		} else {
			fmt.Println(1)
		}

		return
	}
	if k == n {
		fmt.Println(a[n-1])
		return
	}
	lastElem := 0
	result := -1
	for i := 0; i < n; i++ {
		if lastElem != a[i] {
			if i > k {
				break
			}
			if i == k {
				result = lastElem
			}
			lastElem = a[i]
		}
	}
	fmt.Println(result)
}

// http://codeforces.com/problemset/problem/977/C

package main

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

func main() {
	var n, k int
	var res int
	in := bufio.NewReader(os.Stdin)
	_, err := fmt.Fscan(in, &n, &k)
	if err != nil {
		fmt.Println(err)
	} else {
		seq := make([]int, n)
		for i := 0; i < n; i++ {
			_, err := fmt.Fscan(in, &seq[i])
			if err != nil {
				fmt.Println(err)
			}
		}
		sort.Ints(seq)

		if k == 0 { //Boundinary case
			res = seq[0] //Grabs lower element
			if res == 1 {
				res = -1
			} else {
				res--
			}
		} else if k == n { //Boundinary case
			res = seq[len(seq)-1]
		} else { //regular case
			if seq[k-1] == seq[k] {
				res = -1
			} else {
				res = seq[k-1]
			}
		}
	}
	fmt.Println(res)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF977C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	var n, k int
	Fscan(in, &n, &k)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	sort.Ints(a)
	if k == n {
		Fprint(_w, int(1e9))
	} else if k > 0 && a[k-1] != a[k] {
		Fprint(_w, a[k]-1)
	} else if k == 0 && a[0] != 1 {
		Fprint(_w, 1)
	} else {
		Fprint(_w, -1)
	}
}

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

package main

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

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

	var n, k int

	fmt.Fscan(r, &n, &k)
	seq := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Fscan(r, &seq[i])
	}

	sort.Ints(seq)

	var ans int

	if k == 0 {
		ans = seq[0] - 1
	} else {
		ans = seq[k-1]
	}

	var count int
	for i := 0; i < n; i++ {
		if seq[i] <= ans {
			count++
		}
	}

	if count != k || ans < 1 {
		fmt.Fprintln(w, -1)
	} else {
		fmt.Fprintln(w, ans)
	}
}

package main

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

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

	var n, k int
	fmt.Fscan(reader, &n, &k)

	arr := make([]int, n+1)
	used := make(map[int]int)
	arr[0] = 0
	for i := 1; i <= n; i++ {
		fmt.Fscan(reader, &arr[i])
		used[arr[i]]++
	}

	sort.Ints(arr)

	for i := 1; i < k; i++ {
		used[arr[i]]--
	}

	if used[arr[k]] == 1 {
		fmt.Println(arr[k])
	} else if k < n && used[arr[k]] == 0 && used[arr[k]+1] == 0 {
		fmt.Println(arr[k] + 1)
	} else {
		fmt.Println(-1)
	}
}

package main

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

func main() {
	var line string
	reader := bufio.NewReader(os.Stdin)
	line, _ = reader.ReadString('\n')
	arrStartStrings := strings.Split(strings.TrimSpace(line), " ")
	n, _ := strconv.Atoi(arrStartStrings[0])
	k, _ := strconv.Atoi(arrStartStrings[1])
	start := make([]int, n)
	line, _ = reader.ReadString('\n')
	arrStartStrings = strings.Split(strings.TrimSpace(line), " ")
	for i, v := range arrStartStrings {
		start[i], _ = strconv.Atoi(v)
	}
	sort.Ints(start)
	if n<k{
		fmt.Println(-1)
		os.Exit(0)
	} else if n==k{
		fmt.Println(start[k-1])
		os.Exit(0)
	} else if k==0{
		if start[0]>1{
			fmt.Println(1)
			os.Exit(0)
		} else{
			fmt.Println(-1)
			os.Exit(0)
		}
	} else {
		if start[k-1]<start[k]{
			fmt.Println(start[k-1])
		} else {
			fmt.Println(-1)
			os.Exit(0)
		}
	}
}

package main

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

func Init() {
}

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

	sort.Ints(A)

	if K == 0 {
		if A[0] == 1 {
			io.Println(-1)
		} else {
			io.Println(1)
		}
		return
	}

	idx := 0
	for idx < N {
		for idx + 1 < N && A[idx] == A[idx + 1] {
			idx++
		}
		if idx + 1 == K {
			io.Println(A[idx])
			return
		} else if idx + 1 > K {
			break
		}
		idx++
	}
	io.Println(-1)
}

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 (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	var (
		n, k int
		a    []int
	)

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

	n, _ = strconv.Atoi(scanner.Text())

	scanner.Scan()
	k, _ = strconv.Atoi(scanner.Text())

	a = make([]int, n)

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

	if k == 0 {
		if a[0] > 1 {
			fmt.Println("1")
		} else {
			fmt.Println("-1")
		}

		return
	}

	if n == 1 {
		fmt.Println(a[0])

		return
	}

	if k != n && a[k-1] == a[k] {
		fmt.Println("-1")
		return
	}
	fmt.Println(a[k-1])
}

package main

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

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

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

func main() {
	//STDOUT MUST BE FLUSHED MANUALLY
	defer writer.Flush()

	var n, k int
	scanf("%d %d\n", &n, &k)
	array := make([]int, n, int(2*math.Pow(10, 5)))

	sort.Ints(array)

	for i := 0; i < n; i++ {
		scanf("%d", &array[i])
	}

	counter := int(0)

	possible := true

	for i := 0; i < n; i++ {
		if counter < k {
			counter++
		} else if counter <= k && i > 0 && array[i-1] == array[i] {
			counter++
		} else if counter > k {
			possible = false
			break
		}
	}

	answer := int(-1)

	if possible {
		if counter < k {
			answer = -1
		} else if counter == k && counter > 0 {
			answer = array[counter-1]
		}
	} else {
		answer = -1
	}

	if k == 0 && array[0] == 1 {
		answer = -1
	} else if k == 0 {
		answer = 1
	}

	// fmt.Printf("%v\n", counter)
	fmt.Printf("%v\n", answer)

	var a, b int
	scanf("%d %d", &a, &b)
	printf("%d\n", a+b)
}

package main

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

func main() {
	var n, k int
	fmt.Scanf("%d %d\n", &n, &k)
	array := make([]int, n, int(2*math.Pow(10, 5)))

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

	sort.Ints(array)

	// fmt.Printf("%v\n", array)

	counter := int(0)

	possible := true

	for i := 0; i < n; i++ {
		if counter < k {
			counter++
		} else if counter <= k && i > 0 && array[i-1] == array[i] {
			counter++
		} else if counter > k {
			possible = false
			break
		}
	}

	var answer int

	if possible {
		if counter < k {
			answer = -1
		} else if counter == k && counter < n && counter > 0 {
			answer = array[counter-1]
		}
	} else {
		answer = -1
	}

	// fmt.Printf("%v\n", counter)
	fmt.Printf("%v\n", answer)
}

package main

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

func main() {
	var n, k int
	fmt.Scanf("%d %d\n", &n, &k)
	array := make([]int, n, int(2*math.Pow(10, 5)))

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

	sort.Ints(array)

	// fmt.Printf("%v\n", array)

	counter := int(0)

	possible := true

	for i := 0; i < n; i++ {
		if counter < k {
			counter++
		} else if counter <= k && i > 0 && array[i-1] == array[i] {
			counter++
		} else if counter > k {
			possible = false
			break
		}
	}

	answer := int(-1)

	if possible {
		if counter < k {
			answer = -1
		} else if counter == k && counter > 0 {
			answer = array[counter-1]
		}
	} else {
		answer = -1
	}

	// fmt.Printf("%v\n", counter)
	fmt.Printf("%v\n", answer)
}

package main

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

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

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

func main() {
	//STDOUT MUST BE FLUSHED MANUALLY
	defer writer.Flush()

	var n, k int
	scanf("%d %d\n", &n, &k)
	array := make([]int, n, int(2*math.Pow(10, 5)))

	sort.Ints(array)

	for i := 0; i < n; i++ {
		scanf("%d", &array[i])
	}

	counter := int(0)

	possible := true

	for i := 0; i < n; i++ {
		if counter < k {
			counter++
		} else if counter <= k && i > 0 && array[i-1] == array[i] {
			counter++
		} else if counter > k {
			possible = false
			break
		}
	}

	answer := int(-1)

	if possible {
		if counter < k {
			answer = -1
		} else if counter == k && counter > 0 {
			answer = array[counter-1]
		}
	} else {
		answer = -1
	}

	if k == 0 && array[0] == 1 {
		answer = -1
	} else if k == 0 {
		answer = 1
	}

	// fmt.Printf("%v\n", counter)
	fmt.Printf("%v\n", answer)

	// example
	// var a, b int
	// scanf("%d %d", &a, &b)
	// printf("%d\n", a+b)
}

package main

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

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

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

func main() {
	//STDOUT MUST BE FLUSHED MANUALLY
	defer writer.Flush()

	var n, k int
	scanf("%d %d\n", &n, &k)
	array := make([]int, n, int(2*math.Pow(10, 5)))

	sort.Ints(array)

	for i := 0; i < n; i++ {
		scanf("%d", &array[i])
	}

	answer := 0

	if k == 0 {
		answer = array[0] - 1
	} else {
		answer = array[k-1]
	}

	counter := 0

	for _, val := range array {
		if val <= answer {
			counter++
		}
	}

	if answer < 1 || counter != k {
		printf("-1\n")
	} else {
		printf("%v\n", answer)
	}

	// example
	// var a, b int
	// scanf("%d %d", &a, &b)
	// printf("%d\n", a+b)
}

package main

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

func main() {
	var n, k int
	fmt.Scanf("%d %d\n", &n, &k)
	array := make([]int, n, int(2*math.Pow(10, 5)))

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

	sort.Ints(array)

	// fmt.Printf("%v\n", array)

	counter := int(0)

	possible := true

	for i := 0; i < n; i++ {
		if counter < k {
			counter++
		} else if counter <= k && i > 0 && array[i-1] == array[i] {
			counter++
		} else if counter > k {
			possible = false
			break
		}
	}

	var answer int

	if possible {
		if counter < k {
			fmt.Printf("1\n")
			answer = -1
		} else if counter == k && counter < n && (array[counter]-array[counter-1] > 1) {
			fmt.Printf("2\n")
			answer = array[counter-1] + 1
		}
	} else {
		answer = -1
	}

	// fmt.Printf("%v\n", counter)
	fmt.Printf("%v\n", answer)
}

package main

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

func main() {
	rdr := bufio.NewReader(os.Stdin)
	var n, k int
	fmt.Fscan(rdr, &n, &k)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(rdr, &a[i])
	}
	sort.Ints(a)
	lastElem := 0
	result := -1
	for i := 0; i < n; i++ {
		if lastElem != a[i] {
			if i > k {
				break
			}
			if i == k {
				result = lastElem
			}
			lastElem = a[i]
		}
	}
	fmt.Println(result)
}

package main

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

func main() {
	rdr := bufio.NewReader(os.Stdin)
	var n, k int
	fmt.Fscan(rdr, &n, &k)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(rdr, &a[i])
	}
	sort.Ints(a)
	fmt.Println(a)
	lastElem := 0
	result := -1
	for i := 0; i < n; i++ {
		if lastElem != a[i] {
			if i > k {
				break
			}
			if i == k {
				result = lastElem
			}
			lastElem = a[i]
		}
	}
	fmt.Println(result)
}

package main

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

func main() {
	rdr := bufio.NewReader(os.Stdin)
	var n, k int
	fmt.Fscan(rdr, &n, &k)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(rdr, &a[i])
	}
	if k == 0 {
		fmt.Println(-1)
		return
	}
	if k == n {
		fmt.Println(n)
		return
	}
	sort.Ints(a)
	lastElem := 0
	result := -1
	for i := 0; i < n; i++ {
		if lastElem != a[i] {
			if i > k {
				break
			}
			if i == k {
				result = lastElem
			}
			lastElem = a[i]
		}
	}
	fmt.Println(result)
}

package main

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

func main() {
	rdr := bufio.NewReader(os.Stdin)
	var n, k int
	fmt.Fscan(rdr, &n, &k)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(rdr, &a[i])
	}
	if k == 0 {
		if a[0] == 1 {
			fmt.Println(-1)
		} else {
			fmt.Println(1)
		}

		return
	}
	sort.Ints(a)
	if k == n {
		fmt.Println(a[n-1])
		return
	}
	lastElem := 0
	result := -1
	for i := 0; i < n; i++ {
		if lastElem != a[i] {
			if i > k {
				break
			}
			if i == k {
				result = lastElem
			}
			lastElem = a[i]
		}
	}
	fmt.Println(result)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF977C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	var n, k int
	Fscan(in, &n, &k)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	sort.Ints(a)
	if k == n {
		Fprint(_w, int(1e9))
	} else if k > 0 && a[k-1] != a[k] {
		Fprint(_w, a[k]-1)
	} else {
		Fprint(_w, -1)
	}
}

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

package main

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

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

	var n, k int

	fmt.Fscan(r, &n, &k)
	seq := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Fscan(r, &seq[i])
	}

	sort.Ints(seq)
	fmt.Println(seq)

	if (seq[k-1] >= seq[k-1]) && (seq[k-1] < seq[k]) {
		fmt.Fprintln(w, seq[k-1])
	} else {
		fmt.Fprintln(w, -1)
	}

}

package main

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

func main() {
	var (
		n, k int
		a    []int
	)

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

	n, _ = strconv.Atoi(scanner.Text())

	scanner.Scan()
	k, _ = strconv.Atoi(scanner.Text())

	a = make([]int, n)

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

	if k == 0 || n == 1 {
		if a[0] > 1 {
			fmt.Println("1")
		} else {
			fmt.Println("-1")
		}

		return
	}

	if a[k-1] == a[k] {
		fmt.Println("-1")
		return
	}
	fmt.Println(a[k-1])
}

package main

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

func main() {
	var (
		n, k int
		a    []int
	)

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

	n, _ = strconv.Atoi(scanner.Text())

	scanner.Scan()
	k, _ = strconv.Atoi(scanner.Text())

	a = make([]int, n)

	for i := 0; i < n; i++ {
		scanner.Scan()
		a[i], _ = strconv.Atoi(scanner.Text())
	}
	sort.Ints(a)
	fmt.Println(a)

	if a[k-1] == a[k] {
		fmt.Println("-1")
		return
	}
	fmt.Println(a[k-1])
}


NoteIn the first sample Anton has one icosahedron, one cube, one tetrahedron and one dodecahedron. Icosahedron has 20 faces, cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces. In total, they have 20 + 6 + 4 + 12 = 42 faces.

package main

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

func main() {
	var (
		n, result int
		err       error
	)
	scanner := bufio.NewScanner(os.Stdin)
	if scanner.Scan() {
		n, err = strconv.Atoi(scanner.Text())
		if err != nil {
			panic(err)
		}
	}

	for i := 0; i < n; i++ {
		scanner.Scan()
		switch scanner.Text()[0] {
		case 'I':
			result += 20
		case 'C':
			result += 6
		case 'T':
			result += 4
		case 'D':
			result += 12
		case 'O':
			result += 8
		}
	}
	fmt.Println(result)
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	inputData := make([]string, 0)
	for scanner.Scan() {
		inputData = append(inputData, scanner.Text())
	}
	countFaces := 0
	n, _ := strconv.Atoi(inputData[0])
	for i := 0; i < n; i++ {
		if strings.EqualFold(inputData[i+1], "Icosahedron") {
			countFaces += 20
		}
		if strings.EqualFold(inputData[i+1], "Dodecahedron") {
			countFaces += 12
		}
		if strings.EqualFold(inputData[i+1], "Octahedron") {
			countFaces += 8
		}
		if strings.EqualFold(inputData[i+1], "Cube") {
			countFaces += 6
		}
		if strings.EqualFold(inputData[i+1], "Tetrahedron") {
			countFaces += 4
		}
	}
	fmt.Println(countFaces)
}

// Tetrahedron. Tetrahedron has 4 triangular faces.
// Cube. Cube has 6 square faces.
// Octahedron. Octahedron has 8 triangular faces.
// Dodecahedron. Dodecahedron has 12 pentagonal faces.
// Icosahedron. Icosahedron has 20 triangular faces.

package main

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

var m = map[string]int{
	"Tetrahedron" : 4,
	"Cube" : 6,
	"Octahedron" : 8,
	"Dodecahedron" : 12,
	"Icosahedron" : 20,
}

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

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

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

func main() {

	var T int

	scanf("%d \n", &T)
	result := 0
	for i:=0; i<T; i++ {
		var temp string
		scanf("%s \n", &temp)
		result += m[temp]
	}

	fmt.Println(result)

}

package main

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

func main() {
	s2f := make(map[string]int)
	in := bufio.NewReader(os.Stdin)
	s2f["Tetrahedron"] = 4
	s2f["Cube"] = 6
	s2f["Octahedron"] = 8
	s2f["Dodecahedron"] = 12
	s2f["Icosahedron"] = 20
	tot, faces := 0, 0
	fmt.Fscan(in, &tot)
	for ; tot > 0; tot-- {
		var s string
		fmt.Fscan(in, &s)
		f, ok := s2f[s]
		if ok {faces += f}
	}
	fmt.Println(faces)
}

package main

import "fmt"
import "bufio"
import "os"

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

    var cnt int

    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    for scanner.Scan() {
        if scanner.Text() == "Tetrahedron" {
            cnt += 4
        } else if scanner.Text() == "Cube" {
            cnt += 6
        } else if scanner.Text() == "Octahedron" {
            cnt += 8
        } else if scanner.Text() == "Dodecahedron" {
            cnt += 12
        } else if scanner.Text() == "Icosahedron" {
            cnt += 20
        }
    }
    fmt.Print(cnt)
}

package main

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

func main() {
	var n, count int
	count = 0
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	n, _ = strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		scanner.Scan()
		str := scanner.Text()
		switch str {
		case "Tetrahedron":
			count += 4
		case "Cube":
			count += 6
		case "Octahedron":
			count += 8
		case "Dodecahedron":
			count += 12
		case "Icosahedron":
			count += 20
		}
	}
	fmt.Println(count)
}

package main

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

func main() {
	var line string
	var testcount, summ int
	fmt.Scanf("%d\n", &testcount)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < testcount; i++ {
		line, _ = reader.ReadString('\n')
		line = strings.TrimSpace(line)
		switch line {
		case "Tetrahedron":
			summ += 4
		case "Cube":
			summ += 6
		case "Octahedron":
			summ += 8
		case "Dodecahedron":
			summ += 12
		case "Icosahedron":
			summ += 20
		}
	}
	fmt.Println(summ)
}

package main

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

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

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

	polyhedrons := make([]string, n)

	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%s\n", &polyhedrons[i])
	}

	fmt.Printf("%d", antonAndPolyhedrons(polyhedrons))
}

func antonAndPolyhedrons(polyhedrons []string) int {
	var count int
	faceCount := map[string]int{
		"Tetrahedron":  4,
		"Cube":         6,
		"Octahedron":   8,
		"Dodecahedron": 12,
		"Icosahedron":  20,
	}

	for _, polyhedron := range polyhedrons {
		count += faceCount[polyhedron]
	}
	return count
}

package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	count := 0
	for i := 0; i < N; i++ {
		s := sc.NextLine()

		switch s {
		case "Tetrahedron":
			count += 4
		case "Cube":
			count += 6
		case "Octahedron":
			count += 8
		case "Dodecahedron":
			count += 12
		case "Icosahedron":
			count += 20
		}
	}
	fmt.Println(count)

}

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

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

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

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

 package main

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

var scanner *bufio.Scanner

func getI64() int64 {
	scanner.Scan()
	x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return x
}
func getI() int {
	return int(getI64())
}
func getF() float64 {
	scanner.Scan()
	x, _ := strconv.ParseFloat(scanner.Text(), 64)
	return x
}
func getS() string {
	scanner.Scan()
	return scanner.Text()
}

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

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

func printf(format string, x ...interface{}) {
	fmt.Fprintf(os.Stdout, format, x...)
}

const alphabets = "abcdefghijklmnopqrstuvwxyz"

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

	Problem785A()
}

func Problem785A() {
	n := getI()
	mapper := make(map[string]int,0)
	total := 0
	for i:=0;i<n;i++{
		s := getS()
		mapper[s] = mapper[s] + 1
	}
	for k := range mapper {
		switch(k){
		case "Tetrahedron":
			total += mapper[k] * 4
			break
		case "Cube":
			total += mapper[k] * 6
			break
		case "Octahedron":
			total += mapper[k] * 8
			break
		case "Dodecahedron":
			total += mapper[k] * 12
			break
		case "Icosahedron":
			total += mapper[k] * 20
			break
		default:
			total += 0
			break
		}
	}
	printf("%d",total)
}

package main

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

var DEBUG = "N"
var DEBUG_BOOL = false

func debug(args ...interface{}) {
	if DEBUG_BOOL {
		fmt.Fprintln(os.Stderr, args...)
	}
}

func count(s string) (cnt int) {
    switch s {
    case "Tetrahedron":
        cnt = 4
    case "Cube":
        cnt = 6
    case "Octahedron":
        cnt = 8
    case "Dodecahedron":
        cnt = 12
    case "Icosahedron":
        cnt = 20
    }

    return
}

func main() {
	if DEBUG != "N" {
		DEBUG_BOOL = true
	}

	var N int
    fmt.Scan(&N)
    debug("N", N)

    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    //  in := bufio.NewReader(os.Stdin)
	//  fmt.Fscanf(in, "%d\n", &N)

    polys := make([]string, N)
    debug(len(polys), polys)
    //  for scanner.Scan() {
    for i := range polys {
        //  fmt.Scan(&polys[i])
        //  polys[i], _ = in.ReadString('\n')
        //  polys[i] = polys[i][:len(polys[i])-1]
        scanner.Scan()
        polys[i] = scanner.Text()
    }
    debug(len(polys), polys)

    total_cnt := 0
    for _, v := range polys {
        total_cnt += count(v)
    }

    fmt.Println(total_cnt)
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())

	var polyhedrons = map[string]int{
		"Tetrahedron":  4,
		"Cube":         6,
		"Octahedron":   8,
		"Dodecahedron": 12,
		"Icosahedron":  20,
	}

	ans := 0
	for i := 0; i < n; i++ {
		scanner.Scan()
		ans += polyhedrons[scanner.Text()]
	}

	fmt.Println(ans)

}

package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Scan()
	temp := s.Text()
	n, _ := strconv.Atoi(temp)
	f := 0
	for i := 0; i < n; i++ {
		s.Scan()
		curr := s.Text()
		if curr == "Tetrahedron" {
			f += 4
		} else if curr == "Cube" {
			f += 6
		} else if curr == "Octahedron" {
			f += 8
		} else if curr == "Dodecahedron" {
			f += 12
		} else {
			f += 20
		}
	}
	fmt.Println(f)
}

package main

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

// https://codeforces.com/problemset/problem/785/A
// A. Anton and Polyhedrons
// time limit per test
// 2 seconds
// memory limit per test
// 256 megabytes
// input
// standard input
// output
// standard output

// Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons:

//     Tetrahedron. Tetrahedron has 4 triangular faces.
//     Cube. Cube has 6 square faces.
//     Octahedron. Octahedron has 8 triangular faces.
//     Dodecahedron. Dodecahedron has 12 pentagonal faces.
//     Icosahedron. Icosahedron has 20 triangular faces.

// All five kinds of polyhedrons are shown on the picture below:

// Anton has a collection of n polyhedrons. One day he decided to know, how many faces his polyhedrons have in total. Help Anton and find this number!
// Input

// The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of polyhedrons in Anton's collection.

// Each of the following n lines of the input contains a string si — the name of the i-th polyhedron in Anton's collection. The string can look like this:

//     "Tetrahedron" (without quotes), if the i-th polyhedron in Anton's collection is a tetrahedron.
//     "Cube" (without quotes), if the i-th polyhedron in Anton's collection is a cube.
//     "Octahedron" (without quotes), if the i-th polyhedron in Anton's collection is an octahedron.
//     "Dodecahedron" (without quotes), if the i-th polyhedron in Anton's collection is a dodecahedron.
//     "Icosahedron" (without quotes), if the i-th polyhedron in Anton's collection is an icosahedron.

// Output

// Output one number — the total number of faces in all the polyhedrons in Anton's collection.

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

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

	var nFaces int
	for i := 0; i < n; i++ {
		var polyhedron string
		_, _ = fmt.Fscan(bufStdin, &polyhedron)

		switch polyhedron {
		case "Tetrahedron":
			nFaces += 4
		case "Cube":
			nFaces += 6
		case "Octahedron":
			nFaces += 8
		case "Dodecahedron":
			nFaces += 12
		case "Icosahedron":
			nFaces += 20
		}
	}

	fmt.Print(nFaces)
}

package main

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

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

func PrintInts(ints ...int) {
	for _, value := range ints {
		writer.WriteString(strconv.Itoa(value))
		writer.WriteByte(' ')
	}
}
func PrintStrings(strs ...string) {
	for _, value := range strs {
		writer.WriteString(value)
		writer.WriteByte(' ')
	}
}

func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)
	g := map[string]int{"Tetrahedron":4,"Cube":6,"Octahedron":8,"Dodecahedron":12,"Icosahedron":20}
	var s int
	n := ReadInt32()
	for i := 0;i<n;i++ {
		s += g[ReadString()]
	}
	fmt.Println(s)
}

package main

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

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

func taskSolution(a []byte) (ans int) {
	for _, char := range a {
		switch char {
		case 'T':
			// Tetrahedron
			ans += 4
		case 'C':
			// Cube
			ans += 6
		case 'O':
			// Octahedron
			ans += 8
		case 'D':
			// Dodecahedron
			ans += 12
		case 'I':
			// Icosahedron
			ans += 20
		}
	}
	return ans
}

func main() {
	inRaw, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err)
	}

	fmt.Println(taskSolution(inRaw))
}

package main

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

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

func readWord(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Split(bufio.ScanWords)

	n := readInt(scanner)

	ans := 0
	for i := 0; i < n; i++ {
		geoShape := readWord(scanner)
		if strings.Compare(geoShape, "Tetrahedron") == 0 {
			ans += 4
		} else if strings.Compare(geoShape, "Cube") == 0 {
			ans += 6
		} else if strings.Compare(geoShape, "Octahedron") == 0 {
			ans += 8
		} else if strings.Compare(geoShape, "Dodecahedron") == 0 {
			ans += 12
		} else if strings.Compare(geoShape, "Icosahedron") == 0 {
			ans += 20
		}
	}
	fmt.Println(ans)
}

package main

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

func main() {
	var n int
	fmt.Scanf("%d\n" , &n)
	ans := 0
	sc := bufio.NewReader(os.Stdin)
	for i:=1; i <= n; i ++ {
		s,_ := sc.ReadString('\n')
		if s[0] == 'T' {
			ans += 4
		}else if s[0] == 'C'{
			ans += 6
		}else if s[0] == 'O' {
			ans += 8
		}else if s[0] == 'D' {
			ans += 12
		}else if s[0] == 'I'{
			ans += 20
		}
	}
	fmt.Print(ans)
}

package main

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

func main() {
	face := map[string]int{"Tetrahedron": 4, "Cube": 6, "Octahedron": 8, "Dodecahedron": 12, "Icosahedron": 20}
	var n int
	var s string
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &n)
	ans := 0
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &s)
		ans += face[s]
	}
	fmt.Println(ans)
}

// A. Anton and Polyhedrons
/*
Anton's favourite geometric figures are regular polyhedrons.
Note that there are five kinds of regular polyhedrons:

    Tetrahedron. Tetrahedron has 4 triangular faces.
    Cube. Cube has 6 square faces.
    Octahedron. Octahedron has 8 triangular faces.
    Dodecahedron. Dodecahedron has 12 pentagonal faces.
    Icosahedron. Icosahedron has 20 triangular faces.

All five kinds of polyhedrons are shown on the picture below:

Anton has a collection of n polyhedrons. One day he decided to know,
how many faces his polyhedrons have in total. Help Anton and find this number!

Input
The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) —
the number of polyhedrons in Anton's collection.

Each of the following n lines of the input contains a string si —
the name of the i-th polyhedron in Anton's collection. The string can look like this:

    "Tetrahedron" (without quotes), if the i-th polyhedron in Anton's collection is a tetrahedron.
    "Cube" (without quotes), if the i-th polyhedron in Anton's collection is a cube.
    "Octahedron" (without quotes), if the i-th polyhedron in Anton's collection is an octahedron.
    "Dodecahedron" (without quotes), if the i-th polyhedron in Anton's collection is a dodecahedron.
    "Icosahedron" (without quotes), if the i-th polyhedron in Anton's collection is an icosahedron.

Output

Output one number — the total number of faces in all the polyhedrons in Anton's collection.
Examples

Input
4
Icosahedron
Cube
Tetrahedron
Dodecahedron

Output
42

Input
3
Dodecahedron
Octahedron
Octahedron

Output
28

Note
In the first sample Anton has one icosahedron, one cube,
one tetrahedron and one dodecahedron. Icosahedron has 20 faces,
cube has 6 faces, tetrahedron has 4 faces and dodecahedron has 12 faces.
In total, they have 20 + 6 + 4 + 12 = 42 faces.
*/
package main

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

func main() {
	polyhedrons := map[string]int{
		"Tetrahedron":  4,
		"Cube":         6,
		"Octahedron":   8,
		"Dodecahedron": 12,
		"Icosahedron":  20,
	}
	reader := bufio.NewReader(os.Stdin)
	input, _, _ := reader.ReadLine()

	n, _ := strconv.Atoi(string(input))
	total := 0
	for n > 0 {
		i, _, _ := reader.ReadLine()
		total += polyhedrons[string(i)]
		n--
	}
	fmt.Print(total)
}

package main

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

func main() {
	var n int
	var ans int
	var line string
	fmt.Scan(&n)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i <= n; i++ {
		line, _ = reader.ReadString('\n')
		line = strings.TrimSpace(line)
		switch line {
		case "Tetrahedron":
			ans += 4
		case "Cube":
			ans += 6
		case "Octahedron":
			ans += 8
		case "Dodecahedron":
			ans += 12
		case "Icosahedron":
			ans += 20
		}
	}
	fmt.Println(ans)
}

package main

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

func main(){
    var(
        n int
        m = map[string]int{
            "Tetrahedron":4,
            "Cube":6,
            "Octahedron":8,
            "Dodecahedron":12,
            "Icosahedron":20,
        }
        str string
        res =0
        sc = bufio.NewScanner(os.Stdin)
    )
    sc.Scan()
    n,_= strconv.Atoi(sc.Text())
    for i:=0;i<n;i++{
        sc.Scan()
        str = sc.Text()
        res += m[str]
    }
    fmt.Println(res)
}

package main

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

func main() {
	io := newIo()
	n := io.nextInt()

	dic := map[rune]int{
		'T': 4, 'C': 6, 'O': 8,
		'D': 12, 'I': 20,
	}

	cnt := 0
	for range make([]struct{}, n) {
		s := io.next()
		cnt += dic[rune(s[0])]
	}

	fmt.Println(cnt)
}

type _io struct {
	reader    *bufio.Reader
	tokens    []string
	nextToken int
}

func newIo() *_io {
	return &_io{
		reader: bufio.NewReader(os.Stdin),
	}
}

func (_io *_io) nextLine() string {
	var buffer []byte
	for {
		line, isPrefix, _ := _io.reader.ReadLine()
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (_io *_io) next() string {
	for _io.nextToken >= len(_io.tokens) {
		line := _io.nextLine()
		_io.tokens = strings.Fields(line)
		_io.nextToken = 0
	}
	r := _io.tokens[_io.nextToken]
	_io.nextToken++
	return r
}

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

package main

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

func main() {
	var n, quantity int
	var inp string
	fmt.Scanln(&n)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < n; i++ {
		inp, _ = reader.ReadString('\n')
		inp = strings.TrimSpace(inp)
		switch inp {
		case "Tetrahedron":
			quantity += 4
		case "Cube":
			quantity += 6
		case "Octahedron":
			quantity += 8
		case "Dodecahedron":
			quantity += 12
		case "Icosahedron":
			quantity += 20
		}
	}
	fmt.Println(quantity)
}

//многогранники
package main

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

func main() {
	var n, edges int
	var typ string
	var points map[string]int = map[string]int{
		"Tetrahedron":  4,
		"Cube":         6,
		"Octahedron":   8,
		"Dodecahedron": 12,
		"Icosahedron":  20,
	}
	fmt.Scanln(&n)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < n; i++ {
		typ, _ = reader.ReadString('\n')
		typ = strings.TrimSpace(typ)
		edges += points[typ]
	}
	fmt.Println(edges)
}

/*
В первой строке входных данных находится целое число n (1 ≤ n ≤ 200 000) — количество многогранников в коллекции у Антона.

В следующих n строках входных данных находится по одной строке si — название i-го многогранника в коллекции Антона. Строка может иметь следующий вид:

«Tetrahedron» (без кавычек), если i-й многогранник в коллекции Антона — тетраэдр.
«Cube» (без кавычек), если i-й многогранник в коллекции Антона — куб.
«Octahedron» (без кавычек), если i-й многогранник в коллекции Антона — октаэдр.
«Dodecahedron» (без кавычек), если i-й многогранник в коллекции Антона — додекаэдр.
«Icosahedron» (без кавычек), если i-й многогранник в коллекции Антона — икосаэдр.
Выходные данные
Выведите одно целое число — суммарное число граней у всех многогранников в коллекции Антона.
4
Icosahedron
Cube
Tetrahedron
Dodecahedron
42
*/

package main

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

func main() {
	var n, quantity int
	var inp string
	fmt.Scanln(&n)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < n; i++ {
		inp, _ = reader.ReadString('\n')
		inp = strings.TrimSpace(inp)
		if inp == "Tetrahedron" {
			quantity += 4
		} else if inp == "Cube" {
			quantity += 6
		} else if inp == "Octahedron" {
			quantity += 8
		} else if inp == "Dodecahedron" {
			quantity += 12
		} else if inp == "Icosahedron" {
			quantity += 20
		}
	}
	fmt.Println(quantity)
}

package main

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

func main() {
	var n int

	reader := bufio.NewReader(os.Stdin)

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

	ans := 0

	for ; n > 0; n-- {
		s, _, _ := reader.ReadLine()

		switch string(s) {
		case "Tetrahedron":
			ans += 4
		case "Cube":
			ans += 6
		case "Octahedron":
			ans += 8
		case "Dodecahedron":
			ans += 12
		case "Icosahedron":
			ans += 20
		}

	}

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

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())

	var sum uint = 0

	for i := 0; i < n; i++ {
		scanner.Scan();
		figure := scanner.Text()

		switch rune(figure[0]) {
		case 'T':
			sum += 4
		case 'C':
			sum += 6
		case 'O':
			sum += 8
		case 'D':
			sum += 12
		case 'I':
			sum += 20
		}
	}

	fmt.Println(sum)
}

package main

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

func main() {
	myMap := map[string]int{
		"Tetrahedron":  4,
		"Cube":         6,
		"Octahedron":   8,
		"Dodecahedron": 12,
		"Icosahedron":  20,
	}
	var n int
	fmt.Scanf("%d \n", &n)

	scanner := bufio.NewScanner(os.Stdin)
	result := 0
	for i := 0; i < n; i++ {
		scanner.Scan()
		temp := scanner.Text()
		result += myMap[temp]
	}
	fmt.Print(result)
}

package main

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

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

	face_mapping := map[string]int{
		"Tetrahedron":  4,
		"Cube":         6,
		"Octahedron":   8,
		"Dodecahedron": 12,
		"Icosahedron":  20}
	faces := 0

	reader := bufio.NewReader(os.Stdin)
	re := regexp.MustCompile(`\r?\n`)
	for i := 0; i < n; i++ {
		if s, err := reader.ReadString('\n'); err != nil {
			if err != io.EOF {
				return
			}
		} else {
			s = re.ReplaceAllString(s, "")
			faces += face_mapping[s]
		}
	}

	fmt.Println(faces)
}

package main

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

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 1024 * 1024)
	n := 0
	fmt.Sscanf(readLine(reader), "%d", &n)

	set := map[string]int{
		"Tetrahedron": 4,
		"Cube": 6,
		"Octahedron": 8,
		"Dodecahedron": 12,
		"Icosahedron": 20,
	}
	sum := 0
	for i := 0; i < n; i++ {
		line := readLine(reader)
		sum+=set[line]
	}
	fmt.Println(sum)
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

package main

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

func main() {
	var line string
	var testcount, summ int
	fmt.Scanln(&testcount)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < testcount; i++ {
		line, _ = reader.ReadString('\n')
		line = strings.TrimSpace(line)
		switch line {
		case "Tetrahedron":
			summ += 4
		case "Cube":
			summ += 6
		case "Octahedron":
			summ += 8
		case "Dodecahedron":
			summ += 12
		case "Icosahedron":
			summ += 20
		}
	}
	fmt.Println(summ)
}

package main

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

func main() {
	var n, amount int
	var num string
	fmt.Scanln(&n)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < n; i++ {
		num, _ = reader.ReadString('\n')
		num = strings.TrimSpace(num)
		switch num {
		case "Tetrahedron":
			amount += 4
		case "Cube":
			amount += 6
		case "Octahedron":
			amount += 8
		case "Dodecahedron":
			amount += 12
		case "Icosahedron":
			amount += 20
		}
	}
	fmt.Println(amount)
}

// A. Anton and Polyhedrons
package main

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

func main() {
	figures := map[rune]uint64{
		'T': uint64(4),
		'C': uint64(6),
		'O': uint64(8),
		'D': uint64(12),
		'I': uint64(20),
	}

	text := ""
	fmt.Scanln(&text)
	numFigures, _ := strconv.Atoi(text)
	reader := bufio.NewReader(os.Stdin)

	counter := uint64(0)
	for i := 0; i < numFigures; i++ {
		r, _, _ := reader.ReadRune()
		reader.ReadLine()
		counter += figures[r]
	}

	fmt.Println(counter)
}

package main

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

func main() {
	n := 0
	sum := 0
	fmt.Scanf("%d\n", &n)
	scanner := bufio.NewScanner(os.Stdin)
	for i := 0; i < n; i++ {
		scanner.Scan()
		str := scanner.Text()
		if str == "Tetrahedron" {
			sum += 4
		} else if str == "Cube" {
			sum += 6
		} else if str == "Octahedron" {
			sum += 8
		} else if str == "Dodecahedron" {
			sum += 12
		} else {
			sum += 20
		}
	}

	fmt.Println(sum)
}

package main

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

func main() {

	var n int

	reader := bufio.NewReader(os.Stdin)
	fmt.Scanf("%d\n", &n)
	cnt := 0

	for i := 0; i < n; i++ {
		str, _, _ := reader.ReadLine()

		x := string(str[0])

		switch x {
		case "T":
			cnt += 4
		case "C":
			cnt += 6
		case "O":
			cnt += 8
		case "D":
			cnt += 12
		case "I":
			cnt += 20
		}
	}
	fmt.Println(cnt)

}

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 s string

func main() {
	fmt.Fscan(reader, &n)
	ans := 0
	for ; n != 0; n-- {
		fmt.Fscan(reader, &s)
		switch s {
		case "Tetrahedron":
			ans += 4
		case "Cube":
			ans += 6
		case "Octahedron":
			ans += 8
		case "Dodecahedron":
			ans += 12
		case "Icosahedron":
			ans += 20
		}
	}
	fmt.Println(ans)
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var n uint32
	var sum uint32 = 0
	var value string
	fmt.Fscanf(in, "%d\n", &n)
	for i := uint32(0); i < n; i++ {
		fmt.Fscanf(in, "%s\n", &value)
		switch value[0] {
		case 84:
			sum += 4
		case 67:
			sum += 6
		case 79:
			sum += 8
		case 68:
			sum += 12
		case 73:
			sum += 20
		}
	}
	fmt.Println(sum)
}

package main

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

func main() {
	var n  int
	var m [256]int
	m['I'] = 20
	m['D'] = 12
	m['O'] = 8
	m['C'] = 6
	m['T'] = 4
	fmt.Scanf("%d\n",&n)
	ret := 0
	reader := bufio.NewReader(os.Stdin)
	for i:=0; i < n; i++ {
		s, _ := reader.ReadString('\n')
		ret += m[s[0]]
	}
	fmt.Println(ret)
}

package main

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

func main() {
	var n, ret  int
	var m [256]int
	m['I'] = 20
	m['D'] = 12
	m['O'] = 8
	m['C'] = 6
	m['T'] = 4
	fmt.Scan(&n)
	scan := bufio.NewScanner(os.Stdin)
	scan.Split(bufio.ScanWords)
	for scan.Scan() {
		ret += m[scan.Text()[0]]
	}
	fmt.Println(ret)
}

package main

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

func settest() (*os.File, *os.File) {
	f, err := os.Open("a.dat")
	if err != nil {
		panic(err)
	}

	oldStdin := os.Stdin
	os.Stdin = f

	return f, oldStdin
}

func main() {
	/*file, oldStdin := settest()
	defer file.Close()
	defer func() { os.Stdin = oldStdin }()*/

	m := map[string]int {
		"Tetrahedron": 4,
		"Cube": 6,
		"Octahedron": 8,
		"Dodecahedron": 12,
		"Icosahedron": 20,
	}
	var n int
	fmt.Scan(&n)
	f := 0
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for scanner.Scan() {
		f += m[scanner.Text()]
	}
	fmt.Println(f)
}

package main

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

func main() {
	s2f := make(map[string]int)
	s2f["Tetrahedron"] = 4
	s2f["Cube"] = 6
	s2f["Octahedron"] = 8
	s2f["Dodecahedron"] = 12
	s2f["Icosahedron"] = 20
	var inputs string
	reader := bufio.NewReader(os.Stdin)
	inputs, _ = reader.ReadString('|')
	faces := 0
	shapes := strings.Split(inputs, "\n")[1:]
	for _, s := range shapes {
		f, ok := s2f[s]
		if ok {faces += f}
	}
	fmt.Println(faces)
}

package main

import (
	"fmt"
)

func main() {
	var s string
	var testcount, summ int
	fmt.Scanf("%d\n", &testcount)
	for i := 0; i < testcount; i++ {
		fmt.Scanf("%s", &s)
		switch s {
		case "Tetrahedron":
			summ += 4
		case "Cube":
			summ += 6
		case "Octahedron":
			summ += 8
		case "Dodecahedron":
			summ += 12
		case "Icosahedron":
			summ += 20
		}
	}
	fmt.Println(summ)
}

package main

import "fmt"

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

	polyhedrons := make([]string, n)

	for i := 0; i < n; i++ {
		fmt.Scanf("%s", &polyhedrons[i])
	}

	fmt.Printf("%d", antonAndPolyhedrons(polyhedrons))
}

func antonAndPolyhedrons(polyhedrons []string) int {
	var count int
	faceCount := map[string]int{
		"Tetrahedron":  4,
		"Cube":         6,
		"Octahedron":   8,
		"Dodecahedron": 12,
		"Icosahedron":  20,
	}

	for _, polyhedron := range polyhedrons {
		count += faceCount[polyhedron]
	}
	return count
}

package main

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

var scanner *bufio.Scanner

func getI64() int64 {
	scanner.Scan()
	x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return x
}
func getI() int {
	return int(getI64())
}
func getF() float64 {
	scanner.Scan()
	x, _ := strconv.ParseFloat(scanner.Text(), 64)
	return x
}
func getS() string {
	scanner.Scan()
	return scanner.Text()
}

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

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

func printf(format string, x ...interface{}) {
	fmt.Fprintf(os.Stdout, format, x...)
}

const alphabets = "abcdefghijklmnopqrstuvwxyz"

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

	Problem785A()
}

func Problem785A() {
	n := getI()
	mapper := make(map[string]int,0)
	total := 0
	for i:=0;i<n;i++{
		s := getS()
		mapper[s] = mapper[s] + 1
	}
	for k := range mapper {
		switch(k){
		case "Tetrahedron":
			total += mapper[k] * 4
			break
		case "Cube":
			total += mapper[k] * 6
			break
		case "Octahedron":
			total += mapper[k] * 8
			break
		case "Dodecahedron":
			total += mapper[k] * 12
			break
		case "Icosahedron":
			total += mapper[k] * 20
			break
		default:
			total += 0
			break
		}
	}
	print(total)
}

package main

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

var DEBUG = "N"
var DEBUG_BOOL = false

func debug(args ...interface{}) {
	if DEBUG_BOOL {
		fmt.Fprintln(os.Stderr, args...)
	}
}

func count(s string) (cnt int) {
    switch s {
    case "Tetrahedron":
        cnt = 4
    case "Cube":
        cnt = 6
    case "Octahedron":
        cnt = 8
    case "Dodecahedron":
        cnt = 12
    case "Icosahedron":
        cnt = 20
    }

    return
}

func main() {
	if DEBUG != "N" {
		DEBUG_BOOL = true
	}

	var N int

    //  scanner := bufio.NewScanner(os.Stdin)
    //  scanner.Split(bufio.ScanWords)
    in := bufio.NewReader(os.Stdin)
	fmt.Fscanf(in, "%d\n", &N)

    polys := make([]string, N)
    debug(len(polys), polys)
    for i := range polys {
        //  fmt.Scan(&polys[i])
        polys[i], _ = in.ReadString('\n')
        polys[i] = polys[i][:len(polys[i])-1]
    }
    debug(len(polys), polys)

    total_cnt := 0
    for _, v := range polys {
        total_cnt += count(v)
    }

    fmt.Println(total_cnt)
}

package main

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

func main() {
	var n int
	fmt.Scan(&n)
	ans := 0
	sc := bufio.NewReader(os.Stdin)
	for i:=1; i <= n; i ++ {
		s,_ := sc.ReadString('\n')
		if s[0] == 'T' {
			ans += 4
		}else if s[0] == 'C'{
			ans += 6
		}else if s[0] == 'O' {
			ans += 8
		}else if s[0] == 'D' {
			ans += 12
		}else {
			ans += 20
		}
	}
	fmt.Print(ans)
}

package main

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

func main(){
    var(
        n int
        m = map[string]int{
            "Tetrahedron":4,
            "Cube":6,
            "Octahedron":8,
            "Dodecahedron":12,
            "Icosahedron":20,
        }
        str string
        res =0
        sc = bufio.NewScanner(os.Stdin)
    )
    fmt.Scan(&n)
    for i:=0;i<n;i++{
        sc.Scan()
        str = sc.Text()
        res += m[str]
    }
    fmt.Println(res)
}

package main

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

func main() {
	var quantity int = 0
	var inp string
	fmt.Scanln(&quantity)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < quantity; i++ {
		inp, _ = reader.ReadString('\n')
		inp = strings.TrimSpace(inp)
		if inp == "Tetrahedron" {
			quantity += 4
		} else if inp == "Cube" {
			quantity += 6
		} else if inp == "Octahedron" {
			quantity += 8
		} else if inp == "Dodecahedron" {
			quantity += 12
		} else if inp == "Icosahedron" {
			quantity += 20
		}
	}
	fmt.Println(quantity)
}

package main

import (
	"fmt"
)

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

	ans := 0

	for ; n > 0; n-- {
		fmt.Scanf("%s\n", &s)

		switch s {
		case "Tetrahedron":
			ans += 4
		case "Cube":
			ans += 6
		case "Octahedron":
			ans += 8
		case "Dodecahedron":
			ans += 12
		case "Icosahedron":
			ans += 20
		}
	}

	println(ans)
}

package main

import (
	"fmt"
)

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

	ans := 0

	for ; n > 0; n-- {
		fmt.Scanf("%s", &s)

		switch s {
		case "Tetrahedron":
			ans += 4
		case "Cube":
			ans += 6
		case "Octahedron":
			ans += 8
		case "Dodecahedron":
			ans += 12
		case "Icosahedron":
			ans += 20
		}
	}

	println(ans)
}

package main

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

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

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

func main() {
	var n int
	var s string
	scanf("%d\n", &n)

	ans := 0

	for ; n > 0; n-- {
		scanf("%s\n", &s)

		switch s {
		case "Tetrahedron":
			ans += 4
		case "Cube":
			ans += 6
		case "Octahedron":
			ans += 8
		case "Dodecahedron":
			ans += 12
		case "Icosahedron":
			ans += 20
		}
	}

	print("%d\n", ans)
}

package main

import "fmt"

func main() {
	var n int
	var num int = 0
	var str string
	fmt.Scan(&n)
	for i:=0; i<n; i++ {
		fmt.Scan(&str)
		if str == "Tetrahedron" {
			num = num + 4
		} else if str == "Cube" {
			num = num + 6
		} else if str == "Octahedron"{
			num = num + 7
		} else if str == "Dodecahedron" {
			num = num + 12
		} else if str == "Icosahedron" {
			num = num + 20
		}
	}
	fmt.Println(num)
}

package main

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

func main() {
	n := 0
	sum := 0
	fmt.Scanf("%d\n", &n)
	scanner := bufio.NewScanner(os.Stdin)
	for i := 0; i < n; i++ {
		scanner.Scan()
		str := scanner.Text()
		fmt.Println(str)
		if str == "Tetrahedron" {
			sum += 4
		} else if str == "Cube" {
			sum += 6
		} else if str == "Octahedron" {
			sum += 8
		} else if str == "Dodecahedron" {
			sum += 12
		} else {
			sum += 20
		}
	}

	fmt.Println(sum)
}

package main

import(
	"fmt"
)

func main() {
	n := 0
	sum := 0
	fmt.Scanf("%d\n", &n)

	for i := 0; i < n-1; i++ {
		str := ""
		fmt.Scanf("%s\n", &str)
		if str[0] == byte('T') {
			sum += 4
		} else if str[0] == byte('C') {
			sum += 6
		} else if str[0] == byte('O') {
			sum += 8
		} else if str[0] == byte('D') {
			sum += 12
		} else {
			sum += 20
		}
	}

	fmt.Println(sum)
}

package main

import (
	"fmt"
)

func main() {
	var n int
	var num int = 0
	var str string
	fmt.Scan(&n)
	for i:=0; i<n; i++ {
		fmt.Scan(&str)
		if str == "Tetrahedron" {
			num = num + 4
		} else if str == "Cube" {
			num = num + 6
		} else if str == "Octahedron"{
			num = num + 7
		} else if str == "Dodecahedron" {
			num = num + 12
		} else if str == "Icosahedron" {
			num = num + 20
		}
	}
	fmt.Println(num)
}


There are $$$n$$$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $$$[0, 3, 2, 3, 4]$$$, and the value is $$$0+3+2+3+4=12$$$.You are given the initial arrangement of people in the line. For each $$$k$$$ from $$$1$$$ to $$$n$$$, determine the maximum value of the line if you can change the direction of at most $$$k$$$ people.

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the length of the line. The following line contains a string consisting of $$$n$$$ characters, each of which is either L or R, representing a person facing left or right, respectively — the description of the line. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$. Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).

For each test case, output $$$n$$$ space-separated non-negative integers — the maximum value of the line if you can change the direction of at most $$$k$$$ people for each $$$k$$$ from $$$1$$$ to $$$n$$$, inclusive.

6

3

LLR

5

LRRLL

1

L

12

LRRRLLLRLLRL

10

LLLLLRRRRR

9

LRLRLRLRL

NoteIn the first test case:   $$$k=1$$$: change the direction of $$$1$$$ person to make the line RLR. The total value is $$$2+1+0=3$$$.  $$$k=2$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$.  $$$k=3$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. Note that you have to change the direction of at most $$$k$$$ people. In the second test case, it is optimal to only change the direction of the first person for all $$$k$$$ from $$$1$$$ to $$$5$$$ (that is, make the line RRRLL).

package main

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

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

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		var s []byte
		fmt.Fscan(in, &n, &s)

		aa := make([]int64, n)
		var tot int64
		for i := 0; i < n; i++ {
			if s[i] == 'L' {
				aa[i] = int64((n - i - 1) - i)
				tot += int64(i)
			} else {
				aa[i] = int64(i - (n - i - 1))
				tot += int64(n - i - 1)
			}
		}

		sort.Slice(aa, func(i, j int) bool { return aa[i] > aa[j] })
		for i := 0; i < n; i++ {
			if aa[i] > 0 {
				tot += aa[i]
			}
			fmt.Fprintf(out, "%d ", tot)
		}
		fmt.Fprintln(out)
	}
}

package main

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

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

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		var s []byte
		fmt.Fscan(in, &n, &s)

		aa := make([]int64, n)
		for i := 0; i < n; i++ {
			if s[i] == 'L' {
				aa[i]++
			} else {
				aa[n-i-1]++
			}
		}

		var tot int64
		for i := 0; i < n; i++ {
			tot += aa[i] * int64(i)
		}
		for i := 0; i < n; i++ {
			for aa[i] > 0 {
				tot += max(int64(n-1-i*2), 0)
				fmt.Fprintf(out, "%v ", tot)
				aa[i]--
			}
		}
		fmt.Fprintln(out)
	}
}

package main

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

var (
	in   *bufio.Reader = bufio.NewReader(os.Stdin)
	t, n int
	s    string
	ans  [1000000]int64
)

func main() {
	fmt.Fscan(in, &t)
	for t > 0 {
		fmt.Fscan(in, &n, &s)
		solve()
		t--
	}
	// solve()
}

func solve() {
	var start int64
	for i := range s {
		if s[i] == 'L' {
			start += int64(i)
		} else {
			start += int64(n - 1 - i)
		}
	}
	ans[0] = start
	var maxVal int64 = (int64(2*n-1-n/2)*int64(n/2)/2)*2 + int64(n%2*n/2)
	// fmt.Printf("start=%d, maxVal=%d\n", start, maxVal)
	for i := 1; i <= n; i++ {
		ans[i] = maxVal
	}
	l, r := 0, n-1
	k := 1
	for l < r && k <= n {
		if s[l] != 'R' {
			start = start - int64(l)
			start = start + int64(n-1-l)
			ans[k] = start
			k++
		}
		l++
		if l >= r || k > n {
			break
		}
		if s[r] != 'L' {
			start = start - int64(n-1-r)
			start = start + int64(r)
			ans[k] = start
			k++
		}
		r--
	}
	// 到此， ans[i]存储更改k次的最大值, 一次遍历改为至多修改k次的最大值
	for i := 1; i <= n; i++ {
		if ans[i] < ans[i-1] {
			ans[i] = ans[i-1]
		}
	}
	var buf bytes.Buffer
	for i := 1; i <= n; i++ {
		buf.WriteString(strconv.FormatInt(ans[i], 10))
		if i != n {
			buf.WriteByte(' ')
		}
	}
	fmt.Println(buf.String())
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		var s []byte
		fmt.Fscan(in, &n, &s)

		var x int64
		for i, ch := range s {
			if ch == 'L' {
				x += int64(i)
			} else {
				x += int64(n - i - 1)
			}
		}

		p1, p2 := 0, n-1
		bb := make([]int64, n)
		var idx int
		for p2 >= p1 {
			for s[p1] == 'R' && p1 < n-1 {
				p1++
			}
			for s[p2] == 'L' && p2 > 0 {
				p2--
			}

			if n-p1-1 >= p2 {
				x += int64(n - p1 - 1 - p1)
				s[p1] = 'R'
				p1++
			} else {
				x += int64(p2 - (n - p2 - 1))
				s[p2] = 'L'
				p2--
			}
			bb[idx] = x
			idx++
		}
		for i, v := range bb {
			if i >= idx {
				v = x
			}
			fmt.Fprintf(out, "%v ", v)
		}
		fmt.Fprintln(out)
	}
}


Bike loves looking for the second maximum element in the sequence. The second maximum element in the sequence of distinct numbers x1, x2, ..., xk (k > 1) is such maximum element xj, that the following inequality holds: .The lucky number of the sequence of distinct positive integers x1, x2, ..., xk (k > 1) is the number that is equal to the bitwise excluding OR of the maximum element of the sequence and the second maximum element of the sequence.You've got a sequence of distinct positive integers s1, s2, ..., sn (n > 1). Let's denote sequence sl, sl + 1, ..., sr as s[l..r] (1 ≤ l < r ≤ n). Your task is to find the maximum number among all lucky numbers of sequences s[l..r].Note that as all numbers in sequence s are distinct, all the given definitions make sence.

The first line contains integer n (1 < n ≤ 105). The second line contains n distinct integers s1, s2, ..., sn (1 ≤ si ≤ 109).

Print a single integer — the maximum lucky number among all lucky numbers of sequences s[l..r].

NoteFor the first sample you can choose s[4..5] = {4, 3} and its lucky number is (4 xor 3) = 7. You can also choose s[1..2].For the second sample you must choose s[2..5] = {8, 3, 5, 7}.

package main

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

var w *bufio.Writer

var sc *bufio.Scanner

const minus, zero byte = '-', '0'

func nextInt() int {
  var ans, fst int = 0, 0
  var neg bool = false
  sc.Scan()
  if sc.Bytes()[0] == minus {
    fst = 1
    neg = true
  }
  for _, j := range sc.Bytes()[fst:] {
    ans = ans*10 + int(j-zero)
  }
  if neg == true {
    ans = -ans
  }
  return ans
}

func main() {

  w = bufio.NewWriter(os.Stdout)
  sc = bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  n := nextInt()
  a, maxl, maxr, stack := make([]int, n),
    make([]int, n),
    make([]int, n),
    make([]int, n)
  var cur int = 0
  for i := 0; i < n; i++ {
    a[i] = nextInt()
    maxl[i], maxr[i] = -1, -1
  }
  for i := 0; i < n; i++ {
    for ; cur > 0 && a[stack[cur-1]] < a[i]; cur-- {
    }
    if cur > 0 {
      maxl[i] = stack[cur-1]
    } else {
      cur = 0
    }
    stack[cur] = i
    cur += 1
  }
  cur = 0
  for i := n - 1; i >= 0; i-- {
    for ; cur > 0 && a[stack[cur-1]] < a[i]; cur-- {
    }
    if cur > 0 {
      maxr[i] = stack[cur-1]
    } else {
      cur = 0
    }
    stack[cur] = i
    cur += 1
  }
  var ans int = 0
  for i := 0; i < n; i++ {
    if maxl[i] != -1 && a[i]^a[maxl[i]] > ans {
      ans = a[i] ^ a[maxl[i]]
    }
    if maxr[i] != -1 && a[i]^a[maxr[i]] > ans {
      ans = a[i] ^ a[maxr[i]]
    }
  }
  w.WriteString(strconv.Itoa(ans))
  w.Flush()
}