Language: C++

package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

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

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), math.MaxInt32)
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		return []byte(f1())
	}
	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 printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

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

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

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

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

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

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

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

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

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

func main() {
	defer stdout.Flush()
	S := readBytes()
	N := len(S) + 1

	a := make([]int, N)

	for i := 0; i < N-1; i++ {
		if S[i] == '<' {
			a[i+1] = a[i] + 1
		}
	}

	for i := N - 1; 0 < i; i-- {
		if S[i-1] == '>' {
			a[i-1] = max(a[i]+1, a[i-1])
		}
	}

	var ans int
	for i := range a {
		ans += a[i]
	}
	println(ans)
}

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


Compiler output:
a.cc:1:1: error: 'package' does not name a type
    1 | package main
      | ^~~~~~~
a.cc:23:1: error: 'func' does not name a type
   23 | func newReadString(ior io.Reader) (func() string, func() []byte) {
      | ^~~~
a.cc:40:1: error: 'func' does not name a type
   40 | func readInt() int {
      | ^~~~
a.cc:44:1: error: 'func' does not name a type
   44 | func readInt64() int64 {
      | ^~~~
a.cc:52:1: error: 'func' does not name a type
   52 | func readFloat64() float64 {
      | ^~~~
a.cc:60:1: error: 'func' does not name a type
   60 | func printf(f string, args ...interface{}) (int, error) {
      | ^~~~
a.cc:60:42: error: expected unqualified-id before ')' token
   60 | func printf(f string, args ...interface{}) (int, error) {
      |                                          ^
a.cc:64:1: error: 'func' does not name a type
   64 | func println(args ...interface{}) (int, error) {
      | ^~~~
a.cc:64:33: error: expected unqualified-id before ')' token
   64 | func println(args ...interface{}) (int, error) {
      |                                 ^
a.cc:68:1: error: 'func' does not name a type
   68 | func eprintln(args ...interface{}) (int, error) {
      | ^~~~
a.cc:68:34: error: expected unqualified-id before ')' token
   68 | func eprintln(args ...interface{}) (int, error) {
      |                                  ^
a.cc:72:1: error: 'func' does not name a type
   72 | func eprintf(f string, args ...interface{}) (int, error) {
      | ^~~~
a.cc:72:43: error: expected unqualified-id before ')' token
   72 | func eprintf(f string, args ...interface{}) (int, error) {
      |                                           ^
a.cc:76:1: error: 'func' does not name a type
   76 | func min(a, b int) int {
      | ^~~~
a.cc:83:1: error: 'func' does not name a type
   83 | func min64(a, b int64) int64 {
      | ^~~~
a.cc:90:1: error: 'func' does not name a type
   90 | func max(a, b int) int {
      | ^~~~
a.cc:97:1: error: 'func' does not name a type
   97 | func max64(a, b int64) int64 {
      | ^~~~
a.cc:104:1: error: 'func' does not name a type
  104 | func abs(a int) int {
      | ^~~~
a.cc:111:1: error: 'func' does not name a type
  111 | func abs64(a int64) int64 {
      | ^~~~
a.cc:118:1: error: 'func' does not name a type
  118 | func gcd(a, b int) int {
      | ^~~~
a.cc:125:1: error: 'func' does not name a type
  125 | func gcd64(a, b int64) int64 {
      | ^~~~
a.cc:139:1: error: 'func' does not name a type
  139 | func main() {
      | ^~~~