Language: C++

import java.io.*
import java.lang.*
import java.util.*
import kotlin.collections.*

var kin = InputReader(getInput())
val kout = PrintWriter(System.out)

fun solve() {
    val NEG_INF = -(1e16).toLong()
    val n = kin.int()
    val a = kin.listLong(n)
    val mem = HashMap<Pair<Int, Int>, Long>()
    fun dp(i: Int, need: Int): Long {
        val pr = Pair(i, need)
        if (!mem.containsKey(pr)) {
            val mx = (i + 2) / 2
            mem[pr] = when {
                need < 0 || need > mx -> NEG_INF
                i < 0 -> 0
                else -> maxOf(dp(i-2, need-1) + a[i], dp(i-1, need))
            }
        }
        return mem.getValue(pr)
    }
    kout.println(dp(n-1, n/2))
}

fun main() {
    kout.use { solve() }
}

class InputReader(stream: InputStream) {
    private val reader = BufferedReader(InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer? = null

    fun str(): String {
        while (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun <R> list(n: Int, parse: (String) -> R): List<R> {
        return (1..n).map { parse.invoke(str()) }
    }

    fun int() = str().toInt()
    fun listInt(n: Int) = list(n) { it.toInt() }
    fun long() = str().toLong()
    fun listLong(n: Int) = list(n) { it.toLong() }
}

fun getInput(): InputStream {
    val inputFile = try {
        System.getProperty("compet.input")
    } catch (ex: Exception) {
        null
    } ?: return System.`in`

    return FileInputStream({}::class.java.classLoader.getResource(inputFile).file)
}



Compiler output:
a.cc:45:17: error: too many decimal points in number
   45 |         return (1..n).map { parse.invoke(str()) }
      |                 ^~~~
a.cc:59:24: error: stray '`' in program
   59 |     } ?: return System.`in`
      |                        ^
a.cc:59:27: error: stray '`' in program
   59 |     } ?: return System.`in`
      |                           ^
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.*
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:29:1: error: 'fun' does not name a type
   29 | fun main() {
      | ^~~
a.cc:33:25: error: found ':' in nested-name-specifier, expected '::'
   33 | class InputReader(stream: InputStream) {
      |                         ^
      |                         ::
a.cc:33:19: error: 'stream' has not been declared
   33 | class InputReader(stream: InputStream) {
      |                   ^~~~~~
a.cc:33:38: error: variable 'InputReader InputStream' has initializer but incomplete type
   33 | class InputReader(stream: InputStream) {
      |                                      ^
a.cc:34:5: error: expected primary-expression before 'private'
   34 |     private val reader = BufferedReader(InputStreamReader(stream), 32768)
      |     ^~~~~~~
a.cc:34:5: error: expected '}' before 'private'
a.cc:33:40: note: to match this '{'
   33 | class InputReader(stream: InputStream) {
      |                                        ^
a.cc:34:5: error: expected ',' or ';' before 'private'
   34 |     private val reader = BufferedReader(InputStreamReader(stream), 32768)
      |     ^~~~~~~
a.cc:44:5: error: 'fun' does not name a type
   44 |     fun <R> list(n: Int, parse: (String) -> R): List<R> {
      |     ^~~
a.cc:48:5: error: 'fun' does not name a type
   48 |     fun int() = str().toInt()
      |     ^~~
a.cc:50:5: error: 'fun' does not name a type
   50 |     fun long() = str().toLong()
      |     ^~~
a.cc:52:1: error: expected declaration before '}' token
   52 | }
      | ^
a.cc:54:1: error: 'fun' does not name a type
   54 | fun getInput(): InputStream {
      | ^~~