iidai/codenet huggingface dataset:
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])
	}

	b := make([]int, 0, n)
	for _, v := range a {
		x := sort.Search(len(b), func(i int) bool {
			return b[i] < v
		})
		if x == len(b) {
			b = append(b, v)
		} else {
			b[x] = v
		}
	}

	fmt.Println(len(b))
}


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

output: 2
Language: Go

package main

import "fmt"

func main() {
	var x1, y1, x2, y2 int
	fmt.Scan(&x1, &y1, &x2, &y2)

	a := x2 - x1
	b := y2 - y1

	x3 := x2 - b
	y3 := y2 + a
	x4 := x1 - b
	y4 := y1 + a

	fmt.Println(x3, y3, x4, y4)
}


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

output: -1 1 -1 0
Language: Go

package main

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

func main() {
	AB := sc.nextInts()
	A := AB[0]
	B := AB[1]

	if (A+B)%2 == 0 {
		fmt.Println((A + B) / 2)
		return
	}
	fmt.Println("IMPOSSIBLE")
}

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

type Pair struct {
	first  int
	second int
}

type Queue struct {
	v []Pair
}

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

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

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

func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Example test case(s):
input: 2 16

output: 9
Language: Go

package main

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

	"sort"
	"strconv"
	"strings"
)

func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()

			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}

			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()

				break
			}
		}
	}

	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

type Console struct {
	writer *bufio.Writer
}

func NewConsole() Console {
	return Console{bufio.NewWriter(os.Stdout)}
}
func (this *Console) Printf(format string, a ...interface{}) {
	fmt.Fprintf(this.writer, format, a...)
}
func (this *Console) Println(s string) {
	fmt.Fprintln(this.writer, s)
}
func (this *Console) Close() {
	this.Flush()
}
func (this Console) Flush() {
	this.writer.Flush()
}

func PrintList(list []int) {
	con := NewConsole()
	defer con.Flush()
	for i := range list {
		if i == 0 {
			con.Printf("%d", list[i])
		} else {
			con.Printf(" %d", list[i])
		}
	}
	con.Println("")
}

func main() {
	con := NewConsole()
	defer con.Flush()

	m := make(map[int]struct{})
	lines, _ := ReadLongLines(4)
	a := strings.Split(lines[1], " ")
	for i := range a {
		n, _ := strconv.Atoi(a[i])
		m[n] = struct{}{}
	}

	result := make([]int, 0, 200000)
	b := strings.Split(lines[3], " ")
	for i := range b {
		n, _ := strconv.Atoi(b[i])
		if _, ok := m[n]; ok {
			delete(m, n)
		} else {
			m[n] = struct{}{}
		}
	}
	for k, _ := range m {
		result = append(result, k)
	}
	sort.Slice(result, func(lhs, rhs int) bool {
		return result[lhs] < result[rhs]
	})
	for j := range result {
		con.Printf("%d\n", result[j])
	}
}


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

output: 1
3
5
7
8
Language: Go

package main

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

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := nextInts(n)

	ans := 0
	for i := 0; i < n; i++ {
		l, r := i, i+1
		for r+1 < n && (a[r]-a[l])*(a[r+1]-a[r]) >= 0 {
			r++
		}
		ans++
		i = r
	}
	puts(ans)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

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

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

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

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

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

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


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

output: 2
Language: Go

package main

import "fmt"

const size = 100001

func main() {
	var n, t int
	var l, r int
	var mem [size]int
	fmt.Scan(&n)
	fmt.Scan(&t)
	for i := 0; i < n; i++ {
		fmt.Scan(&l)
		fmt.Scan(&r)
		mem[l] += 1
		mem[r] -= 1
	}
	ans := mem[0]
	for i := 1; i < t+1; i++ {
		mem[i] += mem[i-1]
		if ans < mem[i] {
			ans = mem[i]
		}
	}
	fmt.Println(ans)
}


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

output: 4
Language: Go

package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

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

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	n, k := nextInt(), nextInt()
	a := nextInts(n)

	a[0] = 0

	sum := k
	ans := 1
	for sum < n {
		sum = sum - 1 + k
		ans++
	}
	fmt.Println(ans)
}


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

output: 2
Language: Go

package main

import "fmt"

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

	for i := 0; i < 10; i++ {
		x = r*x - d
		fmt.Println(x)
	}
}


Example test case(s):
input: 2 10 20

