package main

import (
	"fmt"
	"strings"
	"unicode/utf8"
)

func main() {
	var n int
	var s string

	fmt.Scan(&n, &s)

	r := strings.Count(s, "R")
	g := strings.Count(s, "G")
	b := strings.Count(s, "B")
	lenS := utf8.RuneCountInString(s)

	var exclude int
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			k := j + j - i
			if k >= lenS {
				continue
			}
			if s[i] != s[j] && s[i] != s[k] && s[j] != s[k] {
				exclude++
			}
		}
	}

	fmt.Println(r*g*b - exclude)
}


package main

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

var DEBUG = true

func main() {
	defer Flush()

	N := readi()
	S := readb()

	var R, G, B int

	for _, c := range S {
		if c == 'R' {
			R++
		} else if c == 'G' {
			G++
		} else {
			B++
		}
	}

	ans := R * G * B
	for j := 1; j < N-1; j++ {
		for i := j - 1; 0 <= i; i-- {
			k := j + j - i
			if N <= k {
				break
			}
			if S[i] != S[j] && S[j] != S[k] && S[k] != S[i] && j-i == k-j {
				ans--
			}
		}
	}
	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)
}

Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.

Score : 400 points

Problem Statement

We have a string S of length N consisting of R, G, and B.

Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions:

S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k.

j - i \neq k - j.

Constraints

1 \leq N \leq 4000

S is a string of length N consisting of R, G, and B.

Input

Input is given from Standard Input in the following format:

N
S

Output

Print the number of triplets in question.

Sample Input 1

4
RRGB

Sample Output 1

1

Only the triplet (1,~3,~4) satisfies both conditions. The triplet (2,~3,~4) satisfies the first condition but not the second, so it does not count.

Sample Input 2

39
RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB

Sample Output 2

1800

Submitted source-code file size, in bytes.

Execution CPU time reported by official Project CodeNet metadata, in milliseconds.

Peak memory usage reported by official Project CodeNet metadata, in kilobytes.


package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)
	rgb := strings.Split(s, "")
	var r, g, b []int
	ans := 0
	var max, min, div int

	for i := 0; i < n; i++ {
		if rgb[i] == "R" {
			r = append(r, i)
		} else if rgb[i] == "G" {
			g = append(g, i)
		} else {
			b = append(b, i)
		}
	}
	for i := range r {
		for j := range g {
			ans = ans + len(b)
			if r[i]-g[j] < 0 {
				max = g[j]
				min = r[i]
			} else {
				max = r[i]
				min = g[j]
			}
			div = max - min
			//			fmt.Println(max, min, div)
			if div%2 == 0 {
				if rgb[min+div/2] == "B" {
					ans--
				}
			}
			if min-div >= 0 {
				if rgb[min-div] == "B" {
					ans--
				}
			}
			if max+div <= n-1 {
				if rgb[max+div] == "B" {
					ans--
				}
			}
		}
	}

	//	for i := range r {
	//		for j := range g {
	//			for k := range b {
	//				tmp := []int{r[i], g[j], b[k]}
	//				sort.Sort(sort.IntSlice(tmp))
	//				if tmp[1]-tmp[0] != tmp[2]-tmp[1] {
	//					ans++
	//				}
	//			}
	//		}
	//	}
	//	fmt.Println("r", r)
	//	fmt.Println("g", g)
	//	fmt.Println("b", b)
	//	fmt.Println("rgb", rgb)
	fmt.Println(ans)
}


package main

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

var sc = bufio.NewScanner(os.Stdin)

type rgb struct {
	R, G, B int
}

func nextInt() int {
	n, _ := strconv.Atoi(nextString())
	return n
}

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

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	S := nextString()

	rc := 0
	gc := 0
	bc := 0

	for _, s := range S {
		if s == 'R' {
			rc++
		} else if s == 'G' {
			gc++
		} else {
			bc++
		}
	}

	sum := rc * gc * bc

	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			k := j + (j - i)
			if k < N {
				str := []byte{S[i], S[j], S[k]}
				if isRGB(string(str)) {
					sum--
				}
			}
		}
	}
	fmt.Println(sum)
}

func isRGB(subString string) bool {
	switch subString {
	case "RGB":
		return true
	case "RBG":
		return true
	case "GRB":
		return true
	case "GBR":
		return true
	case "BRG":
		return true
	case "BGR":
		return true
	default:
		return false
	}
}


package main

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

var s [10000]byte
var N int

var rmap map[int]int
var gmap map[int]int
var bmap map[int]int

func main() {
	io := NewIo()
	defer io.Flush()

	rmap = make(map[int]int)
	gmap = make(map[int]int)
	bmap = make(map[int]int)
	// AUTOGENERATE

	// STR := io.Next()
	// Log("string", STR)

	// F := io.NextFloat()
	// Log("float", F)

	// parsing int array
	N = io.NextInt()
	Logf("%v\n", N)
	// M := io.NextInt()
	// Logf("%v\n", M)
	// var A [200000]int
	// for i := 0 ; i < N; i++ {
	// 	A[i] = io.NextInt()
	// }
	// Logf("A %v\n", A[0:10])
	// sort.Sort(sort.Reverse(sort.IntSlice(A[:])))
	// sort.Sort(sort.IntSlice(A[:]))

	// parsing string as byte array
	str := io.Next()
	var rl, gl, bl [4000]int
	rc := 0
	gc := 0
	bc := 0

	for i := -N; i < len(str)*2; i++ {
		bmap[i] = -1
	}
	for i := 0; i < len(str); i++ {
		s[i] = str[i]
		if int(s[i]) == 82 {
			rl[rc] = i
			rmap[i] = rc
			rc++
		} else if int(s[i]) == 71 {
			gl[gc] = i
			gmap[i] = gc
			gc++
		} else if int(s[i]) == 66 {
			bl[bc] = i
			bmap[i] = bc
			bc++
		}
	}
	Log("byte array", s[0:10])
	Log("r", rl[0:rc])
	Log("g", gl[0:gc])
	Log("b", bl[0:bc])
	Log("r", rmap)
	Log("g", gmap)
	Log("b", bmap)
	Log("count", rc*gc*bc)
	count := 0
	count = rc * gc * bc
	for _, rii := range rl[0:rc] {
		for _, gii := range gl[0:gc] {
			// if rii > gii {
			// 	if _, ok := bmap[rii+rii-gii]; ok {
			// 		count--
			// 	}
			// 	if _, ok := bmap[gii-(rii-gii)]; ok {
			// 		count--
			// 	}
			// } else {
			// 	if _, ok := bmap[gii+gii-rii]; ok {
			// 		count--
			// 	}
			// 	if _, ok := bmap[rii-(gii-rii)]; ok {
			// 		count--
			// 	}
			// }
			// Logf("0 %4v %4v %5v %5v %5v %5v\n", rii, gii, bmap[2*gii-rii], bmap[2*rii-gii], bmap[(rii+gii)/2], count)
			// if _, ok := bmap[2*rii-gii]; 2*rii-gii > 0 && ok {
			if bmap[2*rii-gii] != -1 {
				// Logf("0 %v %v %v %v\n", rii, gii, gii, count)
				count--
			}
			// if _, ok := bmap[2*gii-rii]; 2*gii-rii > 0 && ok {
			if bmap[2*gii-rii] != -1 {
				// Logf("1 %v %v %v %v\n", rii, gii, gii, count)
				count--
			}
			// if _, ok := bmap[(rii+gii)/2]; ok {
			if ((rii+gii)%2 == 0) && bmap[(rii+gii)/2] != -1 {
				// Logf("2 %v %v %v %v\n", rii, gii, gii, count)
				count--
			}
			continue
			for _, bii := range bl[0:bc] {
				// Logf("0 %v %v %v %v\n", rii, gii, bii, count)

				continue
				if rii < gii {
					if gii < bii { // r g b
						if bii-gii != gii-rii {
							count++
							// } else {
							// Logf("1 %v %v %v\n", rii, gii, bii)
						}
					} else if rii < bii { // r b g
						if gii-bii != bii-rii {
							count++
							// } else {
							// 	Logf("2 %v %v %v\n", rii, gii, bii)
						}
					} else { // b r g
						if gii-rii != rii-bii {
							count++
							// } else {
							// 	Logf("3 %v %v %v\n", rii, gii, bii)
						}
					}
				} else { // g r
					if rii < bii { // g r b
						if bii-rii != rii-gii {
							count++
							// } else {
							// 	Logf("4 %v %v %v\n", rii, gii, bii)
						}
					} else if gii < bii { // g b r
						if rii-bii != bii-gii {
							count++
							// } else {
							// 	Logf("5 %v %v %v\n", rii, gii, bii)
						}
					} else { // b g r
						if rii-gii != gii-bii {
							count++
							// } else {
							// 	Logf("6 %v %v %v\n", rii, gii, bii)
						}
					}
				}
			}
		}
	}

	// for i := 0; i < N-2; i++ {
	// 	if int(s[i]) == 82 {
	// 		for gi := 0 ; gi < gc; gi++ {
	// 		}
	// 		rl[rc] = i
	// 		rc++
	// 	} else if int(s[i]) == 71 {
	// 		gl[gc] = i
	// 		gc++
	// 	} else if int(s[i]) == 66 {
	// 		bl[bc] = i
	// 		bc++
	// 	}
	// 	count += part(i)
	// 	Logf("%v\n", count)
	// }

	// count := 0
	// for i := N - 1 - 2; i >= 0; i-- {
	// 	count += part(i)
	// 	Logf("%v\n", count)
	// }
	fmt.Printf("%v\n", count)
	// fmt.Printf("%d %d %d\n", N, M, intMax(N, M))
	// fmt.Printf("Lucas %d %d\n", combMod(N, M, 13), combination(N, M))

	// write your own code here

}

