Language: C

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)
	K := readInt()
	sum := int64(0)
	for i := int64(1); i <= K; i++ {
		for j := int64(1); j <= K; j++ {
			for k := int64(1); k <= K; k++ {
				a := i
				ss := []int64{j, k}
				for l := 0; l < len(ss); l++ {
					a = Gcd(a, ss[l])
				}
				sum += a
			}
		}
	}
	fmt.Println(sum)
}
func min(a int64, b int64) int64 {
	return int64(math.Min(float64(a), float64(b)))
}
func mins(a int64, b int64, c int64) int64 {
	s := []int64{a, b, c}
	Int64s(s)
	return s[0]
}
func maxs(a int64, b int64, c int64) int64 {
	s := []int64{a, b, c}
	Int64s(s)
	return s[2]
}

/*==========================================
 *             Library
 *==========================================*/
func Gcd(a int64, b int64) int64 {
	if a > b {
		if a%b == 0 {
			return b
		}
		return Gcd(b, (a % b))
	} else {
		if b%a == 0 {
			return a
		}
		return Gcd(a, (b % a))
	}
}
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
// }


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:20:1: error: unknown type name 'type'; did you mean 'typeof'?
   20 | type pairs []pair
      | ^~~~
      | typeof
main.c:20:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'pair'
   20 | type pairs []pair
      |              ^~~~