output: 30
50
90
170
330
650
1290
2570
5130
10250
Language: Go

package main

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

func main() {
	m := make(map[int]int)
	N, M := ReadInt(), ReadInt()
	for i := 0; i < N; i++ {
		m[ReadInt()]++
	}
	for i := 0; i < M; i++ {
		B, C := ReadInt(), ReadInt()
		m[C] += B
	}
	ints := make([]int, len(m))
	for i, _ := range m {
		ints = append(ints, i)
	}
	sort.Sort(sort.Reverse(sort.IntSlice(ints)))
	rest := N
	sum := 0
	for _, i := range ints {
		num := m[i]
		if num >= rest {
			sum += rest * i
			break
		}
		sum += num * i
		rest -= num
	}
	fmt.Println(sum)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }


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

output: 14
Language: Go

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	var s []byte
	fmt.Scan(&s)
	ns := make([]int, n)
	for i := range s {
		switch s[i] {
		case 'R':
			ns[i] = 0
		case 'G':
			ns[i] = 1
		case 'B':
			ns[i] = 2
		}
	}

	rgb := make([][]int, n+1)
	rgb[0] = make([]int, 3)
	for i := 1; i <= n; i++ {
		rgb[i] = make([]int, 3)
		for j := 0; j < 3; j++ {
			rgb[i][j] = rgb[i-1][j]
		}
		rgb[i][ns[i-1]]++
	}
	var sum int
	for i := 0; i < n-2; i++ {
		for j := i + 1; j < n-1; j++ {
			if ns[i] != ns[j] {
				tn := 3 - ns[i] - ns[j]
				sum += rgb[n][tn] - rgb[j+1][tn]
				k := 2*j - i
				if k < n && ns[k] == tn {
					sum--
				}
			}
		}
	}
	fmt.Println(sum)
}


Example test case(s):
input: 4
RRGB

output: 1
Language: Go

package main

import (
	"fmt"
)

func main() {
	var a, b, c, x, sum int
	fmt.Scan(&a, &b, &c, &x)
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if 500*i+100*j+50*k == x {
					sum++
				}
			}
		}
	}
	fmt.Println(sum)
}


Example test case(s):
input: 2
2
2
100

output: 2
Language: Go

package main

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

var sc = bufio.NewScanner(os.Stdin)
var wtr = bufio.NewWriter(os.Stdout)
var N, ss, ans, A, B, C int

func main() {

	X := strings.Split(nextLine(), " ")

	N, _ = strconv.Atoi(X[0])
	A, _ = strconv.Atoi(X[1])
	B, _ = strconv.Atoi(X[2])
	C, _ = strconv.Atoi(X[3])

	arr := make([]int, N)
	dp := make([]int, N)
	ans = 10000
	ss = A + B + C

	for i := 0; i < N; i++ {
		Y := strings.Split(nextLine(), " ")

		a, _ := strconv.Atoi(Y[0])
		arr[i] = a

	}
	dfs(dp, 0, arr)

	fmt.Fprintln(wtr, ans)

	_ = wtr.Flush()
}

func dfs(dp []int, times int, arr []int) {
	if times >= N {
		ans = min(ans, calc(dp, arr))
		return
	}

	for i := 0; i < 4; i++ {
		dp[times] = i
		dfs(dp, times+1, arr)
	}
}

func calc(dp, arr []int) int {
	var cost, AA, BB, CC int

	memo := make([]int, 4)
	for i := 0; i < len(dp); i++ {
		memo[dp[i]]++
		if dp[i] == 1 {
			AA += arr[i]
		} else if dp[i] == 2 {
			BB += arr[i]
		} else if dp[i] == 3 {
			CC += arr[i]
		}
	}
	cost += abs(A-AA) + abs(B-BB) + abs(C-CC)

	for i := 1; i < 4; i++ {
		a := memo[i]
		if a < 1 {
			cost += 10000
		} else {
			cost += (a - 1) * 10
		}
	}

	return cost
}

type otosidama struct {
	x float64
	v string
}

func chmax(a *string, b string) {
	if len(*a) < len(b) {
		*a = b
	} else if len(*a) == len(b) && *a < b {
		*a = b
	}
}

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

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

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func com(a, b int) int {

	if a > b {
		return 0
	}
	return 0
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}
func sum(a []int) (sum int) {
	for _, num := range a {
		sum += num
	}
	return
}