func part(i int) int {
	count := 0
	for j := i + 1; j < N; j++ {
		if s[i] == s[j] {
			continue
		}
		for k := j + 1; k < N; k++ {
			if (k - j) == (j - i) {
				continue
			}
			if s[i] == s[k] || s[j] == s[k] {
				continue
			}
			count++
		}
	}
	return count
}

// Libraries

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo
func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

// Flush
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

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

// NextInt
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// NextFloat
func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

// PrintLn
func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

// Printf
func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

// PrintIntLn
func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

// PrintStringLn
func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

// Log
func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

// Log format for standard error output
func Logf(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

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

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

// direct calculation of combination
// n, m should be "small"
func combination(n, m int) int {
	if m > n {
		return 0
	} else if m == n || m == 0 {
		return 1
	} else {
		res := 1
		for i := 0; i < m; i++ {
			res *= (n - i)
		}
		for i := 1; i <= m; i++ {
			res /= i
		}
		return res
	}
}

// caluclate combination modulo based on Lucas theorem
func lucas(n, m, p int) int {
	ntemp := n
	mtemp := m
	res := 1
	for i := 0; i < 100; i++ {
		// fmt.Printf("ntemp: %d\n", ntemp)
		nreminder := ntemp % p
		ntemp = ntemp / p
		mreminder := mtemp % p
		mtemp = mtemp / p
		res = res * (combination(nreminder, mreminder) % p)
		if ntemp == 0 {
			break
		}
	}
	return res % p
}

func combMod(n, m, p int) int {
	return lucas(n, m, p)
}

// BFS/DFS
//
// visited := []int{}
// dfs(1, neighbor, func(node int) {
// 	visited = append(visited, node)
// })
// fmt.Println(visited)

func bfs(start int, nodes map[int][]int, fn func(int)) {
	frontier := []int{start}
	visited := map[int]bool{}
	next := []int{}

	for 0 < len(frontier) {
		next = []int{}
		for _, node := range frontier {
			visited[node] = true
			fn(node)
			for _, n := range bfs_frontier(node, nodes, visited) {
				next = append(next, n)
			}
		}
		frontier = next
	}
}

func bfs_frontier(node int, nodes map[int][]int, visited map[int]bool) []int {
	next := []int{}
	iter := func(n int) bool { _, ok := visited[n]; return !ok }
	for _, n := range nodes[node] {
		if iter(n) {
			next = append(next, n)
		}
	}
	return next
}

func dfs(node int, nodes map[int][]int, fn func(int)) {
	dfs_recur(node, nodes, map[int]bool{}, fn)
}

func dfs_recur(node int, nodes map[int][]int, v map[int]bool, fn func(int)) {
	v[node] = true
	fn(node)
	for _, n := range nodes[node] {
		if _, ok := v[n]; !ok {
			dfs_recur(n, nodes, v, fn)
		}
	}
}

// handles 2 function, one is before entering child tree, and another is
// after entering child tree.
func dfs2(node int, nodes map[int][]int, fn1, fn2 func(int, int)) {
	dfs2_recur(node, -1, nodes, map[int]bool{}, fn1, fn2)
}

func dfs2_recur(node, parent int, nodes map[int][]int, v map[int]bool, fn1, fn2 func(int, int)) {
	v[node] = true
	fn1(node, parent)
	for _, n := range nodes[node] {
		if _, ok := v[n]; !ok {
			dfs2_recur(n, node, nodes, v, fn1, fn2)
		}
	}
	fn2(node, parent)
}

// Stack data structure
type Stack struct {
	top  *Element
	size int
}

type Element struct {
	value interface{}
	next  *Element
}

func (s *Stack) Len() int {
	return s.size
}

func (s *Stack) Push(value interface{}) {
	s.top = &Element{value, s.top}
	s.size++
}

func (s *Stack) Pop() (value interface{}) {
	if s.size > 0 {
		value, s.top = s.top.value, s.top.next
		s.size--
		return
	}
	return nil
}

// powerInt (use math.Pow() for float parameters)
func powerInt(n, p int) int {
	tmp := 1
	for i := 0; i < n; i++ {
		tmp *= p
	}
	return tmp
}

func findDivisors(n int, a *[]int) {
	if n == 1 {
		return
	}

	sqrt := int(math.Sqrt(float64(n)))
	for i := 2; i <= sqrt; i++ {
		if n%i == 0 {
			*a = append(*a, i)
			*a = append(*a, n/i)
		}
	}
	*a = append(*a, n)
}

func removeDuplicate(a []int) []int {
	m := make(map[int]bool)
	for i := 0; i < len(a); i++ {
		m[a[i]] = true
	}
	res := []int{}
	for i, _ := range m {
		res = append(res, i)
	}
	return res
}


package main

import "fmt"

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

	cs := make(map[byte][]int)
	cs['R'] = make([]int, n+1)
	cs['G'] = make([]int, n+1)
	cs['B'] = make([]int, n+1)
	for i := 0; i < n; i++ {
		c := s[i]

		cs['R'][i+1] = cs['R'][i]
		cs['G'][i+1] = cs['G'][i]
		cs['B'][i+1] = cs['B'][i]

		cs[c][i+1]++
	}

	ans := 0
	for i := 0; i < n-2; i++ {
		rgb := map[byte]int{'R': 0, 'G': 0, 'B': 0}
		rgb[s[i]]++
		for j := i + 1; j < n; j++ {
			if s[i] == s[j] {
				continue
			}
			rgb[s[j]]++

			t := byte('@')
			if rgb['R'] == 0 {
				t = 'R'
			} else if rgb['G'] == 0 {
				t = 'G'
			} else {
				t = 'B'
			}

			cc := cs[t]
			cnt := cc[n] - cc[j]
			d := j - i
			if j+d < n {
				if s[j+d] == t {
					cnt--
				}
			}
			ans += cnt

			rgb[s[j]]--
		}
		rgb[s[i]]--
	}

	fmt.Println(ans)
}


package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)
	fmt.Println(Calc(s))
}

func Calc(s string) int {
	var sum int
	n := len(s)
	for i := 0; i <= n-3; i++ {
		for j := i + 1; j <= n-2; j++ {
			for k := j + 1; k <= n-1; k++ {
				if s[i] != s[j] && s[i] != s[k] && s[j] != s[k] && j-i != k-j {
					sum++
				}
			}
		}
	}
	return sum
}


package main

import "fmt"

type key struct {
	To    int
	Color rune
}

func color3(c1, c2 rune) rune {
	if c1 == 'R' && c2 == 'G' {
		return 'B'
	}
	if c1 == 'R' && c2 == 'B' {
		return 'G'
	}
	if c1 == 'G' && c2 == 'B' {
		return 'R'
	}
	if c1 == 'G' && c2 == 'R' {
		return 'B'
	}
	if c1 == 'B' && c2 == 'R' {
		return 'G'
	}
	if c1 == 'B' && c2 == 'G' {
		return 'R'
	}
	return ' '
}

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

	count := make(map[key]int)
	for i, c := range s {
		if c == 'R' {
			count[key{i, 'R'}] = count[key{i - 1, 'R'}] + 1
			count[key{i, 'G'}] = count[key{i - 1, 'G'}]
			count[key{i, 'B'}] = count[key{i - 1, 'B'}]
		} else if c == 'G' {
			count[key{i, 'R'}] = count[key{i - 1, 'R'}]
			count[key{i, 'G'}] = count[key{i - 1, 'G'}] + 1
			count[key{i, 'B'}] = count[key{i - 1, 'B'}]
		} else {
			count[key{i, 'R'}] = count[key{i - 1, 'R'}]
			count[key{i, 'G'}] = count[key{i - 1, 'G'}]
			count[key{i, 'B'}] = count[key{i - 1, 'B'}] + 1
		}
	}

	sum := 0
	for i := 0; i <= n-3; i++ {
		ci := s[i]
		for j := i; j <= n-2; j++ {
			cj := s[j]
			if ci == cj {
				continue
			}
			ck := color3(rune(ci), rune(cj))
			cnt := count[key{len(s) - 1, ck}] - count[key{j, ck}]
			diff := j - i
			if j+diff <= n-1 && rune(s[j+diff]) == ck {
				cnt--
			}
			sum += cnt
		}
	}
	fmt.Println(sum)
}


package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

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

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

func solve(N int, s []byte) {
	ans := 0
	for i := N - 1; i >= 0; i-- {
		for j := N - 1; j > i; j-- {
			if s[i] == s[j] {
				continue
			}
			for k := N - 1; k > j; k-- {
				if s[i] == s[k] || s[j] == s[k] {
					continue
				}
				if j-i != k-j {
					ans++
				}
			}
		}
	}
	out(ans)
}

func solve2(N int, s []byte) {
	ans := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			if s[i] == s[j] {
				continue
			}
			for k := j + 1; k < N; k++ {
				if s[i] == s[k] || s[j] == s[k] {
					continue
				}
				if j-i != k-j {
					ans++
				}
			}
		}
	}
	out(ans)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	N := getInt()
	s := getString()

	// N := 4000
	// s := make([]byte, N)
	// for i := 0; i < N; i++ {
	// 	switch i % 3 {
	// 	case 0:
	// 		s[i] = 'R'
	// 	case 1:
	// 		s[i] = 'G'
	// 	case 2:
	// 		s[i] = 'B'
	// 	}
	// }

	solve(N, []byte(s))

}


package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

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

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	l := scanInt()
	s := scanString()
	cnt := 0
	for i := 0; i < l; i++ {
		for j := i + 1; j < l; j++ {
			if s[i] == s[j] {
				continue
			}
			k := strings.Replace("RGB", string(s[i]), "", 1)
			k = strings.Replace(k, string(s[j]), "", 1)
			cnt += strings.Count(s[j+1:], k)
			if (2*j-i) <= (l-1) && k == string(s[2*j-i]) {
				cnt--
			}
		}
	}
	fmt.Println(cnt)
}


