iidai/codenet huggingface dataset:
Language: Go

package main

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

var in = bufio.NewReader(os.Stdin)

func solve(a, b, c int) int {
	var temp_ int
	if c == a+b {
		temp_ = b + c
	} else if c-1 > a+b {
		temp := (c - 1) - (a + b)
		temp_ = b + c - temp
	} else {
		temp_ = b + c
	}

	return temp_
}
func main() {
	var a, b, c int
	fmt.Fscanf(in, "%d %d %d¥n", &a, &b, &c)

	ans := solve(a, b, c)
	fmt.Println(ans)
}


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

output: 5
Language: Go

package main

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

	"sort"
)

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	arr := make([]float64, n)
	for i := 0; i < n; i++ {
		arr[i] = float64(sc.NextInt())
	}
	sort.Float64s(arr)
	prev := arr[0]
	for i := 1; i < len(arr); i++ {
		prev = (prev + arr[i]) / 2
	}

	fmt.Printf("%v\n", prev)
}

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

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

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

	return result
}

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

	return mp
}

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


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

output: 3.5
Language: Go

package main

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

func main() {
	io, flash := NewIO()
	defer flash()

	n, t, a := io.ScanInt(), io.ScanFloat64(), io.ScanFloat64()
	heights := io.ScanFloat64s(n)

	minDiff := AbsDiffFloat64(t-heights[0]*0.006, a)
	minIdx := 0
	for i, h := range heights[1:] {
		diff := AbsDiffFloat64(t-h*0.006, a)
		if diff < minDiff {
			minDiff = diff
			minIdx = i + 1
		}
	}
	fmt.Println(minIdx + 1)
}

