Language: C++

from strutils import split, parseInt, parseFloat
from sequtils import map

import macros
macro unpack*(input: seq; count: static[int]): untyped =
  result = quote do: ()
  when NimMinor <= 13: # 本当にここが区切りかどうかは知らない
    for i in 0..<count: result[0].add quote do: `input`[`i`]
  else:
    for i in 0..<count: result.add quote do: `input`[`i`]

# count == 0 のとき unpackしない
# count >  0 のとき count個分 unpack した結果の tuple を返す
type UnselectableTypeError = object of Exception
template input*(typ: typedesc; count: static[Natural] = 0): untyped =
  let line = stdin.readLine.split
  when count == 0:
    when typ is int:    line.map(parseInt)
    elif typ is float:  line.map(parseFloat)
    elif typ is string: line
    else: raise newException(UnselectableTypeError, "You selected a type other than int, float or string")
  else:
    when typ is int:    line.map(parseInt).unpack(count)
    elif typ is float:  line.map(parseFloat).unpack(count)
    elif typ is string: line.unpack(count)
    else: raise newException(UnselectableTypeError, "You selected a type other than int, float or string")

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
let
  (H, W) = input(int, 2)
  HHalf = H div 2
  WHalf = W div 2

if H mod 3 == 0 or W mod 3 == 0:
  echo 0
  quit()

var result = min(H, W)
for h in 1..<H:
  result = min(result, max((h * W - (H - h) * WHalf).abs, (h * W - (H - h) * (W - WHalf)).abs))
for w in 1..<W:
  result = min(result, max((H * w - HHalf * (W - w)).abs, (H * w - (H - HHalf) * (W - w)).abs))

echo result


Compiler output:
a.cc:7:24: error: stray '#' in program
    7 |   when NimMinor <= 13: # 本当にここが区切りかどうかは知らない
      |                        ^
a.cc:8:14: error: too many decimal points in number
    8 |     for i in 0..<count: result[0].add quote do: `input`[`i`]
      |              ^~~
a.cc:8:49: error: stray '`' in program
    8 |     for i in 0..<count: result[0].add quote do: `input`[`i`]
      |                                                 ^
a.cc:8:55: error: stray '`' in program
    8 |     for i in 0..<count: result[0].add quote do: `input`[`i`]
      |                                                       ^
a.cc:8:57: error: stray '`' in program
    8 |     for i in 0..<count: result[0].add quote do: `input`[`i`]
      |                                                         ^
a.cc:8:59: error: stray '`' in program
    8 |     for i in 0..<count: result[0].add quote do: `input`[`i`]
      |                                                           ^
a.cc:10:14: error: too many decimal points in number
   10 |     for i in 0..<count: result.add quote do: `input`[`i`]
      |              ^~~
a.cc:10:46: error: stray '`' in program
   10 |     for i in 0..<count: result.add quote do: `input`[`i`]
      |                                              ^
a.cc:10:52: error: stray '`' in program
   10 |     for i in 0..<count: result.add quote do: `input`[`i`]
      |                                                    ^
a.cc:10:54: error: stray '`' in program
   10 |     for i in 0..<count: result.add quote do: `input`[`i`]
      |                                                      ^
a.cc:10:56: error: stray '`' in program
   10 |     for i in 0..<count: result.add quote do: `input`[`i`]
      |                                                        ^
a.cc:12:3: error: invalid preprocessing directive #count
   12 | # count == 0 のとき unpackしない
      |   ^~~~~
a.cc:13:3: error: invalid preprocessing directive #count
   13 | # count >  0 のとき count個分 unpack した結果の tuple を返す
      |   ^~~~~
a.cc:28:3: error: invalid preprocessing directive ##
   28 | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
      |   ^
a.cc:39:10: error: too many decimal points in number
   39 | for h in 1..<H:
      |          ^~~
a.cc:41:10: error: too many decimal points in number
   41 | for w in 1..<W:
      |          ^~~
a.cc:1:1: error: 'from' does not name a type
    1 | from strutils import split, parseInt, parseFloat
      | ^~~~
a.cc:5:27: error: 'count' does not name a type
    5 | macro unpack*(input: seq; count: static[int]): untyped =
      |                           ^~~~~
a.cc:15:32: error: 'count' does not name a type
   15 | template input*(typ: typedesc; count: static[Natural] = 0): untyped =
      |                                ^~~~~