package main

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

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*
ASCII code

ASCII   10進数  ASCII   10進数  ASCII   10進数
!       33      "       34      #       35
$       36      %       37      &       38
'       39      (       40      )       41
*       42      +       43      ,       44
-       45      .       46      /       47
0       48      1       49      2       50
3       51      4       52      5       53
6       54      7       55      8       56
9       57      :       58      ;       59
<       60      =       61      >       62
?       63      @       64      A       65
B       66      C       67      D       68
E       69      F       70      G       71
H       72      I       73      J       74
K       75      L       76      M       77
N       78      O       79      P       80
Q       81      R       82      S       83
T       84      U       85      V       86
W       87      X       88      Y       89
Z       90      [       91      \       92
]       93      ^       94      _       95
`       96      a       97      b       98
c       99      d       100     e       101
f       102     g       103     h       104
i       105     j       106     k       107
l       108     m       109     n       110
o       111     p       112     q       113
r       114     s       115     t       116
u       117     v       118     w       119
x       120     y       121     z       122
{       123     |       124     }       125
~       126             127
*/

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

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	n int
	S []rune

	R, G, B    []int
	RS, GS, BS []int
)

func main() {
	n = ReadInt()
	S = ReadRuneSlice()
	R, G, B = make([]int, n+1), make([]int, n+1), make([]int, n+1)
	RS, GS, BS = make([]int, n+1), make([]int, n+1), make([]int, n+1)

	if n <= 3 {
		fmt.Println(0)
		return
	}

	for i := 0; i < n; i++ {
		if S[i] == 'R' {
			R[i]++
		} else if S[i] == 'G' {
			G[i]++
		} else {
			B[i]++
		}
	}

	for i := 0; i < n; i++ {
		RS[i+1] = RS[i] + R[i]
		GS[i+1] = GS[i] + G[i]
		BS[i+1] = BS[i] + B[i]
	}

	ans := 0
	for i := 0; i < n; i++ {
		if S[i] == 'R' {
			befG, aftB := GS[i], BS[n]-BS[i+1]
			befB, aftG := BS[i], GS[n]-GS[i+1]
			sum := befG*aftB + befB*aftG

			for j := 1; ; j++ {
				if i-j < 0 || i+j >= n {
					break
				}

				before, after := S[i-j], S[i+j]
				if (before == 'G' && after == 'B') || (before == 'B' && after == 'G') {
					sum--
				}
			}

			ans += sum
		} else if S[i] == 'G' {
			befR, aftB := RS[i], BS[n]-BS[i+1]
			befB, aftR := BS[i], RS[n]-RS[i+1]
			sum := befR*aftB + befB*aftR

			for j := 1; ; j++ {
				if i-j < 0 || i+j >= n {
					break
				}

				before, after := S[i-j], S[i+j]
				if (before == 'R' && after == 'B') || (before == 'B' && after == 'R') {
					sum--
				}
			}

			ans += sum
		} else {
			// 'B'
			befR, aftG := RS[i], GS[n]-GS[i+1]
			befG, aftR := GS[i], RS[n]-RS[i+1]
			sum := befR*aftG + befG*aftR

			for j := 1; ; j++ {
				if i-j < 0 || i+j >= n {
					break
				}

				before, after := S[i-j], S[i+j]
				if (before == 'R' && after == 'G') || (before == 'G' && after == 'R') {
					sum--
				}
			}

			ans += sum
		}
	}

	fmt.Println(ans)
}

/*
- まずは全探索を検討しましょう
- MODは最後にとりましたか？
- 負のMODはちゃんと関数を使って処理していますか？
- ループを抜けた後も処理が必要じゃありませんか？
- 和・積・あまりを求められたらint64が必要ではありませんか？
- いきなりオーバーフローはしていませんか？
- MOD取る系はint64必須ですよ？
- 後ろ・逆・ゴールから考えましたか？
- 3者のうち真ん中に着目しましたか？
*/

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


package main

import "fmt"

func main() {
	var N int
	var S string

	fmt.Scan(&N, &S)
	R := make(map[int]struct{})
	G := make(map[int]struct{})
	B := make(map[int]struct{})

	for idx, c := range S {
		if c == 'R' {
			R[idx] = struct{}{}
		} else if c == 'G' {
			G[idx] = struct{}{}
		} else {
			B[idx] = struct{}{}
		}
	}

	ans := 0
	for r, _ := range R {
		for g, _ := range G {
			for b, _ := range B {
				i, j, k := po(r, g, b)
				if j-i != k-j {
					ans++
				}
			}
		}
	}
	fmt.Println(ans)
}

func po(a, b, c int) (i, j, k int) {
	if a < b && a < c {
		i = a
		if b < c {
			j = b
			k = c
		} else {
			j = c
			k = b
		}
	} else if b < a && b < c {
		i = b
		if a < c {
			j = a
			k = c
		} else {
			j = c
			k = a
		}
	} else {
		i = c
		if a < b {
			j = a
			k = b
		} else {
			j = b
			k = a
		}
	}
	return
}


package main

import (
	"fmt"
)

func main() {
	var x, y, z int
	_, _ = fmt.Scanf("%d %d %d", &x, &y, &z)

	fmt.Println(answer161A(x, y, z))
}

func answer161A(x int, y int, z int) string {
	return fmt.Sprintf("%d %d %d", z, x, y)
}

Score : 100 points

Problem Statement

We have three boxes A, B, and C, each of which contains an integer.

Currently, the boxes A, B, and C contain the integers X, Y, and Z, respectively.

We will now do the operations below in order. Find the content of each box afterward.

Swap the contents of the boxes A and B

Swap the contents of the boxes A and C

Constraints

1 \leq X,Y,Z \leq 100

All values in input are integers.

Input

Input is given from Standard Input in the following format:

X Y Z

Output

Print the integers contained in the boxes A, B, and C, in this order, with space in between.

Sample Input 1

1 2 3

Sample Output 1

3 1 2

After the contents of the boxes A and B are swapped, A, B, and C contain 2, 1, and 3, respectively.

Then, after the contents of A and C are swapped, A, B, and C contain 3, 1, and 2, respectively.

Sample Input 2

100 100 100

Sample Output 2

100 100 100

Sample Input 3

41 59 31

Sample Output 3

31 41 59


package main

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

/* sort */
type pair struct {
	index  int64
	p1, p2 interface{}
}
type pairs []pair

func (slice pairs) Len() int {
	return len(slice)
}

func (slice pairs) Less(i, j int) bool {
	return slice[i].index < slice[j].index
}

func (slice pairs) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}

/* sort */
type Int64Slice []int64

func (slice Int64Slice) Len() int {
	return len(slice)
}

func (slice Int64Slice) Less(i, j int) bool {
	return slice[i] < slice[j]
}

func (slice Int64Slice) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}
func Int64s(a []int64)                    { sort.Sort(Int64Slice(a)) }
func Int64sSliceAreSorted(a []int64) bool { return sort.IsSorted(Int64Slice(a)) }

const (
	initialBufSize = 1e4
	maxBufSize     = 1e8
	INF            = 1e8
)

var (
	scanner = bufio.NewScanner(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
	di      = []int64{-1, 0, 1, 0}
	dj      = []int64{0, -1, 0, 1}
	di8     = []int64{-1, -1, 0, 1, 1, 1, 0, -1}
	dj8     = []int64{0, -1, -1, -1, 0, 1, 1, 1}
)

func main() {
	buf := make([]byte, initialBufSize)
	scanner.Buffer(buf, maxBufSize)
	scanner.Split(bufio.ScanWords)
	X, Y, Z := readInt(), readInt(), readInt()
	fmt.Println(Z, X, Y)
}

/*==========================================
 *             Library
 *==========================================*/
func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}
func doubleAry(h int64, w int64, init int64) (res [][]int64) {
	res = make([][]int64, h)
	for i := int64(0); i < h; i++ {
		res[i] = make([]int64, w)
		for j := int64(0); j < w; j++ {
			res[i][j] = init
		}
	}
	return
}

func aryEq(a []int64, b []int64) bool {
	return reflect.DeepEqual(a, b)
}

func clone(n []int64) (r []int64) {
	r = make([]int64, len(n))
	for i := 0; i < len(n); i++ {
		r[i] = n[i]
	}
	return
}
func write(s string) {
	writer.WriteString(s)
}

func print() {
	writer.Flush()
}

// scanner.Split(bufio.ScanWords) をコメントアウトしないと使用不可
func readLine() (s string) {
	if scanner.Scan() {
		s = scanner.Text()
	}
	return s
}

func readInt() (read int64) {
	scanner.Scan()
	read, err := strconv.ParseInt(scanner.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return
}

func readFloat() (read float64) {
	scanner.Scan()
	read, err := strconv.ParseFloat(scanner.Text(), 64)
	if err != nil {
		panic(err)
	}
	return
}

func readRunes() (read []rune) {
	scanner.Scan()
	for _, v := range scanner.Text() {
		read = append(read, v)
	}
	return
}

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

func readStrings() (read []string) {
	scanner.Scan()
	for _, v := range scanner.Text() {
		read = append(read, string(v))
	}
	return
}

func s2i(s string) int64 {
	var intVal, e = strconv.ParseInt(s, 10, 64)
	if e != nil {
		panic(e)
	}
	return intVal
}

func i2s(i int64) string {
	var strVal = strconv.FormatInt(i, 10)
	return strVal
}

func s2f(s string) float64 {
	var floatVal, e = strconv.ParseFloat(s, 64)
	if e != nil {
		panic(e)
	}
	return floatVal
}

func abs(i int64) int64 {
	return int64(math.Abs(float64(i)))
}

func max(a ...int64) int64 {
	ans := int64(0)
	for i, v := range a {
		if i == 0 {
			ans = v
		}
		if ans < v {
			ans = v
		}
	}
	return ans
}
func min(a ...int64) int64 {
	ans := int64(0)
	for i, v := range a {
		if i == 0 {
			ans = v
		}
		if ans > v {
			ans = v
		}
	}
	return ans
}

func sum(i []int64) int64 {
	sum := int64(0)
	for _, val := range i {
		sum += val
	}
	return sum
}

func split(s string) []string {
	return strings.Fields(s)
}

func strAry2intAry(strs []string) []int64 {
	var ret = make([]int64, 0, len(strs))
	for _, str := range strs {
		var intVal = s2i(str)
		ret = append(ret, intVal)
	}
	return ret
}

func intAry2strAry(nums []int64) []string {
	var ret = make([]string, 0, len(nums))
	for _, num := range nums {
		var strVal = i2s(num)
		ret = append(ret, strVal)
	}
	return ret
}

func ary2str(strs []string) string {
	return strings.Join(strs, " ")
}

func reverse(res []int64) []int64 {
	for i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 {
		res[i], res[j] = res[j], res[i]
	}
	return res
}
func reverseStr(res []string) []string {
	for i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 {
		res[i], res[j] = res[j], res[i]
	}
	return res
}

func ini(res []int, init int) {
	if len(res) == 0 {
		return
	}
	res[0] = init
	for i := 0; i < len(res); i++ {
		copy(res[i:], res[:i])
	}
}

//
// func regexpExample() {
//     // Your code here!
//     var str = "13:20"
//     r := regexp.MustCompile(`(\d+):(\d+)`)
//     fmt.Println(r.FindStringSubmatch(str))
// }

// type Country struct {
//     gold int
//     silver int
//     blonze int
// }

// // 複数ソートのサンプル
// func stableSortExample() []Country{
//     var country = []Country {
//         {gold:1, silver:2, blonze:3},
//         {gold:1, silver:2, blonze:3},
//         {gold:1, silver:3, blonze:2},
//         {gold:1, silver:3, blonze:3},
//     }
//     sort.SliceStable(country, func(i, j int) bool { return country[i].blonze > country[j].blonze })
//     sort.SliceStable(country, func(i, j int) bool { return country[i].silver > country[j].silver })
//     sort.SliceStable(country, func(i, j int) bool { return country[i].gold > country[j].gold })
//     return country
// }


package main

import "fmt"

func main() {
	var x, y, z string
	// &はアドレス
	fmt.Scan(&x, &y, &z)

	fmt.Println(z + x + y)
}


package main

import (
	"fmt"
)

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

	fmt.Scan(&a, &b, &c)

	aa := a
	a = b
	b = aa
	aaa := a
	a = c
	c = aaa

	fmt.Println(a, b, c)

}


package main

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

func main() {

	nextReader = newScanner()

	x, y, z := nextInt(), nextInt(), nextInt()

	fmt.Println(z, x, y)
}

/* --------------------------------------------------------------------------
 *  std.io
 * ------------------------------------------------------------------------- */
var nextReader func() string

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

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

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 mins(t ...int) int {
	if len(t) == 0 {
		return 0
	}

	min := t[0]
	for i := 1; i < len(t); i++ {
		if min > t[i] {
			min = t[i]
		}
	}
	return min
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return 0 - a
	}
}


package main

import (
	"fmt"
)

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

func swap(x *int, y *int) {
	var tmp int

	tmp = *x
	*x = *y
	*y = tmp
}


package main

import (
	"fmt"
)

func main() {
	var x int
	var y int
	var z int
	fmt.Scan(&x)
	fmt.Scan(&y)
	fmt.Scan(&z)

	fmt.Println(z, x, y)
}


package main

import (
	"fmt"
)

func main() {
	var x, y, z int
	fmt.Scan(&x, &y, &z)

	s := x

	x = y
	y = s

	s = x
	x = z
	z = s

	fmt.Println(x, y, z)
}


//problem_a.go

package main

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

const (
	constMod = int(1e9) + 7
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

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

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

func getIntSlice(n int) []int {
	ns := []int{}
	for i := 0; i < n; i++ {
		ns = append(ns, getInt())
	}
	return ns
}

func getIntDoubleSlice(m int, n int) [][]int {
	var nds [][]int
	for i := 0; i < m; i++ {
		ns := getIntSlice(n)
		nds = append(nds, ns)
	}

	return nds
}

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

func getStringSlice(n int) []string {
	ss := []string{}
	for i := 0; i < n; i++ {
		ss = append(ss, getString())
	}
	return ss
}

func getStringDoubleSlice(m int, n int) [][]string {
	sds := [][]string{}
	for i := 0; i < m; i++ {
		ss := getStringSlice(n)
		sds = append(sds, ss)
	}

	return sds

}

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

// Sort Fanction

func sortIntSlice(ns []int) []int {
	sort.Sort(sort.IntSlice(ns))
	return ns
}

func sortIntReverseSlice(ns []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(ns)))
	return ns
}

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

// Num Fanction

//numAbs(x) = abs(s)
func numAbs(x int) int {
	if x < 0 {
		return -x
	}

	return x
}

//numModPow(a, n, m) = a^n % m
func numModPow(a int, n int, m int) int {
	result := 1

	for n > 0 {
		if n%2 == 1 {
			result = (result * a) % m
		}

		a = (a * a) % m
		n >>= 1
	}

	return result
}

// numGcd(a, b) = gcd(a, b)
func numGcd(a int, b int) int {
	if b == 0 {
		return a
	}

	return numGcd(b, a%b)
}

// numLcm(a, b) = lcm(a, b)
func numLcm(a int, b int) int {
	return a * b / numGcd(a, b)
}

// numModInv(a, p) = a^(-1) % p
func numModInv(a int, p int) int {
	if a == 1 {
		return 1
	}

	return p - numModInv(p%a, p)*(p/a)%p
}

// numModFrac(n) = n! % constMod
func numModFrac(n int) []int {
	frac := []int{1}

	for i := 1; i <= n; i++ {
		frac = append(frac, i*frac[i-1]%constMod)
	}

	return frac
}

// numModConb(n, r) = nCr % constMod
func numModConb(n int, r int) int {
	frac := numModFrac(n)

	return (frac[n] / ((frac[n-r] * frac[r]) % constMod)) % constMod
}

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

func solve() {

	x, y, z := getInt(), getInt(), getInt()
	fmt.Fprintln(wr, z, x, y)

}

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

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}


package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

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

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

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	A, B, C := getInt(), getInt(), getInt()
	A, B = B, A
	A, C = C, A
	out(A, B, C)
}


package main

import (
	"fmt"
	"sort"
)

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

	A := make([]int, N)

	var all int
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &A[i])
		all = all + A[i]
	}

	sort.Sort(sort.Reverse(sort.IntSlice(A)))
	var count int
	for i := 0; i < N; i++ {
		if A[i]*4*M >= all {
			count++
		} else {
			break
		}
	}

	if count >= M {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Score : 200 points

Problem Statement

We have held a popularity poll for N items on sale. Item i received A_i votes.

From these N items, we will select M as popular items. However, we cannot select an item with less than \dfrac{1}{4M} of the total number of votes.

If M popular items can be selected, print Yes; otherwise, print No.

Constraints

1 \leq M \leq N \leq 100

1 \leq A_i \leq 1000

A_i are distinct.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
A_1 ... A_N

Output

If M popular items can be selected, print Yes; otherwise, print No.

Sample Input 1

4 1
5 4 2 1

Sample Output 1

Yes

There were 12 votes in total. The most popular item received 5 votes, and we can select it.

Sample Input 2

3 2
380 19 1

Sample Output 2

No

There were 400 votes in total. The second and third most popular items received less than \dfrac{1}{4\times 2} of the total number of votes, so we cannot select them. Thus, we cannot select two popular items.

Sample Input 3

12 3
4 56 78 901 2 345 67 890 123 45 6 789

Sample Output 3

Yes


package main

import (
	"fmt"
	"sort"
)

func sliceUnique(target []int) (unique []int) {
	m := map[int]bool{}

	for _, v := range target {
		if !m[v] {
			m[v] = true
			unique = append(unique, v)
		}
	}

	return unique
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	if m > n {
		return
	}
	points := make([]int, n)
	sum := 0

	for i:=0; i<n; i++{
		fmt.Scan(&points[i])
		sum += points[i]
	}

	sort.Sort(sort.Reverse(sort.IntSlice(points)))
	unique_points := sliceUnique(points)

	if float64(unique_points[m-1]) >= float64(sum / (4 * m)) {
		fmt.Println("Yes")
	}else{
		fmt.Print("No")
	}

}


package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	if m > n {
		return
	}
	points := make([]int, n)
	sum := 0

	for i:=0; i<n; i++{
		fmt.Scan(&points[i])
		sum += points[i]
	}

	sort.Sort(sort.Reverse(sort.IntSlice(points)))

	if points[m-1] >= sum / (4 * m){
		fmt.Println("Yes")
	}else{
		fmt.Print("No")
	}

}


package main

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

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

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

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

func scanInts64(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		res[i] = scanInt64()
	}
	return res
}

func scanText() string {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Scan()
	return sc.Text()
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n, m := scanInt(), scanInt()

	a := scanInts(n)
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	sum := 0

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

	for i := 0; i < m; i++ {
		if 4*m*a[i] < sum {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


package main

import (
  "fmt"
  "sort"
)

func main() {
  var n, m int
	fmt.Scanf("%d %d", &n, &m)
	v := make([]int, n)
	for i := range v {
		fmt.Scan(&v[i])
	}

	sort.Sort(sort.Reverse(sort.IntSlice(v)))
	r := 0
	for _, i := range v {
		r = r + i
	}
	l := r / (m * 4)
	var a string
	if v[m-1] > l {
		a = "Yes"
	} else {
		a = "No"
	}
	fmt.Println(a)
}


package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main()  {
	var N, M int
	fmt.Scan(&N, &M)

	inputs := strings.Split(readLine(), " ")

	sum := 0

	for i := 0; i < N; i++{
		num, _ := strconv.Atoi(inputs[i])
		sum += num
	}

	count := 0

	for i := 0; i < N; i++ {
		num, _ := strconv.Atoi(inputs[i])

		if num >= (sum / (4 * M)){
			count++
		}
	}

	if count >= M {
		fmt.Println("Yes")
	}else{
		fmt.Println("No")
	}
}


package main

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

var sc = bufio.NewScanner(os.Stdin)

func sum(slice []int) int {
    total := 0
    for _, n := range slice {
        total += n
    }
    return total
}

func main() {
    sc.Split(bufio.ScanWords)

    n, m := nextInt(), nextInt()
    a := nextIntArr(n)
    sortIntsRev(a)

    threshold := sum(a) / (4 * m)

    count := 0
    for _, c := range a{
        if threshold <= c {
            count++
        }
    }

    if count >= m {
        fmt.Println("Yes")
    } else {
        fmt.Println("No")
    }
}

// Library

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

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

func nextIntArr(n int) []int {
    var a []int
    for i := 0; i < n; i++ {
        a = append(a, nextInt())
    }
    return a
}

// 数値を桁区切りのスライスにする
func digit(n int, list []int) []int {
   if n > 0 {
       return digit(n/10, append(list, n%10))
   }
   return list
}

func sortIntsRev(list []int) {
    sort.Sort(sort.Reverse(sort.IntSlice(list)))
}

func strReverse(s string) string {
    runes := []rune(s)
    for i := 0; i < len(s)/2; i++ {
        runes[i], runes[len(s)-1-i] = runes[len(s)-1-i], runes[i]
    }
    return string(runes)
}


package main

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

var sc = bufio.NewScanner(os.Stdin)

func sum(slice []int) int {
    total := 0
    for _, n := range slice {
        total += n
    }
    return total
}

func main() {
    sc.Split(bufio.ScanWords)

    n, m := nextInt(), nextInt()
    a := nextIntArr(n)
    sortIntsRev(a)

    threshold := sum(a) / (4 * m)

    count := 0
    for _, c := range a{
        if threshold < c {
            count++
        }
    }

    if count >= m {
        fmt.Println("Yes")
    } else {
        fmt.Println("No")
    }
}

// Library

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

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

func nextIntArr(n int) []int {
    var a []int
    for i := 0; i < n; i++ {
        a = append(a, nextInt())
    }
    return a
}

// 数値を桁区切りのスライスにする
func digit(n int, list []int) []int {
   if n > 0 {
       return digit(n/10, append(list, n%10))
   }
   return list
}

func sortIntsRev(list []int) {
    sort.Sort(sort.Reverse(sort.IntSlice(list)))
}

func strReverse(s string) string {
    runes := []rune(s)
    for i := 0; i < len(s)/2; i++ {
        runes[i], runes[len(s)-1-i] = runes[len(s)-1-i], runes[i]
    }
    return string(runes)
}


package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)
	var m, n int
	fmt.Scan(&n, &m)
	a := make([]int, n)
	var totalVote int
	for i := 0; i < n; i++ {
		a[i] = nextInt()
		totalVote += a[i]
	}

	bar := totalVote / (4 * m)

	judge := func() string {
		total := 0
		for i := 0; i < n; i++ {
			if a[i] >= bar {
				total++
			}
			if total >= m {
				return "Yes"
			}
		}
		return "No"
	}()

	fmt.Println(judge)
}


package main

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

func main() {
    var input [][]string = StrStdin()
    var x []string = input[0]
    var y []string = input[1]
    var xx [2]int
    xx[0], _ = strconv.Atoi(x[0])
    xx[1], _ = strconv.Atoi(x[1])
    N := xx[0]
    M := xx[1]

    var yy []int

    yy = make([]int, N)

    for i := 0; i < N; i++ {
        yy[i], _ = strconv.Atoi(y[i])
    }
    var total int = 0
  for i:=0;i<N;i++{
    total += yy[i]
  }
  var result int = 0
  for i:=0;i<N;i++{
    if yy[i] >= (total/4)/M{
      result++
    }
    }
  if result >= M{
    fmt.Println("Yes")
    }else{
    fmt.Println("No")
    }
}

func StrStdin() [][]string {
    var stringInput string
    scanner := bufio.NewScanner(os.Stdin)

    scanner.Scan()
    stringInput = scanner.Text()

    stringInput = strings.TrimSpace(stringInput)

    s := strings.Split(stringInput, "\n")

    var Result [][]string = make([][]string, len(s))

    for i, st := range s {
        var line []string
        line = strings.Split(st, " ")

        Result[i] = line
    }

    return Result
}


package main

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

// 文字列を1行入力
func StrStdin() (stringReturned string) {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	stringReturned = scanner.Text()

	stringReturned = strings.TrimSpace(stringReturned)
	return
}

// 空白や空文字だけの値を除去したSplit()
func SplitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
	stringSplited := strings.Split(stringTargeted, delim)

	for _, str := range stringSplited {
		if str != "" {
			stringReturned = append(stringReturned, str)
		}
	}
	return
}

// デリミタで分割して文字列スライスを取得
func SplitStrStdin(delim string) (stringReturned []string) {
	// 文字列で1行取得
	stringInput := StrStdin()

	// 空白で分割
	// stringSplited := strings.Split(stringInput, delim)
	stringReturned = SplitWithoutEmpty(stringInput, delim)

	return
}

// デリミタで分割して整数値スライスを取得
func SplitIntStdin(delim string) (intSlices []int, err error) {
	// 文字列スライスを取得
	stringSplited := SplitStrStdin(" ")

	// 整数スライスに保存
	for i := range stringSplited {
		var iparam int
		iparam, err = strconv.Atoi(stringSplited[i])
		if err != nil {
			return
		}
		intSlices = append(intSlices, iparam)
	}
	return
}

func main() {
	input, _ := SplitIntStdin(" ")
	_, M := input[0], input[1]

	input, _ = SplitIntStdin(" ")

	sum := 0
	for _, x := range input {
		sum += x
	}

	var M_f float64 = float64(M)
	var sum_f float64 = float64(sum)

	count := 0
	for _, x := range input {
		var x_f float64 = float64(x)
		if x_f >= sum_f/(4.0*M_f) {
			count += 1
		}
	}

	if count >= M {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


package main

import "fmt"

func main(){
	var N, M int
	var ans int

	fmt.Scan(&N, &M)

	var A []int = make([]int, N)

	for i := 0 ; i < N ; i++ {
		fmt.Scan(&A[i])
	}

	for i := 0 ; i < N ; i++ {
		ans += A[i]
	}

	cnt := 0
	for _, e := range A {
		if 4 * M * e >= ans {cnt++}
	}

	if cnt >= M {
		fmt.Println("Yes")
	}else {
		fmt.Println("No")
	}
}


package main

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

type row []string

type data []row

func main() {
	nextReader = newScanner()
	N := nextInt()
	M := nextInt()
	sum := 0
	As := []int{}
	for n := 0; n < N; n++ {
		A := nextInt()
		As = append(As, A)
		sum += A
	}
	sort.Sort(sort.Reverse(sort.IntSlice(As)))
	for n := 0; n < M; n++ {
		if As[n] < sum/(4*M) {
			fmt.Print("no")
			return
		}
	}
	fmt.Print("yes")
}

var nextReader func() string

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	// r.Split(bufio.ScanLines)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func CustomScan(data []byte, atEOF bool) (advance int, token []byte, err error) {
	for i := 0; i < len(data); i++ {
		if data[i] == ' ' {
			return i + 1, data[:i], nil
		}
	}
	fmt.Println(data)
	return 0, data, bufio.ErrFinalToken
}

func nextStrings() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	// r.Split(bufio.ScanWords)
	r.Split(CustomScan)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

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


package main

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

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

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

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

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var n, m int
	fmt.Fscan(read, &n, &m)

	a := make([]int, n)
	sum := 0
	for i := range a {
		fmt.Fscan(read, &a[i])
		sum += a[i]
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))

	if a[m-1]*4*m < sum {
		fmt.Fprintln(write, "No")
	} else {
		fmt.Fprintln(write, "Yes")
	}
}


package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m, j int
	arr := make([]int, 0)
	total := 0
	fmt.Scanf("%d %d\n", &n, &m)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &j)
		arr = append(arr, j)
		total += j
	}
	// popular := total / (4 * m)
	sort.Sort(sort.Reverse(sort.IntSlice(arr)))
	// flag := true
	// for i := 0; i < m; i++ {
	// 	if arr[i] < popular {
	// 		flag = false
	// 		break
	// 	}
	// }
	if arr[m-1]*4*m >= total {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


package main
import(
  "fmt"
)
func main(){
  var i, n int
  var sum, m, count float64
  sum=0
  count=0
  fmt.Scan(&n, &m)
  a:=make([]float64, n)
  for i=0;i<n;i++{
    fmt.Scan(&a[i])
    sum+=a[i]
  }
  sum*=1/(4*m)
  for i=0;i<n;i++{
    if sum<=a[i]{
      count++
    }
  }
  if count<m{
    fmt.Println("No")
  }else{
    fmt.Println("Yes")
  }
}


package main

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

/* sort */
type pair struct {
	index  int64
	p1, p2 interface{}
}
type pairs []pair

func (slice pairs) Len() int {
	return len(slice)
}

func (slice pairs) Less(i, j int) bool {
	return slice[i].index < slice[j].index
}

func (slice pairs) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}

/* sort */
type Int64Slice []int64

func (slice Int64Slice) Len() int {
	return len(slice)
}

func (slice Int64Slice) Less(i, j int) bool {
	return slice[i] < slice[j]
}

func (slice Int64Slice) Swap(i, j int) {
	slice[i], slice[j] = slice[j], slice[i]
}
func Int64s(a []int64)                    { sort.Sort(Int64Slice(a)) }
func Int64sSliceAreSorted(a []int64) bool { return sort.IsSorted(Int64Slice(a)) }

const (
	initialBufSize = 1e4
	maxBufSize     = 1e8
	INF            = 1e8
)

var (
	scanner = bufio.NewScanner(os.Stdin)
	writer  = bufio.NewWriter(os.Stdout)
	di      = []int64{-1, 0, 1, 0}
	dj      = []int64{0, -1, 0, 1}
)

func main() {
	buf := make([]byte, initialBufSize)
	scanner.Buffer(buf, maxBufSize)
	scanner.Split(bufio.ScanWords)
	N, M := readInt(), readInt()
	A := make([]int64, N)
	for i := int64(0); i < N; i++ {
		A[i] = readInt()
	}
	sums := sum(A)
	selec := int64(0)
	for i := int64(0); i < N; i++ {
		if float64(A[i])/float64(sums) >= float64(1)/(4.0*float64(M)) {
			selec++
		}
	}
	if selec >= M {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

/*==========================================
 *             Library
 *==========================================*/
func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}
func doubleAry(h int64, w int64, init int64) (res [][]int64) {
	res = make([][]int64, h)
	for i := int64(0); i < h; i++ {
		res[i] = make([]int64, w)
		for j := int64(0); j < w; j++ {
			res[i][j] = init
		}
	}
	return
}

func aryEq(a []int64, b []int64) bool {
	return reflect.DeepEqual(a, b)
}

func clone(n []int64) (r []int64) {
	r = make([]int64, len(n))
	for i := 0; i < len(n); i++ {
		r[i] = n[i]
	}
	return
}
func write(s string) {
	writer.WriteString(s)
}

func print() {
	writer.Flush()
}

// scanner.Split(bufio.ScanWords) をコメントアウトしないと使用不可
func readLine() (s string) {
	if scanner.Scan() {
		s = scanner.Text()
	}
	return s
}

func readInt() (read int64) {
	scanner.Scan()
	read, err := strconv.ParseInt(scanner.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return
}

func readFloat() (read float64) {
	scanner.Scan()
	read, err := strconv.ParseFloat(scanner.Text(), 64)
	if err != nil {
		panic(err)
	}
	return
}

func readRunes() (read []rune) {
	scanner.Scan()
	for _, v := range scanner.Text() {
		read = append(read, v)
	}
	return
}

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

func readStrings() (read []string) {
	scanner.Scan()
	for _, v := range scanner.Text() {
		read = append(read, string(v))
	}
	return
}

func s2i(s string) int64 {
	var intVal, e = strconv.ParseInt(s, 10, 64)
	if e != nil {
		panic(e)
	}
	return intVal
}

func i2s(i int64) string {
	var strVal = strconv.FormatInt(i, 10)
	return strVal
}

func s2f(s string) float64 {
	var floatVal, e = strconv.ParseFloat(s, 64)
	if e != nil {
		panic(e)
	}
	return floatVal
}

func abs(i int64) int64 {
	return int64(math.Abs(float64(i)))
}

func sum(i []int64) int64 {
	sum := int64(0)
	for _, val := range i {
		sum += val
	}
	return sum
}

func split(s string) []string {
	return strings.Fields(s)
}

func strAry2intAry(strs []string) []int64 {
	var ret = make([]int64, 0, len(strs))
	for _, str := range strs {
		var intVal = s2i(str)
		ret = append(ret, intVal)
	}
	return ret
}

func intAry2strAry(nums []int64) []string {
	var ret = make([]string, 0, len(nums))
	for _, num := range nums {
		var strVal = i2s(num)
		ret = append(ret, strVal)
	}
	return ret
}

func ary2str(strs []string) string {
	return strings.Join(strs, " ")
}

func reverse(res []int64) []int64 {
	for i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 {
		res[i], res[j] = res[j], res[i]
	}
	return res
}
func reverseStr(res []string) []string {
	for i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 {
		res[i], res[j] = res[j], res[i]
	}
	return res
}

func ini(res []int, init int) {
	if len(res) == 0 {
		return
	}
	res[0] = init
	for i := 0; i < len(res); i++ {
		copy(res[i:], res[:i])
	}
}

//
// func regexpExample() {
//     // Your code here!
//     var str = "13:20"
//     r := regexp.MustCompile(`(\d+):(\d+)`)
//     fmt.Println(r.FindStringSubmatch(str))
// }

// type Country struct {
//     gold int
//     silver int
//     blonze int
// }

// // 複数ソートのサンプル
// func stableSortExample() []Country{
//     var country = []Country {
//         {gold:1, silver:2, blonze:3},
//         {gold:1, silver:2, blonze:3},
//         {gold:1, silver:3, blonze:2},
//         {gold:1, silver:3, blonze:3},
//     }
//     sort.SliceStable(country, func(i, j int) bool { return country[i].blonze > country[j].blonze })
//     sort.SliceStable(country, func(i, j int) bool { return country[i].silver > country[j].silver })
//     sort.SliceStable(country, func(i, j int) bool { return country[i].gold > country[j].gold })
//     return country
// }


package main

import (
	"fmt"
)

func solution(n, m int, a []int) string {
	sum := 0
	for _, x := range a {
		sum += x
	}
	c := 0
	for _, x := range a {
		if x < sum/(4*m) {
			continue
		}
		c++
	}
	if c >= m {
		return "Yes"
	}
	return "No"
}

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

	for i := range a {
		fmt.Scan(&j)
		a[i] = j
	}
	fmt.Println(solution(n, m, a))
}


package main

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

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

	sc.Scan()
	N, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	M, _ := strconv.Atoi(sc.Text())

	total := 0
	a := make([]int, N)
	for i := range a {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
		total = total + a[i]
	}

	var min float64 = float64(total) / float64(4.0*M)

	for _, a := range a {
		if float64(a) > min {
			M = M - 1
		}
	}

	if M <= 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m, a int
	fmt.Scan(&n, &m)
	ret := make([]int, n)
	max := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		ret[i] = a
		max += a
	}
	sort.Sort(sort.Reverse(sort.IntSlice(ret)))

	result := "No"
	num := 0
	for _, r := range ret {
		if max/(4*m) > r {
			continue
		}
		num++
		if num == m {
			result = "Yes"
			break
		}
	}
	fmt.Println(result)
}


package main

import(
  "fmt"
)

func main() {
  var N,M int
  fmt.Scan(&N,&M)

  A := make([]int, N)
  sum := 0
  for v := range A{
	fmt.Scan(&A[v])
	sum += A[v]
  }

  var border int
  if sum%(4*M) == 0 {
	border = sum/(4*M) -1
  } else {
	border = sum/(4*M)
  }

  count := 0
  for _,v:= range A {
	if v >border {
	  count++
	}
  }

  if count >= M {
	fmt.Println("Yes")
  } else {
	fmt.Println("No")
  }
}


package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func main() {
	sc.Split(bufio.ScanWords)
	n, m := readInt(), readInt()

	a := make([]int, n)
	sum := 0
	for i := 0; i < n; i++ {
		a[i] = readInt()
		sum += a[i]
	}

	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	var rate float64 = float64(a[m-1]) / float64(sum)

	if rate < 1.0/float64(4*m) {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}


package main
import "fmt"
import "sort"
func main(){
    // Your code here!
    var n, m int
    fmt.Scan(&n, &m)

    t := make([]int, n)
    for i := 0; i < n; i++ {
         fmt.Scan(&t[i])
    }

    sort.Sort(sort.Reverse(sort.IntSlice(t)))
    var sum int
    for i := 0; i < len(t); i++{
        sum += t[i]
    }

    for i := 0; i < m; i++{
        if t[i] < (sum/(4*m)){
            fmt.Println("No")
            return
        }
    }
    fmt.Println("Yes")
}


package main

import (
	"fmt"
)

func main() {

	var N,M int

	fmt.Scan(&N,&M)

	A := make([]int,N)

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

		fmt.Scan(&A[i])

	}

	sum := 0

	for _,x:= range A{

		sum += x
	}

	shikii := sum/(4*M)

	cnt :=0

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

		if A[i] > shikii{

			cnt++
		}
	}

	if cnt == M{

		fmt.Println("Yes")

	}else{

		fmt.Println("No")
	}

}


package main

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

func main() {
	n := readf()
	m := readf()
	a := make([]float64, int(n))
	var sum, cnt float64
	for i := range a {
		fmt.Scan(&a[i])
		sum += a[i]
	}

	for i := range a {
		if a[i] >= sum*(1/(4*m)) {
			cnt++
		}
	}
	yesOrNo(cnt >= m)
}

// IO---------------------------------------------------

func readi() (n int) {
	fmt.Scan(&n)
	return
}

func readf() (n float64) {
	fmt.Scan(&n)
	return
}

func reads() (n string) {
	fmt.Scan(&n)
	return
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func readSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func readFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

func yesorno(b bool) {
	if b {
		fmt.Println("yes")
		return
	}
	fmt.Println("no")
}

// calc---------------------------------------------------

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

func ave(a []int) (ave int) {
	for i := 0; i < len(a); i++ {
		ave += a[i]
	}
	ave /= len(a)
	return
}

func eq(a []string, b []string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

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

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

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

func mid(a []int) int {
	sort.Ints(a)
	return a[len(a)/2]
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}


package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m, sum int
	fmt.Scan(&n, &m)
	as := make([]int, n)
	for i := range as {
		fmt.Scan(&as[i])
		sum += as[i]
	}

	sort.Ints(as)

	var a int
	for i := 0; i < m; i++ {
		a = as[n-1-i]
	}

	if float64(a) < float64(sum)/float64(4*m) {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
}


package main

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

func main() {
	_, M := sc.nextInt(), sc.nextInt()
	An := sc.nextInts()
	sort.Ints(An)
	var total int
	for _, v := range An {
		total += v
	}

	for i := 0; i < M; i++ {
		tmp := An[len(An)-i-1]
		// fmt.Println(tmp)
		if tmp < (total / (4 * M)) {
			no()
			return
		}
	}
	yes()
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

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

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	aa := make([]int, n)
	sum := 0
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
		sum += aa[i]
	}
	mm := m
	sort.Ints(aa)
	for i := n - 1; i >= 0 && m > 0; i-- {
		m--
		if aa[i]*4*mm < sum {
			fmt.Fprintln(writer, "No")
			return
		}
	}
	fmt.Fprintln(writer, "Yes")
}


package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func main() {
	N := getInt()
	M := getInt()
	A := getIntArray(N)

	total := 0
	for i := 0; i < N; i++ {
		total += A[i]
	}

	cnt := 0
	for i := 0; i < N; i++ {
		if A[i] >= total / (4*M) {
			cnt++
		}
	}

	if cnt >= M {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

type Graph struct {
	n     int
	edges [][]int
}

func NewGraph(n int) *Graph {
	g := &Graph{
		n:     n,
		edges: make([][]int, n),
	}
	return g
}

func (g *Graph) AddEdge(u, v int) {
	g.edges[v] = append(g.edges[v], u)
	g.edges[u] = append(g.edges[u], v)
}

func dfs(c int, edges [][]int, visited map[int]struct{}) {
	visited[c] = struct{}{}

	for _, v := range edges[c] {
		_, flag := visited[v]
		if flag {
			continue
		}
		dfs(v, edges, visited)
	}
}

func bfs(c int, graph *Graph) {
	next := make([]int, 0)
	next = append(next, c)
	visited := make(map[int]struct{})

	for ; len(next) != 0; {
		u := next[0]
		next = next[1:]
		visited[u] = struct{}{}

		for v := range graph.edges[u] {
			_, flag := visited[v]
			if flag {
				continue
			}

			// なにか処理

			next = append(next, v)
		}
	}
}

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

func getIntArray(n int) []int {
	array := make([]int, n)
	for i := 0; i < n; i++ {
		array[i] = getInt()
	}
	return array
}

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

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

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func powMod(n, p int) int {
	if p == 0 {
		return 1
	} else if p%2 == 0 {
		t := powMod(n, p/2)
		return calcMod(t * t)
	} else {
		return calcMod(n * powMod(n, p-1))
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray)-1])
}

func calcMod(x int) int {
	return x % mod
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func isPrime(n int) bool {
	if n < 2 {
		return false
	} else if n == 2 {
		return true
	} else if n % 2 == 0 {
		return false
	}

	sqrtN := int(math.Sqrt(float64(n)))
	for i := 3; i <= sqrtN; i += 2 {
		if n % i == 0 {
			return false
		}
	}

	return true
}

func contains(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}

func makeRange(min, max int) []int {
	a := make([]int, max-min+1)
	for i := range a {
		a[i] = min + i
	}
	return a
}

func powerset2(nums []int) [][]int {
	length := int(math.Pow(2, float64(len(nums))))
	result := make([][]int, length)

	index := 0
	result[index] = []int{}
	index++

	for _, n := range nums {
		max := index
		for i := 0; i < max; i++ {
			result[index] = copyAndAppend(result[i], n)
			index++
		}
	}

	return result
}

func copyAndAppend(nums []int, n int) []int {
	dst := make([]int, len(nums)+1)
	copy(dst, nums)
	dst[len(nums)] = n
	return dst
}

func calcGcd(x, y int) int {
	if y == 0 {
		return x
	} else if x >= y {
		return calcGcd(y, x % y)
	} else {
		return calcGcd(x, y % x)
	}
}

func getDivisor(n int) []int {
	var divisor []int
	divisor = append(divisor, 1)
	if n != 1 {
		divisor = append(divisor, n)
	}

	sqrt := int(math.Sqrt(float64(n)))
	for i := 2; i <= sqrt; i++ {
		if n % i == 0 {
			divisor = append(divisor, i)
			divisor = append(divisor, n/i)
		}
	}
	return divisor
}

type intHeap []int

func (h intHeap) Len() int {
	return len(h)
}

func (h intHeap) Less(i, j int) bool {
	return h[i] > h[j]
}

func (h intHeap) Swap(i, j int) {
	h[i], h[j] = h[j], h[i]
}

func (h *intHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *intHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func initHeap() *intHeap {
	ih := &intHeap{}
	heap.Init(ih)
	return ih
}

func (h *intHeap) pushHeap(n int) {
	heap.Push(h, n)
}

func (h *intHeap) popHeap() int {
	return heap.Pop(h).(int)
}

func factMod(n int) int {
	value := 1
	for ; n > 1; n-- {
		value = calcMod(value * n)
	}
	return value
}

func combinationMod(n, k int) int {
	factN := factMod(n)
	factK := factMod(k)
	factNK := factMod(n - k)
	factKR := powMod(factK, mod - 2)
	factNKR := powMod(factNK, mod - 2)
	return calcMod(factN * calcMod(factKR * factNKR))
}


package main

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

func main() {
	x, y := readInt(), readInt()
	a, b, c := readInt(), readInt(), readInt()
	p, q, r := make([]int, a), make([]int, b), make([]int, c)
	for i := range p {
		p[i] = readInt()
	}
	for i := range q {
		q[i] = readInt()
	}
	for i := range r {
		r[i] = readInt()
	}
	sort.Sort(sort.Reverse(sort.IntSlice(p)))
	sort.Sort(sort.Reverse(sort.IntSlice(q)))
	sort.Sort(sort.Reverse(sort.IntSlice(r)))

	arr := make([]int, 0, x+y)
	for i := 0; i < x; i++ {
		arr = append(arr, p[i])
	}
	for i := 0; i < y; i++ {
		arr = append(arr, q[i])
	}

	sort.Ints(arr)
	for i := 0; i < min(len(arr)-1, c); i++ {
		if r[i] < arr[i] {
			break
		}
		arr[i] = r[i]
	}

	// fmt.Println(p)
	// fmt.Println(q)
	// fmt.Println(r)

	ans := 0
	for i := range arr {
		ans += arr[i]
	}
	fmt.Println(ans)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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

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

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

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}

Score : 500 points

Problem Statement

You are going to eat X red apples and Y green apples.

You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C.

Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively.

From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible.

Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.

Constraints

1 \leq X \leq A \leq 10^5

1 \leq Y \leq B \leq 10^5

1 \leq C \leq 10^5

1 \leq p_i \leq 10^9

1 \leq q_i \leq 10^9

1 \leq r_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

X Y A B C
p_1 p_2 ... p_A
q_1 q_2 ... q_B
r_1 r_2 ... r_C

Output

Print the maximum possible sum of the deliciousness of the eaten apples.

Sample Input 1

1 2 2 2 1
2 4
5 1
3

Sample Output 1

12

The maximum possible sum of the deliciousness of the eaten apples can be achieved as follows:

Eat the 2-nd red apple.

Eat the 1-st green apple.

Paint the 1-st colorless apple green and eat it.

Sample Input 2

2 2 2 2 2
8 6
9 1
2 1

Sample Output 2

25

Sample Input 3

2 2 4 4 4
11 12 13 14
21 22 23 24
1 2 3 4

Sample Output 3

74


package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

type Apple struct {
	sweetness int
	color     int //0:red,1:green,2:colorless
}

type Apples []Apple

func (c Apples) Len() int {
	return len(c)
}

func (c Apples) Swap(i, j int) {
	c[i], c[j] = c[j], c[i]
}

func (c Apples) Less(i, j int) bool {
	return c[i].sweetness > c[j].sweetness
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	X, Y, A, B, C := nextInt(), nextInt(), nextInt(), nextInt(), nextInt()
	var p Apples = make([]Apple, A)
	var q Apples = make([]Apple, B)
	var r Apples = make([]Apple, C)
	for i := 0; i < A; i++ {
		p[i] = Apple{nextInt(), 0}
	}
	for i := 0; i < B; i++ {
		q[i] = Apple{nextInt(), 1}
	}
	for i := 0; i < C; i++ {
		r[i] = Apple{nextInt(), 2}
	}
	sort.Sort(p)
	sort.Sort(q)
	sort.Sort(r)

	pAns := p[:X]
	qAns := q[:Y]
	ip := len(pAns) - 1
	iq := len(qAns) - 1
	for i := 0; i < C; i++ {
		if pAns[ip].sweetness > r[i].sweetness && qAns[iq].sweetness > r[i].sweetness {
			break
		}
		if iq < 0 && ip >= 0 {
			// check only p
			if pAns[ip].sweetness < r[i].sweetness {
				pAns[ip] = r[i]
				ip--
			}
		} else if ip < 0 && iq >= 0 {
			// check only q
			if qAns[iq].sweetness < r[i].sweetness {
				qAns[iq] = r[i]
				iq--
			}
		} else if ip < 0 && iq < 0 {
			break
		} else {
			if pAns[ip].sweetness > qAns[iq].sweetness {
				qAns[iq] = r[i]
				iq--
			} else {
				pAns[ip] = r[i]
				ip--
			}
		}
	}
	ans := 0
	for i := 0; i < len(pAns); i++ {
		ans += pAns[i].sweetness
	}
	for i := 0; i < len(qAns); i++ {
		ans += qAns[i].sweetness
	}
	fmt.Println(ans)

}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

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

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

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

// -*-*-*-*-*-*-*-*-*-*-*-*-*-
// * Algorithms Utility Zone *
// -*-*-*-*-*-*-*-*-*-*-*-*-*-

// -*-*-*-*-*-*-*-
// * 1. nibutan  *
// -*-*-*-*-*-*-*-
func lower_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if arr[mid] < target {
			l = mid + 1
		} else {
			r = mid
		}
	}
	return l
}

func upper_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if target < arr[mid] {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	// 10^2 = 100ってことは10に10を1回掛けることだね
	// なので初期値を含めると上限b-1未満
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

type Apple struct {
	sweetness int
	color     int //0:red,1:green,2:colorless
}

type Apples []Apple

func (c Apples) Len() int {
	return len(c)
}

func (c Apples) Swap(i, j int) {
	c[i], c[j] = c[j], c[i]
}

func (c Apples) Less(i, j int) bool {
	return c[i].sweetness > c[j].sweetness
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	X, Y, A, B, C := nextInt(), nextInt(), nextInt(), nextInt(), nextInt()
	var p Apples = make([]Apple, A)
	var q Apples = make([]Apple, B)
	var r Apples = make([]Apple, C)
	for i := 0; i < A; i++ {
		p[i] = Apple{nextInt(), 0}
	}
	for i := 0; i < B; i++ {
		q[i] = Apple{nextInt(), 1}
	}
	for i := 0; i < C; i++ {
		r[i] = Apple{nextInt(), 2}
	}
	sort.Sort(p)
	sort.Sort(q)
	sort.Sort(r)

	pAns := p[:X]
	qAns := q[:Y]
	ip := len(pAns) - 1
	iq := len(qAns) - 1
	for i := 0; i < C; i++ {
		if pAns[ip].sweetness > r[i].sweetness && qAns[iq].sweetness > r[i].sweetness {
			break
		}
		if iq < 0 && ip >= 0 {
			// check only p
			if pAns[ip].sweetness < r[i].sweetness {
				pAns[ip] = r[i]
				ip--
			}
		} else if ip < 0 && iq >= 0 {
			// check only q
			if qAns[iq].sweetness < r[i].sweetness {
				qAns[iq] = r[i]
				iq--
			}
		} else {
			if pAns[ip].sweetness > qAns[iq].sweetness {
				qAns[iq] = r[i]
				iq--
			} else {
				pAns[ip] = r[i]
				ip--
			}
		}
	}
	ans := 0
	for i := 0; i < len(pAns); i++ {
		ans += pAns[i].sweetness
	}
	for i := 0; i < len(qAns); i++ {
		ans += qAns[i].sweetness
	}
	fmt.Println(ans)

}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

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

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

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

// -*-*-*-*-*-*-*-*-*-*-*-*-*-
// * Algorithms Utility Zone *
// -*-*-*-*-*-*-*-*-*-*-*-*-*-

// -*-*-*-*-*-*-*-
// * 1. nibutan  *
// -*-*-*-*-*-*-*-
func lower_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if arr[mid] < target {
			l = mid + 1
		} else {
			r = mid
		}
	}
	return l
}

func upper_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if target < arr[mid] {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	// 10^2 = 100ってことは10に10を1回掛けることだね
	// なので初期値を含めると上限b-1未満
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


// 赤X+緑Y個を選びたい、赤Aと緑BとCがありCは赤か緑に変更可能
// A+BでX+Yが足りる場合（条件から絶対足りるわコレ アホな誤読してた） Cで置換できるものがあれば置換する
// 置換はRの大きいものからP,Qに対してにぶたんして、優先順位の高いやつからやる
// 優先順位の高いやつ、それは何
// なんかどうせ使うんだしP,Qどっちにしても良さそうだしそうする
// これは懸念ですが雑にやったのでpopleftがおかしいし多分TLEなると思うこれ

package main

import (
	"fmt"
	"sort"
)

func main() {
	var X, Y, A, B, C int
	fmt.Scan(&X, &Y, &A, &B, &C)
	P, Q, R := make([]int, A), make([]int, B), make([]int, C)

	for i := 0; i < A; i++ {
		var V int
		fmt.Scan(&V)
		P[i] = V
	}
	for i := 0; i < B; i++ {
		var V int
		fmt.Scan(&V)
		Q[i] = V
	}
	for i := 0; i < C; i++ {
		var V int
		fmt.Scan(&V)
		R[i] = V
	}
	sort.Sort(sort.Reverse(sort.IntSlice(P)))
	sort.Sort(sort.Reverse(sort.IntSlice(Q)))
	sort.Sort(sort.Reverse(sort.IntSlice(R)))
	P = P[:X]
	Q = Q[:Y]
	// まずRをPに使えるだけ試し、次に余ったRをQに使えるだけ試す
	// いつもならlower boundをフルスクラッチで実装するんだけどこれたまたまsort使ってるのでsortパッケージから使ってみることにする

	usedCount := 0
	for _, r := range R {
		// fmt.Printf("target = %d\n", r)
		idx := sort.Search(X, func(i int) bool { return P[i] < r })
		// fmt.Printf("idx:= %d\n", idx)
		if idx >= X {
			// fmt.Println("もう置換不可能")
			break
		} else {
			// fmt.Printf("置換可能： P[%d]=%d\n", idx, P[idx])
			P[idx] = r
			usedCount += 1
		}
	}
	R = R[usedCount:]
	for _, r := range R {
		// fmt.Printf("target = %d\n", r)
		idx := sort.Search(X, func(i int) bool { return Q[i] < r })
		// fmt.Printf("idx:= %d\n", idx)
		if idx >= Y {
			// fmt.Println("もう置換不可能")
			break
		} else {
			// fmt.Printf("置換可能： Q[%d]=%d\n", idx, Q[idx])
			Q[idx] = r
			usedCount += 1
		}
	}
	ans := 0
	for _, p := range P {
		ans += p
	}
	for _, q := range Q {
		ans += q
	}
	fmt.Println(ans)
}


package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var x, y, a, b, c int
	fmt.Fscan(r, &x)
	fmt.Fscan(r, &y)
	fmt.Fscan(r, &a)
	fmt.Fscan(r, &b)
	fmt.Fscan(r, &c)
	as := make([]int, a)
	bs := make([]int, b)
	cs := make([]int, c)
	for i := 0; i < a; i++ {
		fmt.Fscan(r, &as[i])
	}
	for i := 0; i < b; i++ {
		fmt.Fscan(r, &bs[i])
	}
	for i := 0; i < c; i++ {
		fmt.Fscan(r, &cs[i])
	}
	sort.Sort(sort.IntSlice(as))
	sort.Sort(sort.IntSlice(bs))
	sort.Sort(sort.IntSlice(cs))

	ans := 0
	sumX := 0
	sumY := 0
	asIndex := a - 1
	bsIndex := b - 1
	csIndex := c - 1
	for sumX+sumY < x+y {
		currentC := -1
		if csIndex >= 0 {
			currentC = cs[csIndex]
		}

		if sumX < x && sumY < y {
			if as[asIndex] > bs[bsIndex] {
				if as[asIndex] > currentC {
					ans += as[asIndex]
					asIndex--
					sumX++
				} else {
					ans += currentC
					csIndex--
					sumX++
				}
			} else {
				if bs[bsIndex] > currentC {
					ans += bs[bsIndex]
					bsIndex--
					sumY++
				} else {
					ans += currentC
					csIndex--
					sumY++
				}
			}
		} else if sumX < x {
			if as[asIndex] > currentC {
				ans += as[asIndex]
				asIndex--
				sumX++
			} else {
				ans += currentC
				csIndex--
				sumX++
			}
		} else {
			if bs[bsIndex] > currentC {
				ans += bs[bsIndex]
				bsIndex--
				sumY++
			} else {
				ans += currentC
				csIndex--
				sumY++
			}
		}
	}

	fmt.Println(ans)
}


package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  x, y, a, b, c := nextInt(), nextInt(), nextInt(), nextInt(), nextInt()
  p, q, r := nextInts(a), nextInts(b), nextInts(c)

  sort.Sort(sort.Reverse(sort.IntSlice(p)))
  	sort.Sort(sort.Reverse(sort.IntSlice(q)))
  	sort.Sort(sort.Reverse(sort.IntSlice(r)))

  	r = append(r, p[:x]...)
  	r = append(r, q[:y]...)
  	sort.Sort(sort.Reverse(sort.IntSlice(r)))

  	var ans int
  	for i := 0; i < x+y; i++ {
  		ans += r[i]
  	}

  // p = p[len(p)-x:]
  // q = q[len(q)-y:]
  //
  // sort.Ints(p)
  // sort.Ints(q)
  // var d []int
  // d = append(d, p...)
  // d = append(d, q...)
  // d = append(d, r...)
  // sort.Ints(d)
  //
  // var ans int
	// for i := 0; i < x+y; i++ {
  //   ans += d[len(d)-1]
  //   d = d[:len(d)-1]
	// }
	fmt.Println(ans)
}

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

func nextInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = nextInt()
	}
	return sl
}


package main

import (
	"fmt"
	"sort"
)

func main() {
	var x, y, a, b, c int
	fmt.Scan(&x, &y, &a, &b, &c)
	p := make([]int, a)
	q := make([]int, b)
	r := make([]int, c)
	for i := 0; i < a; i++ {
		fmt.Scan(&p[i])
	}
	for i := 0; i < b; i++ {
		fmt.Scan(&q[i])
	}
	for i := 0; i < c; i++ {
		fmt.Scan(&r[i])
	}

	sort.Sort(sort.Reverse(sort.IntSlice(p)))
	sort.Sort(sort.Reverse(sort.IntSlice(q)))
	p = p[:x]
	q = q[:y]

	d := []int{}
	d = append(d, p...)
	d = append(d, q...)
	d = append(d, r...)
	sort.Sort(sort.Reverse(sort.IntSlice(d)))

	ans := 0
	for i := 0; i < x+y; i++ {
		ans += d[i]
	}
	fmt.Println(ans)
}