func AbsDiffFloat64(n1, n2 float64) float64 {
	return math.Abs(n1 - n2)
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInt2() (int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt3() (int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt4() (int, int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Example test case(s):
input: 2
12 5
1000 2000

output: 1
Language: Go

package main

import "fmt"

type Dice struct {
	Nums []int
}

func (d *Dice) rotate(direction string, times int) {
	times %= 4
	switch direction {
	case "W":
		for i := 0; i < times; i++ {
			d.Nums[0], d.Nums[2], d.Nums[5], d.Nums[3] = d.Nums[2], d.Nums[5], d.Nums[3], d.Nums[0]
		}
	case "E":
		for i := 0; i < times; i++ {
			d.Nums[0], d.Nums[2], d.Nums[5], d.Nums[3] = d.Nums[3], d.Nums[0], d.Nums[2], d.Nums[5]
		}
	case "N":
		for i := 0; i < times; i++ {
			d.Nums[0], d.Nums[4], d.Nums[5], d.Nums[1] = d.Nums[1], d.Nums[0], d.Nums[4], d.Nums[5]
		}
	case "S":
		for i := 0; i < times; i++ {
			d.Nums[5], d.Nums[1], d.Nums[0], d.Nums[4] = d.Nums[1], d.Nums[0], d.Nums[4], d.Nums[5]
		}
	}
}

func (d *Dice) roll(direction string, times int) {
	times %= 4
	switch direction {
	case "R":
		for i := 0; i < times; i++ {
			d.Nums[3], d.Nums[1], d.Nums[2], d.Nums[4] = d.Nums[1], d.Nums[2], d.Nums[4], d.Nums[3]
		}
	case "L":
		for i := 0; i < times; i++ {
			d.Nums[3], d.Nums[1], d.Nums[2], d.Nums[4] = d.Nums[4], d.Nums[3], d.Nums[1], d.Nums[2]
		}
	}
}

func (d *Dice) printStatus() {
	status :=
		`	　　　 _ _ _ _
     _ _ _|_%3d_|_ _ _ _ _ _
    |_%3d_|_%3d_|_%3d_|_%3d_|
 　       |_%3d_|
`
	fmt.Printf(status, d.Nums[0], d.Nums[3], d.Nums[1], d.Nums[2], d.Nums[4], d.Nums[5])
	fmt.Println()
}

func getIndex(nums []int, target int) (index int) {
	for i, v := range nums {
		if target == v {
			index = i
			break
		} else {
			index = -1
		}
	}
	return index
}

func (d *Dice) isEqual(other Dice) bool {
	for i, v := range d.Nums {
		if v != other.Nums[i] {
			return false
		}
	}
	return true
}

func main() {
	dice1 := Dice{
		make([]int, 6),
	}
	dice2 := Dice{
		make([]int, 6),
	}
	for i := 0; i < 6; i++ {
		var n int
		fmt.Scan(&n)
		dice1.Nums[i] = n
	}
	for i := 0; i < 6; i++ {
		var n int
		fmt.Scan(&n)
		dice2.Nums[i] = n
	}

	directionOrder := []string{"N", "S", "W", "E"}
	rollOrder := []string{"R", "L"}
	flag := false

CHECK:
	for i := 0; i <= 2; i++ {
		for j := 0; j <= 2; j++ {
			for _, direction := range directionOrder {
				for _, roll := range rollOrder {
					tmp := new(Dice)
					tmp.Nums = append([]int{}, dice2.Nums...)
					tmp.rotate(direction, i)
					tmp.roll(roll, j)
					if tmp.isEqual(dice1) {
						flag = true
						break CHECK
					}
				}
			}
		}
	}
	if flag {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

output: Yes
Language: Go

package main

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

const size = 1000000

var reader = bufio.NewReaderSize(os.Stdin, size)

func NextLine() string {
	var line, buffer []byte
	var isPrefix bool = true
	var err error
	for isPrefix {
		line, isPrefix, err = reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
	}
	return string(buffer)
}
func NextInts() (int, int) {
	var x, y int
	var s []string = strings.Split(NextLine(), " ")
	x, _ = strconv.Atoi(s[0])
	y, _ = strconv.Atoi(s[1])
	return x, y
}
func NextIntArray() []int {
	var s []string = strings.Split(NextLine(), " ")
	var a []int = make([]int, len(s))
	for i := 0; i < len(s); i++ {
		a[i], _ = strconv.Atoi(s[i])
		a[i]--
	}
	return a
}

var par, rank []int

func main() {
	var n, m int = NextInts()
	var p []int = NextIntArray()
	var x, y int
	initialize(n)
	for i := 0; i < m; i++ {
		x, y = NextInts()
		unite(x-1, y-1)
	}
	var s int
	for i := 0; i < n; i++ {
		if same(i, p[i]) {
			s++
		}
	}
	fmt.Println(s)
}
func initialize(n int) {
	par = make([]int, n)
	rank = make([]int, n)
	for i := 0; i < n; i++ {
		par[i] = i
	}
}
func root(i int) int {
	if par[i] == i {
		return i
	}
	par[i] = root(par[i])
	return par[i]
}
func same(i, j int) bool {
	return root(i) == root(j)
}
func unite(i, j int) {
	i = root(i)
	j = root(j)
	if i == j {
		return
	}
	if rank[i] < rank[j] {
		par[i] = j
	} else {
		par[j] = i
		if rank[i] == rank[j] {
			rank[i]++
		}
	}
}


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

output: 2
Language: Go

package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	m := nextInt()
	h := make([]int, n)
	good := make([]bool, n)
	for i := 0; i < n; i++ {
		h[i] = nextInt()
		good[i] = true
	}
	for i := 0; i < m; i++ {
		ai := nextInt() - 1
		bi := nextInt() - 1
		if h[ai] > h[bi] {
			good[bi] = false
		} else if h[ai] < h[bi] {
			good[ai] = false
		} else {
			good[ai] = false
			good[bi] = false
		}
	}
	ans := 0
	for i := 0; i < n; i++ {
		if good[i] {
			ans++
		}
	}
	fmt.Println(ans)
}

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


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

output: 2
Language: Go

package main

import "fmt"

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)
	h := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
	}
	var a, b int
	counter := make(map[int]struct{})
	for i := 0; i < m; i++ {
		fmt.Scanf("%d %d", &a, &b)
		if h[a-1] < h[b-1] {
			counter[a] = struct{}{}
		} else if h[a-1] > h[b-1] {
			counter[b] = struct{}{}
		} else if h[a-1] == h[b-1] {
			counter[a] = struct{}{}
			counter[b] = struct{}{}
		}
	}
	fmt.Println(n - len(counter))
}


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

output: 2
Language: Go

package main

import "fmt"

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

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

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

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

	var sum int
	for i := 0; i <= n-1; i++ {
		a := as[i]
		b := bs[i]
		if a <= b {
			sum += a
			b -= a
			if i+1 <= n {
				an := as[i+1]
				if an <= b {
					sum += an
					as[i+1] = 0
				} else {
					sum += b
					as[i+1] -= b
				}
			}
		} else {
			sum += b
		}
	}
	fmt.Println(sum)
}


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

output: 9
Language: Go

package main

import "fmt"

type problem struct {
	number, bonus int
}

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

func main() {
	var D, G int
	fmt.Scan(&D, &G)
	problems := make([]problem, D)
	for i := range problems {
		fmt.Scan(&problems[i].number)
		fmt.Scan(&problems[i].bonus)
	}

	ans := 10000
	for bit := 0; bit < (1 << uint(D)); bit++ {
		score := 0
		solved := 0
		ok := false
		for j := 0; j < D; j++ {
			if bit&(1<<uint(j)) != 0 {
				score += (j+1)*100*problems[j].number + problems[j].bonus
				solved += problems[j].number
			}
		}
		if score < G {
			var j int
			for j = D - 1; j >= 0; j-- {
				if bit&(1<<uint(j)) == 0 {
					break
				}
			}
			for k := 0; k < problems[j].number; k++ {
				score += (j + 1) * 100
				solved++
				if score >= G {
					ok = true
					break
				}
			}
			if !ok {
				score += problems[j].bonus
				if score >= G {
					ok = true
				}
			}
		} else {
			ok = true
		}
		if ok {
			ans = min(ans, solved)
		}
	}
	fmt.Println(ans)
}


Example test case(s):
input: 2 700
3 500
5 800

output: 3
Language: Go

package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	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) {
	k := getNextInt(scanner)
	x := getNextInt(scanner)

	ans := "No"
	if k*500 >= x {
		ans = "Yes"
	}
	fmt.Fprintln(writer, ans)
}


