Language: C

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

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

type data struct {
	val, pos int
}

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

	N := getInt()
	a := make([]data, N)
	for i := 0; i < N; i++ {
		a[i].val = getInt()
		a[i].pos = i
	}

	sort.Slice(a, func(i, j int) bool {
		return a[i].val > a[j].val
	})
	// out(a)

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

	ans := 0
	for l := 0; l <= N; l++ {
		for r := 0; r <= N; r++ {
			if l+r == N {
				// out(dp[l])
				ans = max(ans, dp[l][r])
				break
			}
			v, i := a[l+r].val, a[l+r].pos
			dp[l+1][r] = max(dp[l+1][r], dp[l][r]+asub(l, i)*v)
			dp[l][r+1] = max(dp[l][r+1], dp[l][r]+asub(N-1-r, i)*v)
		}
	}
	out(ans)
}


Compiler output:
main.c:1:1: error: unknown type name 'package'
    1 | package main
      | ^~~~~~~
main.c:3:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'import'
    3 | import (
      | ^~~~~~
main.c:11:26: error: expected identifier or '(' before ')' token
   11 | func out(x ...interface{}) {
      |                          ^
main.c:15:1: error: unknown type name 'var'
   15 | var sc = bufio.NewScanner(os.Stdin)
      | ^~~
main.c:15:10: error: 'bufio' undeclared here (not in a function)
   15 | var sc = bufio.NewScanner(os.Stdin)
      |          ^~~~~
main.c:15:27: error: 'os' undeclared here (not in a function)
   15 | var sc = bufio.NewScanner(os.Stdin)
      |                           ^~
main.c:17:1: error: expected ',' or ';' before 'func'
   17 | func getInt() int {
      | ^~~~
main.c:26:1: error: unknown type name 'func'
   26 | func getString() string {
      | ^~~~
main.c: In function 'getString':
main.c:26:18: error: expected declaration specifiers before 'string'
   26 | func getString() string {
      |                  ^~~~~~
main.c:32:1: error: unknown type name 'func'
   32 | func max(a, b int) int {
      | ^~~~
main.c:32:14: error: expected ')' before 'int'
   32 | func max(a, b int) int {
      |              ^~~~
      |              )
main.c:39:1: error: unknown type name 'func'
   39 | func min(a, b int) int {
      | ^~~~
main.c:39:14: error: expected ')' before 'int'
   39 | func min(a, b int) int {
      |              ^~~~
      |              )
main.c:46:1: error: unknown type name 'func'
   46 | func asub(a, b int) int {
      | ^~~~
main.c:46:15: error: expected ')' before 'int'
   46 | func asub(a, b int) int {
      |               ^~~~
      |               )
main.c:53:1: error: unknown type name 'func'
   53 | func abs(a int) int {
      | ^~~~
main.c:53:10: error: unknown type name 'a'
   53 | func abs(a int) int {
      |          ^
main.c:60:1: error: unknown type name 'type'; did you mean 'typeof'?
   60 | type data struct {
      | ^~~~
      | typeof
main.c:60:11: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'struct'
   60 | type data struct {
      |           ^~~~~~
main.c:64:1: error: unknown type name 'func'
   64 | func main() {
      | ^~~~
main.c:64:13: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   64 | func main() {
      |             ^
main.c:99: error: expected '{' at end of input