Language: C

package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

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

type task struct {
	day, price int
}

type theap []task

func (h theap) Len() int           { return len(h) }
func (h theap) Less(i, j int) bool { return h[i].price > h[j].price } // maxにするためにあえて変更
func (h theap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *theap) Push(x interface{}) {
	*h = append(*h, x.(task))
}

func (h *theap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]

	return x
}

func main() {
	sc.Split(bufio.ScanWords)
	N, M := scanInt(), scanInt()

	jobs := make(map[int][]int)
	for i := 0; i < N; i++ {
		A, B := scanInt(), scanInt()
		jobs[A] = append(jobs[A], B)
	}

	ans := 0
	H := make(theap, N)
	heap.Init(&H)
	for day := 1; day <= M; day++ {
		for _, t := range jobs[day] {
			heap.Push(&H, task{day, t})
		}
		selected := heap.Pop(&H).(task)
		ans += selected.price
	}
	fmt.Println(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:22:1: error: unknown type name 'type'; did you mean 'typeof'?
   22 | type task struct {
      | ^~~~
      | typeof
main.c:22:10: error: expected ';' before 'struct'
   22 | type task struct {
      |          ^~~~~~~
      |          ;
main.c:23:9: error: expected specifier-qualifier-list before 'day'
   23 |         day, price int
      |         ^~~
main.c:26:6: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'theap'
   26 | type theap []task
      |      ^~~~~
main.c:29:7: error: unknown type name 'h'
   29 | func (h theap) Less(i, j int) bool { return h[i].price > h[j].price } // maxにするためにあえて変更
      |       ^
main.c:30:7: error: unknown type name 'h'
   30 | func (h theap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }
      |       ^
main.c:32:7: error: unknown type name 'h'
   32 | func (h *theap) Push(x interface{}) {
      |       ^
main.c:32:35: error: expected identifier or '(' before ')' token
   32 | func (h *theap) Push(x interface{}) {
      |                                   ^
main.c:36:7: error: unknown type name 'h'
   36 | func (h *theap) Pop() interface{} {
      |       ^
main.c:36:35: error: expected identifier or '(' before '{' token
   36 | func (h *theap) Pop() interface{} {
      |                                   ^
main.c:45:1: error: unknown type name 'func'
   45 | func main() {
      | ^~~~
main.c: In function 'main':
main.c:46:9: error: 'sc' undeclared (first use in this function)
   46 |         sc.Split(bufio.ScanWords)
      |         ^~
main.c:46:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:46:18: error: 'bufio' undeclared (first use in this function)
   46 |         sc.Split(bufio.ScanWords)
      |                  ^~~~~
main.c:46:34: error: expected ';' before 'N'
   46 |         sc.Split(bufio.ScanWords)
      |                                  ^
      |                                  ;
   47 |         N, M := scanInt(), scanInt()
      |         ~                         
main.c:50:21: error: 'i' undeclared (first use in this function)
   50 |         for i := 0; i < N; i++ {
      |                     ^
main.c:50:25: error: 'N' undeclared (first use in this function)
   50 |         for i := 0; i < N; i++ {
      |                         ^
main.c:50:31: error: expected ';' before '{' token
   50 |         for i := 0; i < N; i++ {
      |                               ^~
      |                               ;
main.c:58:23: error: 'day' undeclared (first use in this function)
   58 |         for day := 1; day <= M; day++ {
      |                       ^~~
main.c:58:30: error: 'M' undeclared (first use in this function)
   58 |         for day := 1; day <= M; day++ {
      |                              ^
main.c:58:38: error: expected ';' before '{' token
   58 |         for day := 1; day <= M; day++ {
      |                                      ^~
      |                                      ;