Example test case(s):
input: 2 900

output: Yes
Language: Go

package main

import (
	"fmt"
)

func searchRange(text *string, start, limit int) (int, int, int) {
	middle := -1

	for i := start; i < limit; i++ {
		if (*text)[i] != 'R' {
			middle = i
			break
		}
	}

	end := limit

	for i := middle; i < limit; i++ {
		if (*text)[i] != 'L' {
			end = i
			break
		}
	}

	return start, middle, end
}

func answer() {
	var text string
	fmt.Scan(&text)
	limit := len(text)

	start := 0
	middle := 0
	end := 0
	firstPrinted := false

	for end < limit {
		start, middle, end = searchRange(&text, start, limit)
		len1 := middle - start
		len2 := end - middle

		for i := start; i < middle-1; i++ {
			if firstPrinted {
				fmt.Print(" ")
			}
			fmt.Print("0")
			firstPrinted = true
		}

		count1 := (len1+1)/2 + len2/2
		count2 := len1/2 + (len2+1)/2

		if firstPrinted {
			fmt.Print(" ")
		}
		fmt.Printf("%v %v", count1, count2)
		firstPrinted = true

		for i := middle + 1; i < end; i++ {
			if firstPrinted {
				fmt.Print(" ")
			}
			fmt.Print("0")
			firstPrinted = true
		}
		start = end
		firstPrinted = true
	}
	fmt.Println()
}

func main() {
	answer()
}


Example test case(s):
input: RRLRL

