Language: C++

#=== ここからテンプレート ===========

import strutils, sequtils, math, algorithm, nre, tables, macros
when NimMajor <= 0 and NimMinor >= 19:
  import sugar
else:
  import future

type
  si = seq[int]
  ssi = seq[seq[int]]
  sf = seq[float]
  ssf = seq[seq[float]]

proc r(): string = stdin.readLine
proc ri(): int = r().parseInt
proc rsi(): seq[int] = r().split.map(parseInt)
proc rf(): float = r().parseFloat
proc rsf(): seq[float] = r().split.map(parseFloat)
proc rn(n: int): seq[string] =
  result = @[]
  for i in 1..n:
    result.add(r())
proc rin(n: int): seq[int] =
  result = @[]
  for i in 1..n:
    result.add(ri())
proc rsin(n: int): seq[seq[int]] =
  result = @[]
  for i in 1..n:
    result.add(rsi())
proc range(x, y: int): seq[int] =
  toSeq(x..y-1)
proc range(x: int): seq[int] =
  toSeq(0..x-1)
proc discardableId[T](x: T): T {.discardable.} =
  return x
template `:=`(x, y: untyped): untyped =
  when defined(x):
    (x = y; discardableId(x))
  else:
    (var x = y; discardableId(x))
proc count[T](co: openArray[T]; obj: T): int =
  for itm in items(co):
    if itm == obj:
      inc result
proc divmod(x, y: SomeInteger): (int, int) =
  (x div y, x mod y)
proc `min=`[T](x: var T; y: T): bool {.discardable.} =
  if x > y:
    x = y
    return true
  else:
    return false
proc `max=`[T](x: var T; y: T): bool {.discardable.} =
  if x < y:
    x = y
    return true
  else:
    return false

type
  UnionFind[T] = ref object
    when T is int:
      par: seq[int]
      siz: seq[int]
    else:
      par: Table[T, T]
      siz: Table[T, int]

proc find[T](t: UnionFind[T]; o: T): T =
  if t.par[o] == o: return o
  t.par[o] = t.find(t.par[o])
  return t.par[o]
proc union[T](t: UnionFind[T]; x, y: T) =
  let (rx, ry) = (t.find(x), t.find(y))
  if rx == ry: return
  if t.siz[rx] < t.siz[ry]:
    t.par[rx] = ry
    t.siz[ry] += t.siz[rx]
  else:
    t.par[ry] = rx
    t.siz[rx] += t.siz[ry]
proc isSame[T](t: UnionFind[T]; x, y: T): bool =
  return t.find(x) == t.find(y)
proc size[T](t: UnionFind[T]; x: T): int =
  return t.siz[t.find(x)]
proc initUF(size: int): UnionFind[int] =
  return UnionFind[int](par: range(size), siz: newSeqWith(size, 1))
proc initUF[T](field: openArray[T]): UnionFind[T] =
  var
    par = initTable[T, T]()
    siz = initTable[T, int]()
  for t in field:
    par[t] = t
    siz[t] = 1
  return UnionFind[T](par: par, siz: siz)

when NimMajor <= 0 and NimMinor <= 17:
  iterator pairs(n: NimNode): (int, NimNode) {.inline.} =
    for i in 0 ..< n.len:
      yield (i, n[i])

when NimMajor <= 0 and NimMinor <= 18:
  macro parseInnerType(x: NimNode): untyped =
    newIdentNode("parse" & x[1][1].repr)
else:
  macro parseInnerType(x: typedesc): untyped =
    newIdentNode("parse" & x.getType[1][1].repr)

macro inputAsTuple(ty: untyped): untyped =
  result = nnkStmtListExpr.newTree()
  t := genSym()
  result.add quote do: (let `t` = stdin.readLine.split)
  p := nnkPar.newTree()
  for i, typ in ty.pairs:
    if typ.repr == "string":
      p.add quote do: `t`[`i`]
    else:
      parsefn := newIdentNode("parse" & typ.repr)
      p.add quote do: `t`[`i`].`parsefn`
  result.add p