type item struct {
	x int
}

type que []item

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

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

func (p que) Less(i, j int) bool {

	return p[i].x < p[j].x
}

func (p que) Push(in int) {
	p = append(p, item{x: in})
	sort.Sort(p)
}

func (p que) Pop() int {
	res := p[0].x
	p = p[1:]
	return res
}

func (p que) Peek() int {
	return p[0].x
}


Example test case(s):
input: 5 100 90 80
98
40
30
21
80

output: 23
Language: Go

package main

import (
	"fmt"
)

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	Inf := 1 << 62

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

	dist := make([]int, N)
	for i := 0; i < N; i++ {
		dist[i] = Inf
	}
	dist[0] = 0
	for loop := 0; loop < N; loop++ {
		for i := 0; i < M; i++ {
			if dist[a[i]-1] == Inf {
				continue
			}
			if dist[b[i]-1] > dist[a[i]-1]+c[i] {

				dist[b[i]-1] = dist[a[i]-1] + c[i]
			}
		}
	}
	ans := dist[N-1]
	navigate := make([]bool, N)
	for loop := 0; loop < N; loop++ {
		for i := 0; i < M; i++ {
			if dist[a[i]-1] == Inf {
				continue
			}
			if dist[b[i]-1] > dist[a[i]-1]+c[i] {
				dist[b[i]-1] = dist[a[i]-1] + c[i]
				navigate[b[i]-1] = true
			}
			if navigate[a[i]-1] == true {
				navigate[b[i]-1] = true
			}
		}
	}

	if navigate[N-1] {
		fmt.Println("inf")
	} else {
		fmt.Println(-ans)
	}

}


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

output: 7
Language: Go

package main

import (
	"fmt"
	"strings"
)

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

	ans := "No"
	if strings.Index(s, "C") < strings.LastIndex(s, "F") {
		ans = "Yes"
	}
	if strings.Index(s, "C") < 0 {
		ans = "No"
	}

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


Example test case(s):
input: CODEFESTIVAL

output: Yes
Language: Go

package main

import "fmt"

func main() {
	var A, B, C int
	fmt.Scanf("%d %d %d", &A, &B, &C)
	if C-A+B < 0 {
		fmt.Println("0")
	} else {
		fmt.Printf("%d\n", C-A+B)
	}
}


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

output: 1
Language: Go

package main

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

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	ans := 0.0
	for i := 0; i < n; i++ {
		tmp := 1 / float64(sc.NextInt())
		ans += tmp
	}
	fmt.Printf("%v\n", 1/ans)

}

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
10 30

output: 7.5
Language: Go

package main

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

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

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

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

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
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 main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	s := scanRunes()
	t := scanRunes()

	ans := []string{}
	for i := 0; i < len(s)-len(t)+1; i++ {
		f := true
		ss := make([]rune, len(s))
		copy(ss, s)

		for j := 0; j < len(t); j++ {
			if s[i+j] != t[j] && s[i+j] != '?' {
				f = false
				break
			} else {
				ss[i+j] = t[j]
			}
		}
		if f {
			ans = append(ans, strings.Replace(string(ss), "?", "a", -1))
		}
	}
	sort.Strings(ans)
	if len(ans) == 0 {
		fmt.Fprintln(wr, "UNRESTORABLE")
	} else {
		fmt.Fprintln(wr, ans[0])
	}
}


Example test case(s):
input: ?tc????
coder

output: atcoder
Language: Go

package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	for i := 2; i <= len(S); i = i + 2 {
		if S[0:(len(S)-i)/2] == S[(len(S)-i)/2:len(S)-i] {
			fmt.Println((len(S) - i))
			break
		}
	}
}


Example test case(s):
input: abaababaab

output: 6
Language: Go

package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10240), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner()
	N := sc.nextInt()
	S := sc.nextStr()

	if N == 0 {
	}

	if N < 4 {
		fmt.Println(0)
		return 0
	}

	var nr, nb, ng int
	for _, c := range S {
		if c == 'R' {
			nr++
		}

		if c == 'B' {
			nb++
		}

		if c == 'G' {
			ng++
		}
	}

	same := 0

	for a := 1; a < N; a++ {
		i := 0
		j := 1 * a
		k := 2 * a
		if k >= N {
			break
		}
		for k < N {

			if S[i] != S[j] && S[i] != S[k] && S[j] != S[k] {
				same++

			}

			i += 1
			j += 1
			k += 1
		}
	}

	tot := nr * nb * ng

	fmt.Println(tot - same)

	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