output: 0 1 2 1 1
Language: Go

package main

import (
	"fmt"
	"sort"
	"strings"
)

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

	count := 0
	var counter []int

	if s == "" {
		return
	}
	counter = append(counter, 0)
	li := strings.Split(s, "")

	for _, s := range li {
		if s == "A" || s == "C" || s == "G" || s == "T" {
			count++
		} else {
			counter = append(counter, count)
			count = 0
		}
	}

	counter = append(counter, count)
	sort.Ints(counter)
	fmt.Println(counter[len(counter)-1])
}


Example test case(s):
input: ATCODER

output: 3
Language: Go

package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)
	if a < b && b < c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
	return
}


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

output: Yes
Language: Go

package main

import (
	"fmt"
	"math"
)

const inf = 10000000000.0

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

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

	cumSumA := make([]int, n+1)
	cumSumA[0] = 0
	for i, a := range arrA {
		cumSumA[i+1] = cumSumA[i] + a
	}

	ans := inf
	for i := 1; i < n; i++ {
		if math.Abs(float64(cumSumA[n]-(cumSumA[i]*2))) < ans {
			ans = math.Abs(float64(cumSumA[n] - cumSumA[i]*2))
		}
	}

	fmt.Println(int(ans))
}


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

output: 1
Language: Go

package main

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

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

	N := ScanInt(scanner)
	X := make([]int, N)
	Y := make([]int, N)
	for i := 0; i < N; i++ {
		X[i] = ScanInt(scanner)
		Y[i] = X[i]
	}

	sort.Sort(sort.IntSlice(Y))
	m1 := Y[N/2-1]
	m2 := Y[N/2]
	for i := 0; i < N; i++ {
		if X[i] <= m1 {
			fmt.Println(m2)
		} else {
			fmt.Println(m1)
		}
	}

}

func ScanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func ScanFloat64(scanner *bufio.Scanner) float64 {
	scanner.Scan()
	f, e := strconv.ParseFloat(scanner.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

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

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

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

func Abs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}


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

output: 4
3
3
4
Language: Go

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	var c [3][3]int
	var a, b [3]int
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			scanner.Scan()
			c[i][j], _ = strconv.Atoi(scanner.Text())
		}
	}

	b[0] = c[0][0] - a[0]
	b[1] = c[0][1] - a[0]
	b[2] = c[0][2] - a[0]
	a[1] = c[1][0] - c[0][0]
	a[2] = c[2][0] - c[0][0]
	if a[1] == c[1][1]-c[0][1] && a[1] == c[1][2]-c[0][2] &&
		a[2] == c[2][1]-c[0][1] && a[2] == c[2][2]-c[0][2] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

output: Yes
Language: Go

package main

import "fmt"

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

	max := 0
	cnt := 0
	for _, r := range s {
		if r == 'I' {
			cnt++
		} else {
			cnt--
		}

		if cnt > max {
			max = cnt
		}
	}

	fmt.Println(max)
}


Example test case(s):
input: 5
IIDID

output: 2
Language: Go

package main

import (
	"fmt"
)

func main() {
	var N, K, R, S, P int
	var T string
	fmt.Scan(&N, &K, &R, &S, &P)
	fmt.Scan(&T)

	dict := map[string]int{"r": 0, "s": 0, "p": 0}
	char := ""
	s := make([]bool, N)
	for i := 0; i < N; i++ {
		s[i] = true
	}
	r := make([]bool, N)
	p := make([]bool, N)
	copy(r, s)
	copy(p, s)
	for i := 0; i < len(T); i++ {
		char = T[i : i+1]
		if i >= K {
			if char == T[i-K:i+1-K] {

				switch char {
				case "s":
					if s[i%K] {
						s[i%K] = false
						continue
					} else {
						s[i%K] = true
					}

				case "r":
					if r[i%K] {
						r[i%K] = false
						continue
					} else {
						r[i%K] = true

					}

				case "p":
					if p[i%K] {
						p[i%K] = false
						continue
					} else {
						p[i%K] = true

					}
				}
			} else {
				switch char {
				case "s":
					s[i%K] = true
				case "r":
					r[i%K] = true
				case "p":
					p[i%K] = true
				}

			}
		}
		switch char {
		case "s":
			dict["s"] = dict["s"] + 1
		case "r":
			dict["r"] = dict["r"] + 1
		case "p":
			dict["p"] = dict["p"] + 1
		}
	}

	res := P*dict["r"] + S*dict["p"] + R*dict["s"]
	fmt.Println(res)

}