template inputAsType(ty: static[typedesc]): auto =
  when ty is seq:
    when ty is seq[string]:
      stdin.readLine.split
    else:
      when NimMajor <= 0 and NimMinor <= 18:
        stdin.readLine.split.map(parseInnerType(ty.getType))
      else:
        stdin.readLine.split.map(parseInnerType(ty))
  elif ty is string:
    stdin.readLine
  elif ty is tuple:
    inputAsTuple(ty)
  else:
    stdin.readLine.`parse ty`

macro input(query: untyped): untyped =
  doAssert query.kind == nnkStmtList
  result = nnkStmtList.newTree()
  letSect := nnkLetSection.newTree()
  for defs in query:
    if defs[0].kind == nnkIdent:
      tmp := nnkIdentDefs.newTree(defs[0], newEmptyNode())
      typ := defs[1][0]
      tmp.add quote do: inputAsType(`typ`)
      letSect.add tmp
    elif defs[0].kind == nnkPar:
      vt := nnkVarTuple.newTree()
      for id in defs[0]:
        vt.add id
      vt.add newEmptyNode()
      sle := nnkStmtListExpr.newTree()
      t := genSym()
      sle.add quote do: (let `t` = stdin.readLine.split)
      p := nnkPar.newTree()
      if defs[1][0].kind == nnkPar:
        for i, typ in defs[1][0].pairs:
          if typ.repr == "string":
            p.add quote do: `t`[`i`]
          else:
            parsefn := newIdentNode("parse" & typ.repr)
            p.add quote do: `t`[`i`].`parsefn`
      else:
        typ := defs[1][0]
        if typ.repr == "string":
          for i in 0..<defs[0].len:
            p.add quote do: `t`[`i`]
        else:
          parsefn := newIdentNode("parse" & typ.repr)
          for i in 0..<defs[0].len:
            p.add quote do: `t`[`i`].`parsefn`
      sle.add p
      vt.add sle
      letSect.add vt
    elif defs[0].kind == nnkBracketExpr:
      ids := nnkIdentDefs.newTree(defs[0][0], newEmptyNode())
      cnt := defs[0][1]
      typ := defs[1][0]
      val := (quote do: newSeqWith(`cnt`, inputAsType(`typ`)))
      ids.add val
      letSect.add ids
  result.add letSect

#=== ここまでテンプレート ===========


input:
  (m, d): int

var res = 0
for i in 22..d:
  let (d1, d10) = (i mod 10, i div 10)
  if d1 >= 2 and d10 >= 2 and d1 * d10 <= m:
    res.inc

echo res


Compiler output:
a.cc:1:2: error: invalid preprocessing directive #==
    1 | #=== ここからテンプレート ===========
      |  ^~
a.cc:21:12: error: stray '@' in program
   21 |   result = @[]
      |            ^
a.cc:22:12: error: too many decimal points in number
   22 |   for i in 1..n:
      |            ^~~~
a.cc:25:12: error: stray '@' in program
   25 |   result = @[]
      |            ^
a.cc:26:12: error: too many decimal points in number
   26 |   for i in 1..n:
      |            ^~~~
a.cc:29:12: error: stray '@' in program
   29 |   result = @[]
      |            ^
a.cc:30:12: error: too many decimal points in number
   30 |   for i in 1..n:
      |            ^~~~
a.cc:35:9: error: too many decimal points in number
   35 |   toSeq(0..x-1)
      |         ^~~~
a.cc:38:10: error: stray '`' in program
   38 | template `:=`(x, y: untyped): untyped =
      |          ^
a.cc:38:13: error: stray '`' in program
   38 | template `:=`(x, y: untyped): untyped =
      |             ^
a.cc:49:6: error: stray '`' in program
   49 | proc `min=`[T](x: var T; y: T): bool {.discardable.} =
      |      ^
a.cc:49:11: error: stray '`' in program
   49 | proc `min=`[T](x: var T; y: T): bool {.discardable.} =
      |           ^
a.cc:55:6: error: stray '`' in program
   55 | proc `max=`[T](x: var T; y: T): bool {.discardable.} =
      |      ^
a.cc:55:11: error: stray '`' in program
   55 | proc `max=`[T](x: var T; y: T): bool {.discardable.} =
      |           ^
a.cc:114:29: error: stray '`' in program
  114 |   result.add quote do: (let `t` = stdin.readLine.split)
      |                             ^