Example test case(s):
input: 4
RRGB

output: 1
Language: Go

package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	if len(s) >= 4 && s[0:4] == "YAKI" {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Example test case(s):
input: YAKINIKU

output: Yes
Language: Go

package main

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

func solve() {
	n := getInt()
	as := getIntSlice(n)

	xs := make([]int, n)
	for i, a := range as {
		xs[i] = a - i + 1
	}
	sort.Ints(xs)

	b := xs[n/2]
	ans := 0
	for _, x := range xs {
		ans += abs(x - b)
	}
	fmt.Fprintln(wr, ans)
}

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

const (
	inf = 1 << 60
)

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

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

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

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

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

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


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

output: 2
Language: Go

package main

import "fmt"
import "math"

func max(lhs, rhs int) int {
	return int(math.Max(float64(lhs), float64(rhs)))
}

func main() {
	var (
		N, M int
	)
	fmt.Scanf("%d %d", &N, &M)
	values := make([]int, N)
	weights := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d %d", &weights[i], &values[i])
	}

	dp := make([][]int, N+1)
	for i := 0; i < N+1; i++ {
		dp[i] = make([]int, M+1)
	}
	for i := 1; i <= N; i++ {
		for j := 0; j <= M; j++ {
			dp[i][j] = dp[i-1][j]
			if j >= weights[i-1] {
				dp[i][j] = max(dp[i][j], dp[i-1][j-weights[i-1]]+values[i-1])
			}
		}
	}
	fmt.Println(dp[N][M])
}


Example test case(s):
input: 3 8
3 30
4 50
5 60

output: 90
Language: Go

package main

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

type scanner struct{ *bufio.Scanner }

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *scanner) IntSlice(l int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := range sl {
		sl[i] = s.Int()
	}
	return sl
}

func iabs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func solve(n int, heights []int) int {
	t := make([]int, n+1, n+1)
	for i := range t {
		t[i] = math.MaxInt64
	}

	t[0] = 0
	for i := 1; i < n; i++ {
		if v := t[i-1] + iabs(heights[i]-heights[i-1]); v < t[i] {
			t[i] = v
		}
		if 1 < i {
			if v := t[i-2] + iabs(heights[i]-heights[i-2]); v < t[i] {
				t[i] = v
			}
		}
	}

	return t[n-1]
}

func main() {
	sc := newScanner(os.Stdin)
	n := sc.Int()
	heights := sc.IntSlice(n)
	ans := solve(n, heights)
	fmt.Println(ans)
}


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

output: 30
Language: Go

package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func NextIntsLine() []int {
	ints := []int{}
	intsStr := NextLine()
	tmp := strings.Split(intsStr, " ")
	for _, s := range tmp {
		integer, _ := strconv.Atoi(s)
		ints = append(ints, integer)
	}
	return ints
}

func NextStringsLine() []string {
	strs := []string{}
	stringsStr := NextLine()
	tmp := strings.Split(stringsStr, " ")
	for _, s := range tmp {
		strs = append(strs, s)
	}
	return strs
}

func NextRunesLine() []rune {
	return []rune(NextLine())
}

func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}
	fa := float64(a)
	fe := float64(e)
	fanswer := math.Pow(fa, fe)
	return int(fanswer)
}

func AbsInt(a int) int {
	fa := float64(a)
	fanswer := math.Abs(fa)
	return int(fanswer)
}

func DeleteElement(s []int, i int) []int {
	if i < 0 || len(s) <= i {
		panic(errors.New("[index error]"))
	}

	n := make([]int, 0, len(s)-1)
	n = append(n, s[:i]...)
	n = append(n, s[i+1:]...)
	return n
}

func Concat(s, t []rune) []rune {
	n := make([]rune, 0, len(s)+len(t))
	n = append(n, s...)
	n = append(n, t...)
	return n
}

var x int

func main() {
	tmp := NextIntsLine()
	x = tmp[0]
	i := 1
	sum := 0
	for {
		sum += i
		if sum >= x {
			break
		}
		i++
	}
	fmt.Println(i)
}


Example test case(s):
input: 6

output: 3
Language: Go

package main

import (
	"fmt"
)

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


Example test case(s):
input: 2

output: 14