Example test case(s):
input: 5 2
8 7 6
rsrpr

output: 27
Language: Go

package main

import "fmt"

func main() {
	for i := 0; i < 5; i++ {
		var a int
		fmt.Scan(&a)
		if a == 0 {
			fmt.Println(i + 1)
		}
	}
}


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

output: 1
Language: Go

package main

import (
	"fmt"
)

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

	if b-a == c-b {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


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

output: YES
Language: Go

package main

import "fmt"

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

	ans := 0
	if x >= 400 && x <= 599 {
		ans = 8
	}
	if x >= 600 && x <= 799 {
		ans = 7
	}
	if x >= 800 && x <= 999 {
		ans = 6
	}
	if x >= 1000 && x <= 1199 {
		ans = 5
	}
	if x >= 1200 && x <= 1399 {
		ans = 4
	}
	if x >= 1400 && x <= 1599 {
		ans = 3
	}
	if x >= 1600 && x <= 1799 {
		ans = 2
	}
	if x >= 1800 && x <= 9999 {
		ans = 1
	}

	fmt.Println(ans)
}


Example test case(s):
input: 725

output: 7
Language: Go

package main

import (
	"fmt"
	"sort"
)

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

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

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

	sort.Sort(sort.IntSlice(s))

	ans := 0
	count := 0
	for i := 0; i < n; i++ {
		if s[i] == s[i+1] {
			count++
		} else if count > 0 {
			ans += combi(count+1, 2)
			count = 0
		}
	}
	if count > 0 {
		ans += combi(count+1, 2)
	}

	fmt.Println(ans)
}

func combi(n, r int) int {
	c := 1
	for i := 1; i <= r; i++ {
		c = c * (n - i + 1) / i
	}
	return c
}


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

output: 3
Language: Go

package main

import (
	"fmt"
	"strings"
)

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

	n := strings.Count(s, "o")
	fmt.Println(700 + n*100)
}


Example test case(s):
input: oxo

output: 900
Language: Go

package main

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

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)

	N, C, K := getInt(), getInt(), getInt()
	t := make([]int, N)
	for i := 0; i < N; i++ {
		t[i] = getInt()
	}

	sort.Ints(t)

	ans := 1
	cnt := 1
	end := t[0] + K
	for i := 1; i < N; i++ {
		if cnt < C && t[i] <= end {
			cnt++

		} else {

			cnt = 1
			end = t[i] + K
			ans++
		}
	}
	out(ans)
}


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

output: 3
Language: Go

package main

import "fmt"

func main() {
	var K, X int
	fmt.Scan(&K, &X)
	if 500*K >= X {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Example test case(s):
input: 2 900

output: Yes
Language: Go

package main

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

func main() {

	N := nextInt()
	h := nextInts(N)

	dp := make([]int, N)
	for i := 0; i < N; i++ {
		dp[i] = 0
	}
	dp[1] = Abs(h[0] - h[1])

	for i := 2; i < N; i++ {
		dp[i] = Min([]int{dp[i-1] + Abs(h[i]-h[i-1]),
			dp[i-2] + Abs(h[i]-h[i-2])})
	}

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

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

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

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

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

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}

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

func (p Pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

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 nextStrings(n int) []string {
	r := make([]string, n)
	for i := 0; i < n; i++ {
		r[i] = nextString()
	}
	return r
}

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


Example test case(s):
input: 4
10 30 40 20

output: 30