a.cc:114:31: error: stray '`' in program
  114 |   result.add quote do: (let `t` = stdin.readLine.split)
      |                               ^
a.cc:118:23: error: stray '`' in program
  118 |       p.add quote do: `t`[`i`]
      |                       ^
a.cc:118:25: error: stray '`' in program
  118 |       p.add quote do: `t`[`i`]
      |                         ^
a.cc:118:27: error: stray '`' in program
  118 |       p.add quote do: `t`[`i`]
      |                           ^
a.cc:118:29: error: stray '`' in program
  118 |       p.add quote do: `t`[`i`]
      |                             ^
a.cc:121:23: error: stray '`' in program
  121 |       p.add quote do: `t`[`i`].`parsefn`
      |                       ^
a.cc:121:25: error: stray '`' in program
  121 |       p.add quote do: `t`[`i`].`parsefn`
      |                         ^
a.cc:121:27: error: stray '`' in program
  121 |       p.add quote do: `t`[`i`].`parsefn`
      |                           ^
a.cc:121:29: error: stray '`' in program
  121 |       p.add quote do: `t`[`i`].`parsefn`
      |                             ^
a.cc:121:32: error: stray '`' in program
  121 |       p.add quote do: `t`[`i`].`parsefn`
      |                                ^
a.cc:121:40: error: stray '`' in program
  121 |       p.add quote do: `t`[`i`].`parsefn`
      |                                        ^
a.cc:138:20: error: stray '`' in program
  138 |     stdin.readLine.`parse ty`
      |                    ^
a.cc:138:29: error: stray '`' in program
  138 |     stdin.readLine.`parse ty`
      |                             ^
a.cc:148:37: error: stray '`' in program
  148 |       tmp.add quote do: inputAsType(`typ`)
      |                                     ^
a.cc:148:41: error: stray '`' in program
  148 |       tmp.add quote do: inputAsType(`typ`)
      |                                         ^
a.cc:157:30: error: stray '`' in program
  157 |       sle.add quote do: (let `t` = stdin.readLine.split)
      |                              ^
a.cc:157:32: error: stray '`' in program
  157 |       sle.add quote do: (let `t` = stdin.readLine.split)
      |                                ^
a.cc:162:29: error: stray '`' in program
  162 |             p.add quote do: `t`[`i`]
      |                             ^
a.cc:162:31: error: stray '`' in program
  162 |             p.add quote do: `t`[`i`]
      |                               ^
a.cc:162:33: error: stray '`' in program
  162 |             p.add quote do: `t`[`i`]
      |                                 ^
a.cc:162:35: error: stray '`' in program
  162 |             p.add quote do: `t`[`i`]
      |                                   ^
a.cc:165:29: error: stray '`' in program
  165 |             p.add quote do: `t`[`i`].`parsefn`
      |                             ^
a.cc:165:31: error: stray '`' in program
  165 |             p.add quote do: `t`[`i`].`parsefn`
      |                               ^
a.cc:165:33: error: stray '`' in program
  165 |             p.add quote do: `t`[`i`].`parsefn`
      |                                 ^
a.cc:165:35: error: stray '`' in program
  165 |             p.add quote do: `t`[`i`].`parsefn`
      |                                   ^
a.cc:165:38: error: stray '`' in program
  165 |             p.add quote do: `t`[`i`].`parsefn`
      |                                      ^
a.cc:165:46: error: stray '`' in program
  165 |             p.add quote do: `t`[`i`].`parsefn`
      |                                              ^
a.cc:169:20: error: too many decimal points in number
  169 |           for i in 0..<defs[0].len:
      |                    ^~~
a.cc:170:29: error: stray '`' in program
  170 |             p.add quote do: `t`[`i`]
      |                             ^
a.cc:170:31: error: stray '`' in program
  170 |             p.add quote do: `t`[`i`]
      |                               ^
a.cc:170:33: error: stray '`' in program
  170 |             p.add quote do: `t`[`i`]
      |                                 ^
a.cc:170:35: error: stray '`' in program
  170 |             p.add quote do: `t`[`i`]
      |                                   ^
a.cc:173:20: error: too many decimal points in number
  173 |           for i in 0..<defs[0].len:
      |                    ^~~
a.cc:174:29: error: stray '`' in program
  174 |             p.add quote do: `t`[`i`].`parsefn`
      |                             ^
a.cc:174:31: error: stray '`' in program
  174 |             p.add quote do: `t`[`i`].`parsefn`
      |                               ^
a.cc:174:33: error: stray '`' in program
  174 |             p.add quote do: `t`[`i`].`parsefn`
      |                                 ^
a.cc:174:35: error: stray '`' in program
  174 |             p.add quote do: `t`[`i`].`parsefn`
      |                                   ^
a.cc:174:38: error: stray '`' in program
  174 |             p.add quote do: `t`[`i`].`parsefn`
      |                                      ^
a.cc:174:46: error: stray '`' in program
  174 |             p.add quote do: `t`[`i`].`parsefn`
      |                                              ^
a.cc:182:36: error: stray '`' in program
  182 |       val := (quote do: newSeqWith(`cnt`, inputAsType(`typ`)))
      |                                    ^
a.cc:182:40: error: stray '`' in program
  182 |       val := (quote do: newSeqWith(`cnt`, inputAsType(`typ`)))
      |                                        ^
a.cc:182:55: error: stray '`' in program
  182 |       val := (quote do: newSeqWith(`cnt`, inputAsType(`typ`)))
      |                                                       ^
a.cc:182:59: error: stray '`' in program
  182 |       val := (quote do: newSeqWith(`cnt`, inputAsType(`typ`)))
      |                                                           ^
a.cc:187:2: error: invalid preprocessing directive #==
  187 | #=== ここまでテンプレート ===========
      |  ^~
a.cc:194:10: error: too many decimal points in number
  194 | for i in 22..d:
      |          ^~~~~
a.cc:3:1: error: 'import' does not name a type
    3 | import strutils, sequtils, math, algorithm, nre, tables, macros
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:36:48: error: expected unqualified-id before '=' token
   36 | proc discardableId[T](x: T): T {.discardable.} =
      |                                                ^
a.cc:40:26: error: expected constructor, destructor, or type conversion before '(' token
   40 |     (x = y; discardableId(x))
      |                          ^
a.cc:42:30: error: expected constructor, destructor, or type conversion before '(' token
   42 |     (var x = y; discardableId(x))
      |                              ^
a.cc:43:36: error: found ':' in nested-name-specifier, expected '::'
   43 | proc count[T](co: openArray[T]; obj: T): int =
      |                                    ^
      |                                    ::
a.cc:43:33: error: 'obj' does not name a type
   43 | proc count[T](co: openArray[T]; obj: T): int =
      |                                 ^~~
a.cc:49:27: error: found ':' in nested-name-specifier, expected '::'
   49 | proc `min=`[T](x: var T; y: T): bool {.discardable.} =
      |                           ^
      |                           ::
a.cc:49:26: error: 'y' does not name a type
   49 | proc `min=`[T](x: var T; y: T): bool {.discardable.} =
      |                          ^
a.cc:49:54: error: expected unqualified-id before '=' token
   49 | proc `min=`[T](x: var T; y: T): bool {.discardable.} =
      |                                                      ^
a.cc:55:27: error: found ':' in nested-name-specifier, expected '::'
   55 | proc `max=`[T](x: var T; y: T): bool {.discardable.} =
      |                           ^
      |                           ::
a.cc:55:26: error: 'y' does not name a type
   55 | proc `max=`[T](x: var T; y: T): bool {.discardable.} =
      |                          ^
a.cc:55:54: error: expected unqualified-id before '=' token
   55 | proc `max=`[T](x: var T; y: T): bool {.discardable.} =
      |                                                      ^
a.cc:71:32: error: found ':' in nested-name-specifier, expected '::'
   71 | proc find[T](t: UnionFind[T]; o: T): T =
      |                                ^
      |                                ::
a.cc:71:31: error: 'o' does not name a type
   71 | proc find[T](t: UnionFind[T]; o: T): T =
      |                               ^
a.cc:75:32: error: 'x' does not name a type
   75 | proc union[T](t: UnionFind[T]; x, y: T) =
      |