main.c:20:14: error: unknown type name 'pair'
main.c:26:7: error: unknown type name 'slice'
   26 | func (slice pairs) Less(i, j int) bool {
      |       ^~~~~
main.c:30:7: error: unknown type name 'slice'
   30 | func (slice pairs) Swap(i, j int) {
      |       ^~~~~
main.c:35:1: error: unknown type name 'type'; did you mean 'typeof'?
   35 | type Int64Slice []int64
      | ^~~~
      | typeof
main.c:35:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int64'
   35 | type Int64Slice []int64
      |                   ^~~~~
main.c:35:19: error: unknown type name 'int64'; did you mean 'int'?
   35 | type Int64Slice []int64
      |                   ^~~~~
      |                   int
main.c:41:7: error: unknown type name 'slice'
   41 | func (slice Int64Slice) Less(i, j int) bool {
      |       ^~~~~
main.c:45:7: error: unknown type name 'slice'
   45 | func (slice Int64Slice) Swap(i, j int) {
      |       ^~~~~
main.c:48:1: error: unknown type name 'func'
   48 | func Int64s(a []int64)                    { sort.Sort(Int64Slice(a)) }
      | ^~~~
main.c:48:13: error: unknown type name 'a'
   48 | func Int64s(a []int64)                    { sort.Sort(Int64Slice(a)) }
      |             ^
main.c:49:1: error: unknown type name 'func'
   49 | func Int64sSliceAreSorted(a []int64) bool { return sort.IsSorted(Int64Slice(a)) }
      | ^~~~
main.c:49:27: error: unknown type name 'a'
   49 | func Int64sSliceAreSorted(a []int64) bool { return sort.IsSorted(Int64Slice(a)) }
      |                           ^
main.c:52:23: error: expected ')' before '=' token
   52 |         initialBufSize = 1e4
      |                       ^~
      |                       )
main.c:61:9: warning: data definition has no type or storage class
   61 |         dj      = []int64{0, -1, 0, 1}
      |         ^~
main.c:61:9: error: type defaults to 'int' in declaration of 'dj' [-Wimplicit-int]
main.c:61:19: error: expected expression before '[' token
   61 |         dj      = []int64{0, -1, 0, 1}
      |                   ^
main.c:62:1: error: expected identifier or '(' before ')' token
   62 | )
      | ^
main.c:84:1: error: unknown type name 'func'
   84 | func min(a int64, b int64) int64 {
      | ^~~~
main.c:84:10: error: unknown type name 'a'
   84 | func min(a int64, b int64) int64 {
      |          ^
main.c:84:19: error: unknown type name 'b'
   84 | func min(a int64, b int64) int64 {
      |                   ^
main.c:87:1: error: unknown type name 'func'
   87 | func mins(a int64, b int64, c int64) int64 {
      | ^~~~
main.c:87:11: error: unknown type name 'a'
   87 | func mins(a int64, b int64, c int64) int64 {
      |           ^
main.c:87:20: error: unknown type name 'b'
   87 | func mins(a int64, b int64, c int64) int64 {
      |                    ^
main.c:87:29: error: unknown type name 'c'
   87 | func mins(a int64, b int64, c int64) int64 {
      |                             ^
main.c:92:1: error: unknown type name 'func'
   92 | func maxs(a int64, b int64, c int64) int64 {
      | ^~~~
main.c:92:11: error: unknown type name 'a'
   92 | func maxs(a int64, b int64, c int64) int64 {
      |           ^
main.c:92:20: error: unknown type name 'b'
   92 | func maxs(a int64, b int64, c int64) int64 {
      |                    ^
main.c:92:29: error: unknown type name 'c'
   92 | func maxs(a int64, b int64, c int64) int64 {
      |                             ^
main.c:101:1: error: unknown type name 'func'
  101 | func Gcd(a int64, b int64) int64 {
      | ^~~~
main.c:101:10: error: unknown type name 'a'
  101 | func Gcd(a int64, b int64) int64 {
      |          ^
main.c:101:19: error: unknown type name 'b'
  101 | func Gcd(a int64, b int64) int64 {
      |                   ^
main.c:114:1: error: unknown type name 'func'
  114 | func NextPermutation(x sort.Interface) bool {
      | ^~~~
main.c:114:22: error: unknown type name 'x'
  114 | func NextPermutation(x sort.Interface) bool {
      |                      ^
main.c:137:1: error: unknown type name 'func'
  137 | func doubleAry(h int64, w int64, init int64) (res [][]int64) {
      | ^~~~
main.c:137:16: error: unknown type name 'h'
  137 | func doubleAry(h int64, w int64, init int64) (res [][]int64) {
      |                ^
main.c:137:25: error: unknown type name 'w'
  137 | func doubleAry(h int64, w int64, init int64) (res [][]int64) {
      |                         ^
main.c:137:34: error: unknown type name 'init'; did you mean 'int'?
  137 | func doubleAry(h int64, w int64, init int64) (res [][]int64) {
      |                                  ^~~~
      |                                  int
main.c:148:1: error: unknown type name 'func'
  148 | func aryEq(a []int64, b []int64) bool {
      | ^~~~
main.c:148:12: error: unknown type name 'a'
  148 | func aryEq(a []int64, b []int64) bool {
      |            ^
main.c:148:23: error: unknown type name 'b'
  148 | func aryEq(a []int64, b []int64) bool {
      |                       ^
main.c:152:1: error: unknown type name 'func'
  152 | func clone(n []int64) (r []int64) {
      | ^~~~
main.c:152:12: error: unknown type name 'n'
  152 | func clone(n []int64) (r []int64) {
      |            ^
main.c:159:1: error: unknown type name 'func'
  159 | func write(s string) {
      | ^~~~
main.c:159:12: error: unknown type name 's'
  159 | func write(s string) {
      |            ^
main.c:163:1: error: unknown type name 'func'
  163 | func print() {
      | ^~~~
main.c: In function 'print':
main.c:164:9: error: 'writer' undeclared (first use in this function)
  164 |         writer.Flush()
      |         ^~~~~~
main.c:164:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:164:23: error: expected ';' before '}' token
  164 |         writer.Flush()
      |                       ^
      |                       ;
  165 | }
      | ~                      
main.c: At top level:
main.c:168:1: error: unknown type name 'func'
  168 | func readLine() (s string) {
      | ^~~~
main.c:168:18: error: unknown type name 's'
  168 | func readLine() (s string) {
      |                  ^
main.c:175:1: error: unknown type name 'func'
  175 | func readInt() (read int64) {
      | ^~~~
main.c:175:17: error: unknown type name 'read'
  175 | func readInt() (read int64) {
      |                 ^~~~
main.c:184:1: error: unknown type name 'func'
  184 | func readFloat() (read float64) {
      | ^~~~
main.c:184:19: error: unknown type name 'read'
  184 | func readFloat() (read float64) {
      |                   ^~~~
main.c:193:1: error: unknown type name 'func'
  193 | func readRunes() (read []rune) {
      | ^~~~
main.c:193:19: error: unknown type name 'read'
  193 | func readRunes() (read []rune) {
      |                   ^~~~
main.c:201:1: error: unknown type name 'func'
  201 | func readString() (read string) {
      | ^~~~
main.c:201:20: error: unknown type name 'read'
  201 | func readString() (read string) {
      |                    ^~~~
main.c:207:1: error: unknown type name 'func'
  207 | func readStrings() (read []string) {
      | ^~~~
main.c:207:21: error: unknown type name 'read'
  207 | func readStrings() (read []string) {
      |                     ^~~~
main.c:215:1: error: unknown type name 'func'
  215 | func s2i(s string) int64 {
      | ^~~~
main.c:215:10: error: unknown type name 's'
  215 | func s2i(s string) int64 {
      |          ^
main.c:223:1: error: unknown type name 'func'
  223 | func i2s(i int64) string {
      | ^~~~
main.c:223:10: error: unknown type name 'i'
  223 | func i2s(i int64) string {
      |          ^
main.c:228:1: error: unknown type name 'func'
  228 | func s2f(s string) float64 {
      | ^~~~
main.c:228:10: error: unknown type name 's'
  228 | func s2f(s string) float64 {
      |          ^
main.c:236:1: error: unknown type name 'func'
  236 | func abs(i int64) int64 {
      | ^~~~
main.c:236:10: error: unknown type name 'i'
  236 | func abs(i int64) int64 {
      |          ^
main.c:240:1: error: unknown type name 'func'
  240 | func sum(i []int64) int64 {
      | ^~~~
main.c:240:10: error: unknown type name 'i'
  240 | func sum(i []int64) int64 {
      |          ^
main.c:248:1: error: unknown type name 'func'
  248 | func split(s string) []string {
      | ^~~~
main.c:248:12: error: unknown type name 's'
  248 | func split(s string) []string {
      |            ^
main.c:252:1: error: unknown type name 'func'
  252 | func strAry2intAry(strs []string) []int64 {
      | ^~~~
main.c:252:20: error: unknown type name 'strs'
  252 | func strAry2intAry(strs []string) []int64 {
      |                    ^~~~
main.c:261:1: error: unknown type name 'func'
  261 | func intAry2strAry(nums []int64) []string {
      | ^~~~
main.c:261:20: error: unknown type name 'nums'
  261 | func intAry2strAry(nums []int64) []string {
      |                    ^~~~
main.c:270:1: error: unknown type name 'func'
  270 | func ary2str(strs []string) string {
      | ^~~~
main.c:270:14: error: unknown type name 'strs'
  270 | func ary2str(strs []string) string {
      |              ^~~~
main.c:274:1: error: unknown type name 'func'
  274 | func reverse(res []int64) []int64 {
      | ^~~~
main.c:274:14: error: unknown type name 'res'
  274 | func reverse(res []int64) []int64 {
      |              ^~~
main.c:280:1: error: unknown type name 'func'
  280 | func reverseStr(res []string) []string {
      | ^~~~
main.c:280:17: error: unknown type name 'res'
  280 | func reverseStr(res []string) []string {
      |                 ^~~
main.c:287:1: error: unknown type name 'func'
  287 | func ini(res []int, init int) {
      | ^~~~
main.c:287:10: error: unknown type name 'res'
  287 | func ini(res []int, init int) {
      |          ^~~
main.c:287:21: error: