There is a bar of chocolate with a height of H blocks and a width of W blocks.
Snuke is dividing this bar into exactly three pieces.
He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle.
Snuke is trying to divide the bar as evenly as possible.
More specifically, he is trying to minimize S_{max} - S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece.
Find the minimum possible value of S_{max} - S_{min}.

-----Constraints-----
 - 2 ≤ H, W ≤ 10^5

-----Input-----
Input is given from Standard Input in the following format:
H W

-----Output-----
Print the minimum possible value of S_{max} - S_{min}.

-----Sample Input-----
3 5

-----Sample Output-----
0

In the division below, S_{max} - S_{min} = 5 - 5 = 0.
[{"code": "H, W = map(int, input().split())\nans = float('inf')\nfor h in range(1,H):\n    S = [h * W]\n    w = W // 2\n    S += [(H-h) * w]\n    S += [(H-h) * (W-w)]\n    ans = min(ans,max(S)-min(S))\n\nfor h in range(1,H):\n    S = [h * W]\n    hb = (H-h) // 2\n    S += [hb * W]\n    S += [(H-h-hb) * W]\n    ans = min(ans,max(S)-min(S))\n\nfor w in range(1,W):\n    S = [H * w]\n    h = H // 2\n    S += [h * (W-w)]\n    S += [(H-h) * (W-w)]\n    ans = min(ans,max(S)-min(S))\n\nfor w in range(1,W):\n    S = [w * H]\n    wb = (W-w) // 2\n    S += [wb * H]\n    S += [(W-w-wb) * H]\n    ans = min(ans,max(S)-min(S))\n\nprint(ans)", "passed": true, "time": 0.7, "memory": 14236.0, "status": "done"}, {"code": "H, W = list(map(int, input().split()))\n\nif (H%3==0) or (W%3==0):\n  print((0))\nelse:\n  ans = H * W\n  H, W = min(H, W), max(H, W)\n  for wi in range(1, W//2 + 1):\n    S1 = H * wi\n    if (H%2==0) or ((W-wi)%2==0):\n      S2 = H * (W-wi) // 2\n      S3 = S2\n    else:\n      S2 = min(H, W-wi) * (max(H, W-wi)//2)\n      S3 = S2 + min(H, W-wi)\n    ans = min(ans, max(S1, S2, S3) - min(S1, S2, S3))\n  for hi in range(1, H//2 + 1):\n    S1 = W * hi\n    if (W%2==0) or ((H-hi)%2==0):\n      S2 = W * (H-hi) // 2\n      S3 = S2\n    else:\n      S2 = min(W, H-hi) * (max(W, H-hi)//2)\n      S3 = S2 + min(W, H-hi)\n    ans = min(ans, max(S1, S2, S3) - min(S1, S2, S3))\n    \n  print(ans)\n  \n", "passed": true, "time": 0.53, "memory": 14212.0, "status": "done"}, {"code": "def aaa(a, b):\n    return abs((a // 3 * b) - ((a // 3 + 1) * b))\n\n\ndef bbb(a, b):\n    ret = 1000 * 100\n    for x in range(1, a):\n        xx = a - x\n        i = x * b\n        j = xx * (b // 2)\n        k = xx * (b // 2 + (b % 2))\n        tmp = max(abs(i - j), abs(j - k), abs(k - i))\n        ret = min(ret, tmp)\n    return ret\n\n\nH, W = list(map(int, input().split()))\n\nif H % 3 == 0 or W % 3 == 0:\n    print((0))\nelse:\n    a = aaa(H, W)\n    b = aaa(W, H)\n    c = bbb(H, W)\n    d = bbb(W, H)\n    print((min(a, b, c, d)))\n", "passed": true, "time": 0.37, "memory": 14112.0, "status": "done"}, {"code": "H,W = map(int,input().split())\nans = [H//2+W//3+1,H//3+W//2+1,H,W]\n\nif(H%3==0 or W%3==0):\n  ans+=[0]\nif(H%2==0):\n  ans+=[H//2]\nif(W%2==0):\n  ans+=[W//2]\n\nprint(min(ans))", "passed": true, "time": 0.16, "memory": 14396.0, "status": "done"}, {"code": "h,w = map(int,input().split())\n\ntmps = 0\nans = 10**18\nfor i in range(1,h):\n\tk = (h-i)//2\n\tt = [i*w, k*w, (h-i-k)*w]\n\ttmp = max(t)-min(t)\n\tans = min(tmp, ans)\n\tk = w//2\n\tt = [i*w, (h-i)*k, (h-i)*(w-k)]\n\ttmp = max(t)-min(t)\n\tans = min(tmp, ans)\nfor i in range(1,w):\n\tk = (w-i)//2\n\tt = [i*h, k*h, (w-i-k)*h]\n\ttmp = max(t)-min(t)\n\tans = min(tmp, ans)\n\tk = h//2\n\tt = [i*h, (w-i)*k, (w-i)*(h-k)]\n\ttmp = max(t)-min(t)\n\tans = min(tmp, ans)\nprint(ans)", "passed": true, "time": 0.82, "memory": 14256.0, "status": "done"}, {"code": "h,w = map(int,input().split())\nans = 10**10\n\ndef menseki(h,w):\n    nonlocal ans\n    for i in range(1,h):\n        # \u7e261\u6a2a2\n        haba = w//2\n        ans = min(ans,max(i*w,haba*(h-i),(w-haba)*(h-i))-min(i*w,haba*(h-i),(w-haba)*(h-i)))\n        # \u7e263\u5206\u5272\n        if i == h-1:\n            continue\n        tate = (h-i)//2\n        ans = min(ans,max(w*i,tate*w,(h-i-tate)*w)-min(w*i,tate*w,(h-i-tate)*w))\n\nmenseki(h,w)\nmenseki(w,h)\n\nprint(ans)", "passed": true, "time": 0.71, "memory": 14364.0, "status": "done"}, {"code": "from math import ceil, floor\n\n\ndef main():\n    h, w = list(map(int, input().split()))\n    d = h * w\n    d = min((ceil(h / 3) - floor(h / 3)) * w, d)\n    d = min((ceil(w / 3) - floor(w / 3)) * h, d)\n    dd = h * w\n    for i in range(h):\n        u = i * w\n        d1 = (h - i) * ceil(w / 2)\n        d2 = (h - i) * floor(w / 2)\n        di = max(abs(u - d1), abs(u - d2))\n        if di > dd:\n            break\n        dd = di\n    d = min(dd, d)\n    dd = h * w\n    for i in range(w):\n        u = i * h\n        d1 = (w - i) * ceil(h / 2)\n        d2 = (w - i) * floor(h / 2)\n        di = max(abs(u - d1), abs(u - d2))\n        if di > dd:\n            break\n        dd = di\n    d = min(dd, d)\n    print(d)\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.35, "memory": 14340.0, "status": "done"}, {"code": "h,w=list(map(int,input().split()))\n\ninf=float('inf')\n\nans=inf\n\nfor i in range(1,h):\n  a=i*w\n  rest=h*w-a\n  b=(w//2)*(h-i)\n  c=rest-b\n  max_s=max(a,b,c)\n  min_s=min(a,b,c)\n  ans=min(ans,max_s-min_s)\n  \nfor j in range(1,w):\n  A=j*h\n  Rest=h*w-A\n  B=(h//2)*(w-j)\n  C=Rest-B\n  Max_s=max(A,B,C)\n  Min_s=min(A,B,C)\n  ans=min(ans,Max_s-Min_s)\n  \nif w>=3:\n  if w%3==0:\n    ans=0\n  else:\n    ans=min(ans,h)\n    \nif h>=3:\n  if h%3==0:\n    ans=0\n  else:\n    ans=min(ans,w)\n    \nprint(ans)\n  \n\n", "passed": true, "time": 0.63, "memory": 14388.0, "status": "done"}, {"code": "def resolve():\n    H, W = list(map(int, input().split()))\n    \n    def _solve(H, W):\n        mean_w = W // 2\n        ans = float(\"inf\")\n        for h in range(1, H):\n            s1 = h * W\n            mean_h = (H-h) // 2\n            for i in range(0, 2):\n                if i == 0:\n                    s2 = (H-h)*mean_w\n                    s3 = (H-h)*(W-mean_w)\n                if i == 1:\n                    s2 = mean_h*W\n                    s3 = (H-h-mean_h)*W\n                ans = min(ans, max(s1, s2, s3)-min(s1, s2, s3))\n        return ans\n\n    print(min(_solve(H, W), _solve(W, H)))\n\nif '__main__' == __name__:\n    resolve()", "passed": true, "time": 0.61, "memory": 14416.0, "status": "done"}, {"code": "h, w = map(int, input().split())\nif h % 3 == 0 or w % 3 == 0:\n    print(0)\nelse:\n    if h > w:\n        h, w = w, h\n    ans = h\n    for w1 in range(w//3-2, w//3+3):\n        s1 = w1 * h\n        w2 = w-w1\n        for h1 in range(h//2 + 1):\n            s2 = w2 * h1\n            s3 = w2 * (h-h1)\n            ans = min(ans, max(s1, s2, s3) - min(s1, s2, s3))\n    h, w = w, h\n    for w1 in range(w//3-2, w//3+3):\n        s1 = w1 * h\n        w2 = w-w1\n        for h1 in range(h//2 + 1):\n            s2 = w2 * h1\n            s3 = w2 * (h-h1)\n            ans = min(ans, max(s1, s2, s3) - min(s1, s2, s3))\n    print(ans)", "passed": true, "time": 0.83, "memory": 14372.0, "status": "done"}, {"code": "H, W = map(int, input().split())\n\ndef abc(x,y,z): #x,y:\u9ad8\u3055\u307e\u305f\u306f\u5e45\u3001z:\uff59\u306e\u5e45\u3092\u3082\u3064\u30d4\u30fc\u30b9\u306e\u9ad8\u3055\n    a = z * y\n    if (x-z)&1 and y&1:\n        b = max(x-z, y)//2 * min(x-z,y)\n        c = x*y - a - b\n    else:\n        b = c = (x-z)*y//2\n    return a, b, c\n\ndef diffS(a,b,c): #a,b,c:abc()\u306e\u623b\u308a\u5024\n    return max(a, b, c) - min(a, b, c)\n\ndef solve(x, y): #x,y:\u9ad8\u3055\u307e\u305f\u306f\u5e45\n    z = x // 3\n    return min(diffS(*abc(x,y,z)), diffS(*abc(x,y,z+1)))\n\n\nif H % 3 == 0 or W % 3 == 0:\n    ans = 0\nelse:\n    ans = min(solve(H,W), solve(W,H))\nprint(ans)", "passed": true, "time": 0.26, "memory": 14192.0, "status": "done"}, {"code": "# solution\n# online help taken\n\nh,w=map(int,input().split())\nans=h*w\n\nif h%3==0 or w%3==0:\n  ans=0\nelse:\n  ans=min(h,w)\n  \na=round(h/3)*w\nb=(h-round(h/3))*(w//2)\nc=h*w-a-b\nd=max(a,b,c)-min(a,b,c)\nans=min(ans,d)\na=round(w/3)*h\nb=(w-round(w/3))*(h//2)\nc=h*w-a-b\nd=max(a,b,c)-min(a,b,c)\nans=min(ans,d)\nprint(ans)", "passed": true, "time": 0.14, "memory": 14364.0, "status": "done"}, {"code": "h,w = map(int,input().split())\ns = [h*w] * 4\n\nif h == w == 2:\n  print(1)\n  return\nif h % 3 == 0 or w % 3 == 0:\n  print(0)\n  return\n\nif w > 2:\n  s[0] = h\nif h > 2:\n  s[1] = w\nif h % 2 == 0:\n  s[2] = h // 2\nelse:\n  tmp = h*w\n  for i in range(w//3, w//3+2):\n    s1 = i * h\n    s2 = (w-i) * (h//2)\n    s3 = (w-i) * (h//2 + 1)\n    tmp = min(tmp, max(s1, s2, s3) - min(s1, s2, s3))\n  s[2] = tmp\nif w % 2 == 0:\n  s[3] = w // 2\nelse:\n  tmp = h*w\n  for i in range(h//3, h//3 + 2):\n    s1 = i * w\n    s2 = (h-i) * (w//2)\n    s3 = (h-i) * (w//2 + 1)\n    tmp = min(tmp, max(s1, s2, s3) - min(s1, s2, s3))\n  s[3] = tmp\n\nprint(min(s))", "passed": true, "time": 0.24, "memory": 14272.0, "status": "done"}, {"code": "import sys\nH, W = map(int,input().split())\nif H % 3 == 0 or W % 3 == 0:\n    print(0)\n    return\ndef solve(p, q):\n    r = int(p / 2)\n    s = int(q / 3)\n    a, b, c = p*s, r*(q-s), (p-r)*(q-s)\n    ans = max(a, b, c) - min(a, b, c)\n    a, b, c = p*(s+1), r*(q-s-1), (p-r)*(q-s-1)\n    ans = min(ans, max(a, b, c) - min(a, b, c))\n    return ans\nans = min(W, H, solve(H, W), solve(W, H))\nprint(ans)", "passed": true, "time": 0.14, "memory": 14172.0, "status": "done"}, {"code": "ma = lambda :map(int,input().split())\nlma = lambda :list(map(int,input().split()))\ntma = lambda :tuple(map(int,input().split()))\nni = lambda:int(input())\nyn = lambda fl:print(\"Yes\") if fl else print(\"No\")\nimport collections\nimport math\nimport itertools\nimport heapq as hq\n\nH,W=ma()\ndef f(H,W):\n    ret=10**10+5\n    for h in range(1,H):\n        s1 = h*W\n        s2,s3 = (H-h)//2*W,(H-h+1)//2*W\n        ret=min(ret,max(s1,s2,s3) -min(s1,s2,s3) )\n        s2,s3 = W//2*(H-h),(W+1)//2*(H-h)\n        ret=min(ret,max(s1,s2,s3) -min(s1,s2,s3) )\n    return ret\nprint(min(f(H,W),f(W,H)))\n", "passed": true, "time": 0.55, "memory": 14300.0, "status": "done"}, {"code": "H, W = map(int, input().split())\nif (H%3) * (W%3) == 0:\n  print(0)\n  return\n\nans = H * W\nw1 = W // 2\nw2 = W - w1\nS1 = (H - 1) * w1; T1 = W * ((H-1)//2)\nS2 = (H - 1) * w2; T2 = W * (H-1) - T1\nS3 = W\nh = H - 1\nfor i in range(H-1):\n  diff1 = max(S1, S2, S3) - min(S1, S2, S3)\n  diff2 = max(T1, T2, S3) - min(T1, T2, S3)\n  ans = min(ans, diff1, diff2)\n  S1 -= w1; S2 -= w2; S3 += W\n  h -= 1\n  T1 = W * (h//2)\n  T2 = W*h - T1\n\nh1 = H // 2\nh2 = H - h1\nS1 = (W - 1) * h1; T1 = H * ((W-1)//2)\nS2 = (W - 1) * h2; T2 = H * (W-1) - T1\nS3 = H\nw = W - 1\nfor i in range(W-1):\n  diff1 = max(S1, S2, S3) - min(S1, S2, S3)\n  diff2 = max(T1, T2, S3) - min(T1, T2, S3)\n  ans = min(ans, diff1, diff2)\n  S1 -= h1; S2 -= h2; S3 += H\n  w -= 1\n  T1 = H * (w//2)\n  T2 = H*w - T1\n\nprint(ans)", "passed": true, "time": 0.5, "memory": 14268.0, "status": "done"}, {"code": "H,W = map(int,input().split())\n\nans = 1e19\n##\u7e26\u65b9\u5411\u306e\u63a2\u7d22\nfor i in range(1,H):\n    tate = W*i##\u4e0a\u304b\u3089\u6a2a\u306b\u5207\u308b\n    ##\u6a2a\u306b\u5207\u308b\n    if i < H-1:\n        mini = W*((H-i)//2)##\u5206\u5272\u3057\u305f\u3084\u3064\n        ##print(tate,mini,H*W-mini-tate)\n        ans = min(ans,max(tate,mini,H*W-mini-tate)-min(tate,mini,H*W-mini-tate))\n\n    ##\u7e26\u306b\u5207\u308b\n    mini = (H-i)*(W//2)\n    ##print(tate,mini,H*W-mini-tate)\n    ans = min(ans,max(tate,mini,H*W-tate-mini)-min(tate,mini,H*W-tate-mini))\n\n##\u6a2a\u65b9\u5411\u306e\u63a2\u7d22\nfor i in range(1,W):\n    yoko = H*i\n    if i < W-1:\n        mini = H*((W-i)//2)\n        ##print(yoko,mini,H*W-mini-yoko)\n        ans = min(ans,max(yoko,mini,H*W-mini-yoko)-min(yoko,mini,H*W-yoko-mini))\n    mini = (W-i)*(H//2)\n    ##print(yoko,mini,H*W-yoko-mini)\n    ans = min(ans,max(yoko,mini,H*W-yoko-mini)-min(yoko,mini,H*W-yoko-mini))\n\nprint(ans)", "passed": true, "time": 0.6, "memory": 14324.0, "status": "done"}, {"code": "h,w=map(int,input().split())\nmini=h*w\nfor i in range(1,h):\n    if mini > max(w*(h-i),(w//2+w%2)*i) - min(w*(h-i),(w//2)*i):\n        mini = max(w*(h-i),(w//2+w%2)*i) - min(w*(h-i),(w//2)*i)\n\nfor i in range(1,w):\n    if mini > max(h*(w-i),(h//2+h%2)*i) - min(h*(w-i),(h//2)*i):\n        mini = max(h*(w-i),(h//2+h%2)*i) - min(h*(w-i),(h//2)*i)\n\nif h%3 == 0 or w%3 == 0:\n    mini=0\nelse:\n    if mini > h:\n        mini = h\n    elif mini > w:\n        mini = w\n    else:\n        pass\nprint(mini)", "passed": true, "time": 0.39, "memory": 14248.0, "status": "done"}, {"code": "h, w = list(map(int, input().split()))\nif not h%3 or not w%3:\n  print((0))\nelse:\n  ans = min([h, w])\n  for i in range(h):\n    sub = max([abs(w*i-w//2*(h-i)), abs(w*i-(w-w//2)*(h-i))])\n    if ans > sub:\n      ans = sub\n  for i in range(w):\n    sub = max([abs(h*i-h//2*(w-i)), abs(h*i-(h-h//2)*(w-i))])\n    if ans > sub:\n      ans = sub\n  print(ans)\n", "passed": true, "time": 0.34, "memory": 14288.0, "status": "done"}, {"code": "H, W = map(int, input().split())\nif (H%3) * (W%3) == 0:\n  print(0)\n  return\n\nans = min(H, W)\nw1 = W // 2\nw2 = W - w1\nS1 = (H - 1) * w1\nS2 = (H - 1) * w2\nS3 = W\nfor i in range(H-1):\n  diff = max(S1, S2, S3) - min(S1, S2, S3)\n  ans = min(ans, diff)\n  S1 -= w1; S2 -= w2; S3 += W\n\nh1 = H // 2\nh2 = H - h1\nS1 = (W - 1) * h1\nS2 = (W - 1) * h2\nS3 = H\nfor i in range(W-1):\n  diff = max(S1, S2, S3) - min(S1, S2, S3)\n  ans = min(ans, diff)\n  S1 -= h1; S2 -= h2; S3 += H\n\nprint(ans)", "passed": true, "time": 0.43, "memory": 14152.0, "status": "done"}, {"code": "h,w = map(int, input().split())\nans = 1000000000\nif max(h,w) >= 3:\n  if h >= w :\n    ans = w*min(1,(h%3))\n  else:\n    ans = h*min(1,(w%3))\nif h%3 == 0:\n  ans = 0\nif w%3 == 0:\n  ans = 0\nfor i in range(1,h):\n  ans_ = max(i*w,(h-i)*(w+(w%2))//2) - min(i*w,(h-i)*(w-(w%2))//2)\n  ans = min(ans,ans_)\nfor i in range(1,w):\n  ans_ = max(i*h,(w-i)*(h+(h%2))//2) - min(i*h,(w-i)*(h-(h%2))//2)\n  ans = min(ans,ans_)\nprint(ans)", "passed": true, "time": 0.45, "memory": 14348.0, "status": "done"}, {"code": "h, w = map(int, input().split())\nINF = 100000000\n\n#\u7e26\u306b3\u3064\u5206\u3051\u308b\u5834\u5408\nif w % 3 == 0:\n    s_tate = 0\nelse:\n    s_tate = (int(w/3)+1) * h - int(w/3) * h\n\n#\u6a2a\u306b3\u3064\u306b\u5206\u3051\u308b\u5834\u5408\nif h % 3 == 0:\n    s_yoko = 0\nelse:\n    s_yoko = (int(h/3)+1) * w - int(h/3) * w\n\n#\u4e0a\u5074\u306b\u7e26\u306b2\u3064\u3001\u4e0b\u65b9\u306b1\u3064\u3067\u308f\u3051\u308b\u5834\u5408\ncase3 = INF\nif w%2 == 0:\n    for i in range(1,h):\n        buf = abs((int(w/2) * i) - (w * (h-i)))\n        case3 = min(buf, case3)\nelse:\n    for i in range(1,h):\n        buf1 = int(w/2) * i\n        buf2 = (int(w/2)+1) * i\n        buf3 = w * (h - i)\n        buf = [buf1, buf2, buf3]\n        buf = sorted(buf)\n        sa = buf[2] - buf[0]\n        case3 = min(sa, case3)\n\n#\u5de6\u5074\u306b\uff11\u3064\u3001\u53f3\u5074\u306b\u6a2a\u306b\uff12\u3064\u3067\u308f\u3051\u308b\u5834\u5408\ncase4 =INF\nif h%2 == 0:\n    for i in range(1,w):\n        buf = abs((int(h/2) * i) - (h * (w-i)))\n        case4 = min(buf, case4)\nelse:\n    for i in range(1,w):\n        buf1 = int(h/2) * i\n        buf2 = (int(h/2)+1) * i\n        buf3 = h * (w - i)\n        buf = [buf1, buf2, buf3]\n        buf = sorted(buf)\n        sa = buf[2] - buf[0]\n        case4 = min(sa, case4)\nans1 = min(s_tate, s_yoko)\nans2 = min(case3, case4)\n\nans = min(ans1, ans2)\n\n#print(s_tate, s_yoko, case3, case4)\n\nprint(ans)", "passed": true, "time": 0.27, "memory": 14308.0, "status": "done"}, {"code": "def pattern1(A, B):\n    s1 = (A // 3) * B\n    s2 = ((A - (A // 3)) // 2) * B\n    s3 = A * B - s1 - s2\n    return max([abs(s1 - s2), abs(s2 - s3), abs(s3 - s1)])\n\n\ndef pattern2(A, B):\n    a1 = A // 2\n    a2 = A - a1\n    b1 = (2 * B + 1) // 3\n    b2 = B - b1\n    s1, s2, s3 = a1 * b1, a2 * b1, A * b2\n    return max([abs(s1 - s2), abs(s2 - s3), abs(s3 - s1)])\n\n\ndef main():\n    H, W = list(map(int, input().split(' ')))\n    ans = min([\n        pattern1(H, W),\n        pattern1(W, H),\n        pattern2(H, W),\n        pattern2(W, H)\n    ])\n    print(ans)\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.17, "memory": 14232.0, "status": "done"}, {"code": "H, W = map(int, input().split())\n\nans = 10**12\n\n# 1\u679a\u76ee\u3092(1,2,...,H-1)*W\u3068\u3059\u308b\nfor h in range(1, H):\n    s1 = W * h\n    # \u6b8b\u308a\u306f(H-h)*W\n\n    # \u6b8b\u308a\u3092\u6a2a\u306b\u5272\u308b\u5834\u5408\n    h2 = (H - h) // 2\n    h3 = (H - h) - h2\n    s2 = W * h2\n    s3 = W * h3\n    max_s = max(s1, s2, s3)\n    min_s = min(s1, s2, s3)\n    ans = min(ans, max_s - min_s)\n\n    # \u6b8b\u308a\u3092\u7e26\u306b\u5272\u308b\u5834\u5408\n    w2 = W // 2\n    w3 = W - w2\n    s2 = (H - h) * w2\n    s3 = (H - h) * w3\n    max_s = max(s1, s2, s3)\n    min_s = min(s1, s2, s3)\n    ans = min(ans, max_s - min_s)\n\n# 1\u679a\u76ee\u3092H*(1,2,...,W-1)\u3068\u3059\u308b\nfor w in range(1, W):\n    s1 = w * H\n    # \u6b8b\u308a\u306fH*(W-w)\n\n    # \u6b8b\u308a\u3092\u6a2a\u306b\u5272\u308b\u5834\u5408\n    h2 = H // 2\n    h3 = H - h2\n    s2 = (W - w) * h2\n    s3 = (W - w) * h3\n    max_s = max(s1, s2, s3)\n    min_s = min(s1, s2, s3)\n    ans = min(ans, max_s - min_s)\n\n    # \u6b8b\u308a\u3092\u7e26\u306b\u5272\u308b\u5834\u5408\n    w2 = (W - w) // 2\n    w3 = (W - w) - w2\n    s2 = H * w2\n    s3 = H * w3\n    max_s = max(s1, s2, s3)\n    min_s = min(s1, s2, s3)\n    ans = min(ans, max_s - min_s)\n\nprint(ans)", "passed": true, "time": 0.53, "memory": 14176.0, "status": "done"}, {"code": "H,W = map(int,input().split())\nans = [H//2+W//3+1,H//3+W//2+1,H,W]\n\nif(H%3==0 or W%3==0):\n  ans+=[0]\nif(H%2==0):\n  ans+=[H//2]\nif(W%2==0):\n  ans+=[W//2]\n\nprint(min(ans))", "passed": true, "time": 0.14, "memory": 14148.0, "status": "done"}, {"code": "h,w=map(int,input().split())\npattern=[h//2+w//3+1,h//3+w//2+1,h,w]\nif h%3==0 or w%3==0:\n    pattern+=[0]\nif h%2==0:\n    pattern+=[h//2]\nif w%2==0:\n    pattern+=[w//2]\nprint(min(pattern))", "passed": true, "time": 0.14, "memory": 14160.0, "status": "done"}, {"code": "h, w = list(map(int, input().split()))\n\nif h % 3 == 0 or w % 3 == 0:\n    print((0))\n    return\nans = 10 ** 10\nif h >= 3:\n    ans = min(h, ans)\n\nif w >= 3:\n\n    ans = min(ans, w)\n    # print(kouho)\n\nfor i in range(1, h):\n    num1 = w * (i)\n    num2 = (h - i) * (w // 2)\n    num3 = (h - i) * (w - w // 2)\n    kouho = [num1, num2, num3]\n    kouho.sort()\n    ans = min(ans, kouho[-1] - kouho[0])\nfor i in range(1, w):\n    num1 = h * (i)\n    num2 = (w - i) * (h // 2)\n    num3 = (w - i) * (h - h // 2)\n    kouho = [num1, num2, num3]\n    kouho.sort()\n    ans = min(ans, kouho[-1] - kouho[0])\nprint(ans)\n", "passed": true, "time": 0.3, "memory": 14244.0, "status": "done"}, {"code": "h,w=map(int,input().split());print(min(min(min(max((i*w,(h-i)//2*w,(h-i-(h-i)//2)*w))-min((i*w,(h-i)//2*w,(h-i-(h-i)//2)*w)),max((i*w,w//2*(h-i),(h-i)*(w-w//2)))-min((i*w,w//2*(h-i),(h-i)*(w-w//2))))for i in range(h)),min(min(max((h*i,(w-i)//2*h,h*(w-i-(w-i)//2)))-min((h*i,(w-i)//2*h,h*(w-i-(w-i)//2))),max((h*i,h//2*(w-i),(h-h//2)*(w-i)))-min((h*i,h//2*(w-i),(h-h//2)*(w-i))))for i in range(w))))", "passed": true, "time": 0.69, "memory": 14264.0, "status": "done"}, {"code": "h,w=map(int,input().split())\nh_half=h//2\nw_half=w//2\ns_hw=h*w\nmin_x=s_hw\n\n# H*n \u306e\u7bc4\u56f2\u3092\u63a2\u67fb\nfor n in reversed(range(1,w_half+2)):\n  a=h*n\n  b=h_half*(w-n)\n  c=s_hw-(a+b)\n  s1=max(a,b,c)-min(a,b,c)\n  d=(w-n)//2*h\n  e=s_hw-(a+d)\n  s2=max(a,d,e)-min(a,d,e)\n  min_x=min(min_x,s1,s2)\n\n# n*W \u306e\u7bc4\u56f2\u3092\u63a2\u67fb\nfor n in reversed(range(1,h_half+2)):\n  a=w*n\n  b=w_half*(h-n)\n  c=s_hw-(a+b)\n  s1=max(a,b,c)-min(a,b,c)\n  d=(h-n)//2*w\n  e=s_hw-(a+d)\n  s2=max(a,d,e)-min(a,d,e)\n  min_x=min(min_x,s1,s2)\n\nprint(min_x)", "passed": true, "time": 0.31, "memory": 14200.0, "status": "done"}, {"code": "def cut(ch, cw):\n    total = ch*cw\n    if not ch % 2 or not cw % 2:\n        x = ch*cw // 2\n        return x, x\n    else:\n        x = max(ch*(cw//2), cw*(ch//2))\n        return x, total - x\n\n\nh, w = map(int,input().split())\n\nans = h*w\n\nfor i in range(2):\n    yh = h // 3 + i\n    s = [yh*w]\n    ch = h - yh\n    s += cut(ch, w)\n    ans = min(ans, max(s) - min(s))\n\nfor i in range(2):\n    yw = w // 3 + i\n    s = [h*yw]\n    cw = w - yw\n    s += cut(h, cw)\n    ans = min(ans, max(s) - min(s))\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14324.0, "status": "done"}, {"code": "#!/usr/bin/env python3\nclass V:\n    def __init__(self, f, v = None):\n        self.f = f\n        self.v = v\n \n    def __str__(self):\n        return str(self.v)\n \n    def __call__(self, n):\n        if n is None:\n            return self.v\n\n        if self.v is None:\n            self.v = n\n            return self.v\n        self.v = self.f(self.v, n) \n\nh, w = map(int, input().split())\n\ndef minmax(*args):\n    return max(args) - min(args)\n\ndef sep(m, n):\n    a = b = c = 0\n    nn = n // 2\n    ans = V(min, float(\"inf\"))\n\n    for i in range(1, m):\n        a = i * n\n        mm = (m - i) // 2\n    \n        # \u6a2a\n        b, c = (m - i) * nn, (m - i) * (n - nn)\n        ans(minmax(a, b, c))\n\n        # \u7e26\n        b, c = mm * n, (m - i - mm) * n\n        ans(minmax(a, b, c))\n    \n    return ans.v\n\nprint(min(sep(h, w), sep(w, h)))", "passed": true, "time": 0.69, "memory": 14124.0, "status": "done"}, {"code": "def answer(H,W,ans_kari):\n\n    for x in range(1,W):\n        y1 = H // 2\n        Sa1 = H * x\n        Sb1 = (W - x) * y1\n        Sc1 = (W - x) * (H - y1)\n        M = max(Sa1,Sb1,Sc1)\n        m = min(Sa1,Sb1,Sc1)\n\n        y2 = (W - x) // 2\n        Sa2 = H * x\n        Sb2 = H * y2\n        Sc2 = H * (W - x - y2)\n        M2 = max(Sa2,Sb2,Sc2)\n        m2 = min(Sa2,Sb2,Sc2)\n\n        if ans_kari > min(M-m,M2-m2):\n            ans_kari = min(M-m,M2-m2)\n\n    return ans_kari\n\ndef __starting_point():\n    H,W = [int(i) for i in input().split()]\n    ans = H * W\n    ans = answer(H,W,ans)\n    \n    H,W = W,H\n\n    if answer(H,W,ans) < ans:\n        ans = answer(H,W,ans)\n\n    print(ans)\n\n__starting_point()", "passed": true, "time": 0.64, "memory": 14388.0, "status": "done"}, {"code": "H, W = map(int, input().split())\nans = float('inf')\nfor h in range(1,H):\n    Sa = h * W\n    w = W // 2\n    Sb = (H-h) * w\n    Sc = (H-h) * (W-w)\n    ans = min(ans,max([Sa,Sb,Sc])-min([Sa,Sb,Sc]))\n\nfor h in range(1,H):\n    Sa = h * W\n    hb = (H-h) // 2\n    Sb = hb * W\n    Sc = (H-h-hb) * W\n    ans = min(ans,max([Sa,Sb,Sc])-min([Sa,Sb,Sc]))\n\nfor w in range(1,W):\n    Sa = H * w\n    h = H // 2\n    Sb = h * (W-w)\n    Sc = (H-h) * (W-w)\n    ans = min(ans,max([Sa,Sb,Sc])-min([Sa,Sb,Sc]))\n\nfor w in range(1,W):\n    Sa = w * H\n    wb = (W-w) // 2\n    Sb = wb * H\n    Sc = (W-w-wb) * H\n    ans = min(ans,max([Sa,Sb,Sc])-min([Sa,Sb,Sc]))\n\nprint(ans)", "passed": true, "time": 0.64, "memory": 14216.0, "status": "done"}, {"code": "import math\n\ndef main():\n\tH, W = [int(a) for a in input().split(\" \")]\n\n\tcand = []\n\t# case 1. w 3 split, h 3 split\n\tif W % 3 == 0 or H % 3 == 0:\n\t\tprint((0))\n\t\treturn 0\n\t# W % 3 !== 0 and H % 3 !== 0\n\tcand.append(H)\n\tcand.append(W)\n\t# case 2. w split -> h split\n\tcand += split_3(H, W)\n\tcand += split_3(W, H)\n\n\tprint((min(cand)))\n\treturn 0\n\ndef split_3(a, b):\n\ta_f = math.floor(a/3)\n\ta_c = math.ceil(a/3)\n\tb_f = math.floor(b/2)\n\tb_c = math.ceil(b/2)\n\n\ta1 = [b * a_f, (a - a_f) * b_f, a * b - (a - a_f) * b_f - b * a_f]\n\ta2 = [b * a_c, (a - a_c) * b_f, a * b - (a - a_c) * b_f - b * a_c]\n\ta3 = [b * a_f, (a - a_f) * b_c, a * b - (a - a_f) * b_c - b * a_f]\n\ta4 = [b * a_c, (a - a_c) * b_c, a * b - (a - a_c) * b_c - b * a_c]\n\n\treturn [max(a1) - min(a1), max(a2) - min(a2), max(a3) - min(a3), max(a4) - min(a4)]\n\nmain()\n", "passed": true, "time": 0.16, "memory": 14112.0, "status": "done"}, {"code": "H, W = map(int, input().split())\n\ndef case1(h, w):\n    MIN = float('inf')\n    for i in range(1, h):\n        sa = i * w\n        sb = (h - i) * (w//2)\n        sc = (h - i) * (w - w//2)\n        if max([sa,sb,sc]) - min([sa,sb,sc]) < MIN:\n            MIN = max([sa,sb,sc]) - min([sa,sb,sc]) \n    return MIN\n\ndef case2(h, w):\n    MIN = float('inf')\n    for i in range(1, h):\n        sa = i * w\n        sb = (h - i)//2 * w\n        sc = (h - i -(h - i)//2) * w\n        if max([sa,sb,sc]) - min([sa,sb,sc]) < MIN:\n            MIN = max([sa,sb,sc]) - min([sa,sb,sc]) \n    return MIN\nprint(min([case1(H,W) , case1(W,H), case2(H,W), case2(W,H)]))", "passed": true, "time": 0.93, "memory": 14168.0, "status": "done"}, {"code": "import sys\nreadline = sys.stdin.readline\nfrom math import floor, ceil\nfrom decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN\ndef round(f, r=0):\n    return Decimal(str(f)).quantize(Decimal(str(r)), rounding=ROUND_HALF_UP)\n\ndef main():\n    H, W = map(int, readline().rstrip().split())\n    ans = H * W\n    if H >= 3:\n        y1 = int(round(H/3))\n        y2 = (H-y1) // 2\n        y3 = H - y1 - y2\n        ans = min(ans, max(W*y1, W*y2, W*y3)-min(W*y1, W*y2, W*y3))\n    if W >= 3:\n        x1 = int(round(W/3))\n        x2 = (W-x1) // 2\n        x3 = W - x1 - x2\n        ans = min(ans, max(x1*H, x2*H, x3*H)-min(x1*H, x2*H, x3*H))\n    \n    # \u7e26\u306b\u30b9\u30e9\u30a4\u30b9 + \u6b8b\u308a\u306b\u6a2a\u306b\u30b9\u30e9\u30a4\u30b9\n    x1_cand = [floor(W/3), ceil(W/3)]\n    # x1_cand = [i for i in range(1, W)]\n    y1 = H\n    for x1 in x1_cand:\n        x2 = W - x1\n        x3 = x2\n        y2 = H // 2\n        y3 = H - y2\n        ans = min(ans, max((x1*y1), (x2*y2), (x3*y3)) - min((x1*y1), (x2*y2), (x3*y3)))\n\n    # \u6a2a\u306b\u30b9\u30e9\u30a4\u30b9 + \u6b8b\u308a\u306b\u7e26\u306b\u30b9\u30e9\u30a4\u30b9\n    y1_cand = [floor(H/3), ceil(H/3)]\n    # y1_cand = [i for i in range(1, H)]\n    x1 = W\n    for y1 in y1_cand:\n        y2 = H - y1\n        y3 = y2\n        x2 = W // 2\n        x3 = W - x2\n        ans = min(ans, max((x1*y1), (x2*y2), (x3*y3)) - min((x1*y1), (x2*y2), (x3*y3)))\n\n    print(ans)\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.18, "memory": 14160.0, "status": "done"}, {"code": "h,w = map(int,input().split())\nif (h%3 == 0) or (w%3 == 0):\n  print(0)\nelse:\n  ans = h*w\n  for i in range(1,max(h,w)//2 + 1):\n    a = min(h,w)*i\n    b = (max(h,w)-i)*(min(h,w)//2)\n    if min(h,w)%2 != 0:\n      c = (max(h,w)-i)*(min(h,w)//2 + 1)\n    else:\n      c = b\n    kari = max(a,b,c)-min(a,b,c)\n    if ans > kari:\n      ans = kari\n  ans3 = h*w\n  for i in range(1,min(h,w)//2 + 1):\n    a = max(h,w)*i\n    b = (min(h,w)-i)*(max(h,w)//2)\n    if max(h,w)%2 != 0:\n      c = (min(h,w)-i)*(max(h,w)//2 + 1)\n    else:\n      c = b\n    kari = max(a,b,c)-min(a,b,c)\n    if ans3 > kari:\n      ans3 = kari\n  ans2 = ((max(h,w)//3 + 1)*min(h,w))-((max(h,w)//3)*min(h,w))\n  print(min(ans,ans2,ans3))", "passed": true, "time": 0.3, "memory": 14160.0, "status": "done"}, {"code": "h, w = map(int, input().split())\nif h % 3 == 0 or w % 3 == 0:\n    print(0)\nelse:\n    ans = min(w, h)\n    for w1 in range(w//3, w//3+3):\n        s1 = w1 * h\n        w2 = w-w1\n        for h1 in range(h//2, h//2+2):\n            s2 = w2 * h1\n            s3 = w2 * (h-h1)\n            ans = min(ans, max(s1, s2, s3) - min(s1, s2, s3))\n    h, w = w, h\n    for w1 in range(w//3, w//3+3):\n        s1 = w1 * h\n        w2 = w-w1\n        for h1 in range(h//2, h//2+2):\n            s2 = w2 * h1\n            s3 = w2 * (h-h1)\n            ans = min(ans, max(s1, s2, s3) - min(s1, s2, s3))\n    print(ans)", "passed": true, "time": 0.22, "memory": 14336.0, "status": "done"}, {"code": "h,w = map(int, input().split())\nif (h%3==0 or w%3==0):\n    print(0)\n    return\nans = float(\"inf\")\nif (w%2==0):\n    ans = min(ans, (h-h//3)*(w//2) - h//3*w)\n    ans = min(ans, abs((h-h//3-1)*(w//2) - (h//3+1)*w))\nelse:\n    if (h%3==1):\n        ans = min(ans, max(abs((h-h//3)*(w//2) - h//3*w),abs((h-h//3)*(w//2+1) - h//3*w), abs(h-h//3)))\n    else:\n        ans = min(ans, max(abs((h-h//3-1)*(w//2) - (h//3+1)*w),abs((h-h//3-1)*(w//2+1) - (h//3+1)*w), abs(h-h//3-1)))\nans = min(ans,w)\n    \na = w\nw = h\nh = a\n#print(h,w)\nif (w%2==0):\n    ans = min(ans, (h-h//3)*(w//2) - h//3*w)\n    ans = min(ans, abs((h-h//3-1)*(w//2) - (h//3+1)*w))\nelse:\n    if (h%3==1):\n        ans = min(ans, max(abs((h-h//3)*(w//2) - h//3*w),abs((h-h//3)*(w//2+1) - h//3*w), abs(h-h//3)))\n    else:\n        ans = min(ans, max(abs((h-h//3-1)*(w//2) - (h//3+1)*w),abs((h-h//3-1)*(w//2+1) - (h//3+1)*w), abs(h-h//3-1)))\nans = min(ans,w)\n    \nprint(ans)", "passed": true, "time": 0.23, "memory": 14412.0, "status": "done"}, {"code": "H, W = map(int, input().split())\n\nans = float(\"inf\")\nfor h, w in zip([H, W], [W, H]):\n    # ah \u306e\u5168\u63a2\u7d22\n    for ah in range(1, h):\n        # \u6b8b\u308a\u3092\u7e26\u5272\u308a\n        Sa = ah * w\n        bw = (w - 1) // 2 + 1\n        Sb = (h - ah) * bw\n        Sc = (h - ah) * (w - bw)\n        ans = min(ans, (max(Sa, Sb, Sc)-min(Sa, Sb, Sc)))\n\n        # \u6b8b\u308a\u3092\u6a2a\u5272\u308a\n        if (h - ah) > 1:\n            bh = ((h - ah) - 1) // 2 + 1\n            Sb = bh * w\n            Sc = (h - ah - bh) * w\n            ans = min(ans, (max(Sa, Sb, Sc)-min(Sa, Sb, Sc)))\n        \nprint(ans)", "passed": true, "time": 0.58, "memory": 14292.0, "status": "done"}, {"code": "def main():\n    h, w = list(map(int, input().split()))\n    d = h * w\n    for i in range(1, h):\n        sh = (h - i) // 2\n        s = (i * w, sh * w, (h - i - sh) * w)\n        d = min(max(s) - min(s), d)\n        sv = w // 2\n        s = (i * w, (h - i) * sv, (h - i) * (w - sv))\n        d = min(max(s) - min(s), d)\n    for i in range(1, w):\n        sv = (w - i) // 2\n        s = (h * i, h * sv, h * (w - i - sv))\n        d = min(max(s) - min(s), d)\n        sh = h // 2\n        s = (h * i, sh * (w - i), (h - sh) * (w - i))\n        d = min(max(s) - min(s), d)\n    print(d)\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.56, "memory": 14156.0, "status": "done"}, {"code": "h,w=map(int,input().split())\nans=min(h,w)\nif h%3==0 or w%3==0:\n  print(0)\n  return\nfor hi in range(1,h):\n  mi=min(w*hi,w//2*(h-hi),(w-w//2)*(h-hi))\n  ma=max(w*hi,w//2*(h-hi),(w-w//2)*(h-hi))\n  ans=min(ans,ma-mi)\nfor wi in range(1,w):\n  mi=min(h*wi,h//2*(w-wi),(h-h//2)*(w-wi))\n  ma=max(h*wi,h//2*(w-wi),(h-h//2)*(w-wi))\n  ans=min(ans,ma-mi)\nprint(ans)", "passed": true, "time": 0.41, "memory": 14120.0, "status": "done"}, {"code": "H, W = list(map(int, input().split()))\n\nans = float('inf')\n\n# first cut vertical\nfor x in range(1, W):\n  S1 = x * H\n  # cut vertical\n  w2 = (W - x) // 2\n  w3 = W - x - w2\n  S2 = w2 * H\n  S3 = w3 * H\n  S_max = max(S1, S3)\n  S_min = min(S1, S2)\n  ans = min(ans, S_max - S_min)\n  # cut horizontal\n  h2 = H // 2\n  h3 = H - h2\n  S2 = (W - x) * h2\n  S3 = (W - x) * h3\n  S_max = max(S1, S3)\n  S_min = min(S1, S2)\n  ans = min(ans, S_max - S_min)\n# first cut horizontal\nfor y in range(1, H):\n  S1 = W * y\n  # cut vertical\n  w2 = W // 2\n  w3 = W - w2\n  S2 = w2 * (H - y)\n  S3 = w3 * (H - y)\n  S_max = max(S1, S3)\n  S_min = min(S1, S2)\n  ans = min(ans, S_max - S_min)\n  # cut horizontal\n  h2 = (H - y) // 2\n  h3 = H - y - h2\n  S2 = W * h2\n  S3 = W * h3\n  S_max = max(S1, S3)\n  S_min = min(S1, S2)\n  ans = min(ans, S_max - S_min)\n\nprint(int(ans))", "passed": true, "time": 0.57, "memory": 14228.0, "status": "done"}, {"code": "def min_value(w, h):\n\tans = float('inf')\n\tfor i in range(1, h):\n\t\ta = w*i\n\t\tv_t = (h-i)//2 * w\n\t\tv_b = (h-i)*w - v_t\n\t\tv_re = max(a, v_t, v_b) - min(a, v_t, v_b)\n\t\th_l = (h-i)*(w//2)\n\t\th_r = (h-i)*w-h_l\n\t\th_re = max(a, h_l, h_r) - min(a, h_l, h_r)\n\t\tans = min(ans, v_re, h_re)\n\treturn ans\n\ndef resolve():\n\th, w = map(int, input().split())\n\ta = min_value(w, h)\n\tb = min_value(h, w)\n\tprint(min(a, b))\nresolve()", "passed": true, "time": 0.49, "memory": 14100.0, "status": "done"}, {"code": "h, w = list(map(int, input().split()))\n\ndef defs(h, w):\n    ans = 10 ** 12\n    for i in range(1, h):\n        sa = i * w\n        h2 = h - i\n\n        for j in range(2):\n            if j == 0:\n                sb = h2 * (w // 2)\n                sc = h2 * (w - (w // 2))\n            else:\n                sb = (h2 // 2) * w\n                sc = (h - i - (h2 // 2)) * w\n\n            s_max = max(sa, sb, sc)\n            s_min = min(sa, sb, sc)\n\n            ans = min(ans, s_max - s_min)\n    return ans\n\nprint((min(defs(h, w), defs(w, h))))\n", "passed": true, "time": 0.6, "memory": 14372.0, "status": "done"}, {"code": "h,w=map(int,input().split())\nif h==2 and w==2:\n  print(1)\n  return\nans=10**10\nif h>=3:\n  if h%3==0:\n    a=0\n  else:\n    a=w\n  if a<ans:\n    ans=a\nif w>=3:\n  if w%3==0:\n    a=0\n  else:\n    a=h\n  if a<ans:\n    ans=a\nif h>1:\n  b=h//3\n  x1=w*b\n  x2=(h-b)*(w//2)\n  x3=h*w-x1-x2\n  a=max(x1,x2,x3)-min(x1,x2,x3)\n  if a<ans:\n    ans=a\n  x1=w*(b+1)\n  x2=(h-b-1)*(w//2)\n  x3=h*w-x1-x2\n  a=max(x1,x2,x3)-min(x1,x2,x3)\n  if a<ans:\n    ans=a\n  b=w//3\n  x1=h*b\n  x2=(w-b)*(h//2)\n  x3=h*w-x1-x2\n  a=max(x1,x2,x3)-min(x1,x2,x3)\n  if a<ans:\n    ans=a\n  x1=h*(b+1)\n  x2=(w-b-1)*(h//2)\n  x3=h*w-x1-x2\n  a=max(x1,x2,x3)-min(x1,x2,x3)\n  if a<ans:\n    ans=a\nprint(ans)", "passed": true, "time": 0.15, "memory": 14180.0, "status": "done"}, {"code": "import sys\nh, w = list(map(int, input().split()))\nif h%3==0 or w%3==0:\n    print((0))\n    return\nans=h*w #inf\nfor i in range(1, h):\n    s1=i*w\n    s2=(h-i)*(w//2)\n    s3=h*w-s1-s2\n    now=max(s1, s2, s3)-min(s1, s2, s3)\n    #print(i, now)\n    ans=min(ans, now)\nfor j in range(1, w):\n    s1=h*j\n    s2=(w-j)*(h//2)\n    s3=h*w-s1-s2\n    now=max(s1, s2, s3)-min(s1, s2, s3)\n    ans=min(ans, now)\nif w>3:\n    ans=min(ans, h)\nif h>3:\n    ans=min(ans, w)\nprint(ans)\n", "passed": true, "time": 0.34, "memory": 14148.0, "status": "done"}, {"code": "#\n# Written by NoKnowledgeGG @YlePhan\n# ('\u03c9')\n#\n#import math\n#mod = 10**9+7\n#import itertools\n#import fractions\n#import numpy as np\n#mod = 10**4 + 7\n\"\"\"def kiri(n,m):\n  r_ = n / m\n  if (r_ - (n // m)) > 0:\n    return (n//m) + 1\n  else:\n    return (n//m)\"\"\"\n\n\"\"\" n! mod m \u968e\u4e57\nmod = 1e9 + 7\nN = 10000000\nfac = [0] * N\ndef ini():\n  fac[0] = 1 % mod\n  for i in range(1,N):\n    fac[i] = fac[i-1] * i % mod\"\"\"\n\n\"\"\"mod = 1e9+7\nN = 10000000\npw = [0] * N\ndef ini(c):\n  pw[0] = 1 % mod\n  for i in range(1,N):\n    pw[i] = pw[i-1] * c % mod\"\"\"\n\n\"\"\"\ndef YEILD():\n  yield 'one'\n  yield 'two'\n  yield 'three'\ngenerator = YEILD()\nprint(next(generator))\nprint(next(generator))\nprint(next(generator))\n\"\"\"\n\"\"\"def gcd_(a,b):\n  if b == 0:#\u7d50\u5c40\u306fc,0\u306e\u6700\u5927\u516c\u7d04\u6570\u306fc\u306a\u306e\u306b\n    return a\n  return gcd_(a,a % b) # a = p * b + q\"\"\"\n\"\"\"def extgcd(a,b,x,y):\n  d = a\n  if b!=0:\n    d = extgcd(b,a%b,y,x)\n    y -= (a//b) * x\n    print(x,y)\n  else:\n    x = 1\n    y = 0\n  return d\"\"\"\n\n\ndef readInts():\n  return list(map(int,input().split()))\nmod = 10**9 + 7\ndef main():\n  H,W = readInts()\n  LIST = [H//2 + W//3 + 1, W//3 + H//2 + 1, H, W]\n  if H%3 == 0 or W % 3 == 0:\n    LIST += [0]\n  if H % 2 == 0:\n    LIST += [H//2]\n  if W % 2 == 0:\n    LIST += [W//2]\n  print(min(LIST))\n  \ndef __starting_point():\n  main()\n__starting_point()", "passed": true, "time": 0.14, "memory": 14176.0, "status": "done"}, {"code": "h,w=list(map(int,input().split()))\nif h%3==0 or w%3==0:\n    print((0))\nelse:\n    num1=max((h//3)*w,(h-(h//3))*(w//2),(h-(h//3))*(w-(w//2)))-min((h//3)*w,(h-(h//3))*(w//2),(h-(h//3))*(w-(w//2)))\n    num2=max((w//3)*h,(w-(w//3))*(h//2),(w-(w//3))*(h-(h//2)))-min((w//3)*h,(w-(w//3))*(h//2),(w-(w//3))*(h-(h//2)))\n    num3=max((h//3+1)*w,(h-(h//3+1))*(w//2),(h-(h//3+1))*(w-(w//2)))-min((h//3+1)*w,(h-(h//3+1))*(w//2),(h-(h//3+1))*(w-(w//2)))\n    num4=max((w//3+1)*h,(w-(w//3+1))*(h//2),(w-(w//3+1))*(h-(h//2)))-min((w//3+1)*h,(w-(w//3+1))*(h//2),(w-(w//3+1))*(h-(h//2)))\n    print((min(num1,num2,num3,num4,h,w)))\n", "passed": true, "time": 0.15, "memory": 14344.0, "status": "done"}, {"code": "H, W = map(int, input().split())\nS = H * W\nans = S\n\nfor h in range(1,H):\n    s1 = h * W\n    s2 = W // 2 * (H-h)\n    s3 = S-s1-s2\n    ans = min(ans,max(s1,s2,s3)-min(s1,s2,s3))\n\n    s2 = (H-h) // 2 * W\n    s3 = S-s1-s2\n    ans = min(ans,max(s1,s2,s3)-min(s1,s2,s3))\n\nfor w in range(1,W):\n    s1 = H * w\n    s2 = H // 2 * (W-w)\n    s3 = S-s1-s2\n    ans = min(ans,max(s1,s2,s3)-min(s1,s2,s3))\n\n    s2 = (W-w) // 2 * H\n    s3 = S-s1-s2\n    ans = min(ans,max(s1,s2,s3)-min(s1,s2,s3))\n\nprint(ans)", "passed": true, "time": 0.5, "memory": 14288.0, "status": "done"}, {"code": "h,w=list(map(int,input().split()))\na1=min(h*(w%3!=0),w*(h%3!=0))\na2=10**6\na3=10**6\nfor i in range(1,h):\n  mx=max(w*i,(w//2)*(h-i),((w+1)//2)*(h-i))\n  mn=min(w*i,(w//2)*(h-i),((w+1)//2)*(h-i))\n  a2=min(a2,mx-mn)\nfor i in range(1,w):\n  mx=max(h*i,(h//2)*(w-i),((h+1)//2)*(w-i))\n  mn=min(h*i,(h//2)*(w-i),((h+1)//2)*(w-i))\n  a3=min(a3,mx-mn)\nprint((min(a1,a2,a3)))\n", "passed": true, "time": 0.41, "memory": 14372.0, "status": "done"}, {"code": "def answer(H,W,ans):\n\n    for x in range(1,W):\n        y1 = H // 2\n        Sa1 = H * x\n        Sb1 = (W - x) * y1\n        Sc1 = (W - x) * (H - y1)\n        M = max(Sa1,Sb1,Sc1)\n        m = min(Sa1,Sb1,Sc1)\n\n        y2 = (W - x) // 2\n        Sa2 = H * x\n        Sb2 = H * y2\n        Sc2 = H * (W - x - y2)\n        M2 = max(Sa2,Sb2,Sc2)\n        m2 = min(Sa2,Sb2,Sc2)\n\n        if ans > min(M-m,M2-m2):\n            ans = min(M-m,M2-m2)\n\n    return ans\n\ndef __starting_point():\n    H,W = [int(i) for i in input().split()]\n    ans = H * W\n    ans = answer(H,W,ans)\n\n    H,W = W,H\n\n    if answer(H,W,ans) < ans:\n        ans = answer(H,W,ans)\n\n    print(ans)\n\n__starting_point()", "passed": true, "time": 0.65, "memory": 14164.0, "status": "done"}, {"code": "h, w = map(int, input().split())\n\np1 = [(h//3) * w, (h//3) * w, (h-2*(h//3))*w]\np2 = [(w//3) * h, (w//3) * h, (w-2*(w//3))*h]\np3 = [(h//3) * w, (h - h//3)* (w//2), h*w - (h//3) * w - (h - h//3)* (w//2)]\np4 = [(w//3) * h, (w - w//3)* (h//2), h*w - (w//3) * h - (w - w//3)* (h//2)]\n\np5 = [(h//3 + 1) * w, (h//3 + 1) * w, (h-2*(h//3 + 1))*w]\np6 = [(w//3 + 1) * h, (w//3 + 1) * h, (w-2*(w//3 + 1))*h]\np7 = [(h//3 + 1) * w, (h - h//3 - 1)* (w//2), h*w - (h//3 + 1) * w - (h - h//3 - 1)* (w//2)]\np8 = [(w//3 + 1) * h, (w - w//3 - 1)* (h//2), h*w - (w//3 + 1) * h - (w - w//3 - 1)* (h//2)]\n\nprint(min(max(p1)-min(p1), max(p2)-min(p2), max(p3)-min(p3), max(p4)-min(p4), max(p5)-min(p5), max(p6)-min(p6), max(p7)-min(p7), max(p8)-min(p8)))", "passed": true, "time": 0.14, "memory": 14252.0, "status": "done"}, {"code": "#!/usr/bin/env python3\n\n\ndef main():\n    H, W = list(map(int, input().split()))\n    if H % 3 == 0 or W % 3 == 0:\n        print((0))\n    else:\n        ans = min(W,H)\n\n        # H\u30921:2\u3067\u5206\u5272\n        for i in range(3):\n            d = (H // 3)- 1 + i\n            if d > 0:\n                choco = [d * W, (H-d) * (W//2), (H-d) * (W - W//2)]\n                ans = min(ans, max(choco) - min(choco))\n        \n        # W\u30921:2\u3067\u5206\u5272\n        for i in range(3):\n            d = (W // 3)- 1 + i\n            if d > 0:\n                choco = [d * H, (W-d) * (H//2), (W-d) * (H - H//2)]\n                ans = min(ans, max(choco) - min(choco))\n        \n        print(ans)\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14264.0, "status": "done"}, {"code": "def divide_into_three(X, Y):\n    minimum = float(\"inf\")\n    for x in range(1, X):\n        b1 = x * Y\n        if not all(((X - x) & 1, Y & 1)):\n            b2 = b3 = ((X - x) * Y) >> 1\n        else:\n            s, l = sorted((X - x, Y))\n            b2 = s * (l >> 1)\n            b3 = s * l - b2\n        diff = max((b1, b2, b3)) - min((b1, b2, b3))\n        minimum = min(minimum, diff)\n    return minimum\n\nH, W = map(int, input().split())\nprint(min(divide_into_three(H, W), divide_into_three(W, H)))", "passed": true, "time": 0.4, "memory": 14144.0, "status": "done"}, {"code": "import sys\nreadline = sys.stdin.readline\nfrom math import floor, ceil\nfrom decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN\n\ndef round(f, r=0):\n    return Decimal(str(f)).quantize(Decimal(str(r)), rounding=ROUND_HALF_UP)\n\ndef main():\n    H, W = map(int, readline().rstrip().split())\n    ans = H * W\n    if H >= 3:\n        y1 = int(round(H/3))\n        y2 = (H-y1) // 2\n        y3 = H - y1 - y2\n        ans = min(ans, max(W*y1, W*y2, W*y3)-min(W*y1, W*y2, W*y3))\n    if W >= 3:\n        x1 = int(round(W/3))\n        x2 = (W-x1) // 2\n        x3 = W - x1 - x2\n        ans = min(ans, max(x1*H, x2*H, x3*H)-min(x1*H, x2*H, x3*H))\n    \n    # \u7e26\u306b\u30b9\u30e9\u30a4\u30b9 + \u6b8b\u308a\u306b\u6a2a\u306b\u30b9\u30e9\u30a4\u30b9\n    x1_cand = [int(round(W/3))]\n    y1 = H\n    for x1 in x1_cand:\n        x2 = W - x1\n        x3 = x2\n        y2 = H // 2\n        y3 = H - y2\n        ans = min(ans, max((x1*y1), (x2*y2), (x3*y3)) - min((x1*y1), (x2*y2), (x3*y3)))\n\n    # \u6a2a\u306b\u30b9\u30e9\u30a4\u30b9 + \u6b8b\u308a\u306b\u7e26\u306b\u30b9\u30e9\u30a4\u30b9\n    y1_cand = [int(round(H/3))]\n    x1 = W\n    for y1 in y1_cand:\n        y2 = H - y1\n        y3 = y2\n        x2 = W // 2\n        x3 = W - x2\n        ans = min(ans, max((x1*y1), (x2*y2), (x3*y3)) - min((x1*y1), (x2*y2), (x3*y3)))\n\n    print(ans)\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.15, "memory": 14428.0, "status": "done"}, {"code": "h,w=map(int,input().split())\nmin_ = h*w\nif h % 3 == 0:\n  min_ = 0\nelse:\n  min_ = min(min_, w)\nif w % 3 == 0:\n  min_ = 0\nelse:\n  min_ = min(min_, h)\nfor i in range(1, w):\n  p1 = h//2*i\n  p2 = (h-h//2)*i\n  p3 = h*(w-i)\n  min_ = min(min_, max(p1,p2,p3)-min(p1,p2,p3))\nfor i in range(1, h):\n  p1 = w//2*i\n  p2 = (w-w//2)*i\n  p3 = w*(h-i)\n  min_ = min(min_, max(p1,p2,p3)-min(p1,p2,p3))\nprint(min_)", "passed": true, "time": 0.33, "memory": 14136.0, "status": "done"}, {"code": "# \u7d20\u76f4\u306b\u5168\u63a2\u7d22\u3057\u305f\u307b\u3046\u304c\u697d\nH,W = (int(T) for T in input().split())\nminSH = H*W\nminSW = H*W\nfor TH in range(1,H):\n    BlockA = TH*W\n\n    if TH<=(H-2):\n        BlockB1 = ((H-TH)//2)*W\n        BlockC1 = H*W-(BlockA+BlockB1)\n        BigSCa1 = max(BlockA,BlockB1,BlockC1)\n        SmlSCa1 = min(BlockA,BlockB1,BlockC1)\n        DifSCa1 = BigSCa1-SmlSCa1\n    else:\n        DifSCa1 = H*W\n\n    if W>=2:\n        BlockB2 = (H-TH)*(W//2)\n        BlockC2 = H*W-(BlockA+BlockB2)\n        BigSCa2 = max(BlockA,BlockB2,BlockC2)\n        SmlSCa2 = min(BlockA,BlockB2,BlockC2)\n        DifSCa2 = BigSCa2-SmlSCa2\n    else:\n        DifSCa2 = H*W\n\n    if min(DifSCa1,DifSCa2)<minSH:\n        minSH = min(DifSCa1,DifSCa2)\n\nfor TW in range(1,W):\n    BlockA = H*TW\n\n    if TW<=(W-2):\n        BlockB1 = H*((W-TW)//2)\n        BlockC1 = H*W-(BlockA+BlockB1)\n        BigSCa1 = max(BlockA,BlockB1,BlockC1)\n        SmlSCa1 = min(BlockA,BlockB1,BlockC1)\n        DifSCa1 = BigSCa1-SmlSCa1\n    else:\n        DifSCa1 = H*W\n\n    if H>=2:\n        BlockB2 = (H//2)*(W-TW)\n        BlockC2 = H*W-(BlockA+BlockB2)\n        BigSCa2 = max(BlockA,BlockB2,BlockC2)\n        SmlSCa2 = min(BlockA,BlockB2,BlockC2)\n        DifSCa2 = BigSCa2-SmlSCa2\n    else:\n        DifSCa2 = H*W\n\n    if min(DifSCa1,DifSCa2)<minSW:\n        minSW = min(DifSCa1,DifSCa2)\n\nprint(min(minSH,minSW))", "passed": true, "time": 0.55, "memory": 14452.0, "status": "done"}, {"code": "h, w = list(map(int, input().split()))\n\nans = 10 ** 10\nfor i in range(h):\n    x = (i + 1) * w\n    mid = (h - i - 1) // 2\n    y = mid * w\n    z = (h - i - 1 - mid) * w\n    ans = min(ans, max(x, y, z) - min(x, y, z))\n\n    mid = w // 2\n    y = (h - i - 1) * mid\n    z = (h - i - 1) * (w - mid)\n    ans = min(ans, max(x, y, z) - min(x, y, z))\n\nfor j in range(w):\n    x = (j + 1) * h\n    mid = (w - j - 1) // 2\n    y = mid * h\n    z = (w - j - 1 - mid) * h\n    ans = min(ans, max(x, y, z) - min(x, y, z))\n\n    mid = h // 2\n    y = (w - j - 1) * mid\n    z = (w - j - 1) * (h - mid)\n    ans = min(ans, max(x, y, z) - min(x, y, z))\n\nprint(ans)\n", "passed": true, "time": 0.57, "memory": 14208.0, "status": "done"}, {"code": "def abc062_c():\n    h, w = map(int, input().split())\n    # 2 <= h, w \u306e\u305f\u30811\u306e\u5834\u5408\u306f\u8003\u3048\u306a\u3044\n    # \u3069\u3061\u3089\u304b\u304c3\u306e\u500d\u6570\u306a\u3089\u3074\u3063\u305f\u308a3\u5206\u5272\u3067\u304d\u308b (\u5e73\u884c2\u7dda)\n    if h % 3 == 0 or w % 3 == 0:\n        print(0)\n        return\n    # \u5e73\u884c2\u7dda\u3067\u5272\u308b\u3068\u304d\u306e\u5dee\u5206\u6700\u5c0f\u306f\u3001\u77ed\u8fba1\u672c\u5206\n    ans = min(h, w)\n    # \u305d\u308c\u4ee5\u5916\u306f\u4f8b2\u4f8b3\u306e\u5272\u308a\u65b9 (\u76f4\u4ea42\u7dda)\n    for x, y in [(w, h), (h, w)]:\n        for i in range(1, x):\n            sa = i * y\n            sb = (x - i) * (y // 2)\n            sc = (x - i) * (y - y // 2)\n            diff = max(sa, sb, sc) - min(sa, sb, sc)\n            ans = min(diff, ans)\n    print(ans)\n\nabc062_c()", "passed": true, "time": 0.34, "memory": 14296.0, "status": "done"}, {"code": "H,W=list(map(int,input().split()))\n\nif H%3==0 or W%3==0:\n  print((0))\n  return\n\nA=0\nB=0\nans=H*W\n\nif H%2==0:\n  A=H//2\n  B=H//2\nelse:\n  A=H//2+1\n  B=H-A\nfor i in range(1,W):\n  S1=A*i\n  S2=B*i\n  S3=(W-i)*H\n  SMaxMin=max(S1,S2,S3)-min(S1,S2,S3)\n  ans=min(ans,SMaxMin)\nif W%2==0:\n  A=W//2\n  B=W//2\nelse:\n  A=W//2+1\n  B=W-A;\nfor i in range(1,H):\n  S1=A*i\n  S2=B*i\n  S3=(H-i)*W\n  SMaxMin=max(S1,S2,S3)-min(S1,S2,S3)\n  ans=min(ans,SMaxMin)\nif H>=3:\n  ans=min(ans,W)\nif W>=3:\n  ans=min(ans,H)\nprint(ans)\n", "passed": true, "time": 0.67, "memory": 14160.0, "status": "done"}, {"code": "H,W = [int(i) for i in input().split()]\nans = H * W\n\nfor x in range(1,W):\n    y1 = H // 2\n    Sa1 = H * x\n    Sb1 = (W - x) * y1\n    Sc1 = (W - x) * (H - y1)\n    M = max(Sa1,Sb1,Sc1)\n    m = min(Sa1,Sb1,Sc1)\n\n    y2 = (W - x) // 2\n    Sa2 = H * x\n    Sb2 = H * y2\n    Sc2 = H * (W - x - y2)\n    M2 = max(Sa2,Sb2,Sc2)\n    m2 = min(Sa2,Sb2,Sc2)\n\n    if ans > min(M-m,M2-m2):\n        ans = min(M-m,M2-m2)\n\nH,W = W,H\nfor x in range(1,W):\n    y = H // 2\n    Sa1 = H * x\n    Sb1 = (W - x) * y\n    Sc1 = (W - x) * (H - y)\n    M = max(Sa1,Sb1,Sc1)\n    m = min(Sa1,Sb1,Sc1)\n\n    y2 = (W - x) // 2\n    Sa2 = H * x\n    Sb2 = H * y2\n    Sc2 = H * (W - x - y2)\n    M2 = max(Sa2,Sb2,Sc2)\n    m2 = min(Sa2,Sb2,Sc2)\n\n    if ans > min(M-m,M2-m2):\n        ans = min(M-m,M2-m2)\n\nprint(ans)\n", "passed": true, "time": 0.52, "memory": 14164.0, "status": "done"}, {"code": "h,w=map(int,input().split())\nif h%3==0 or w%3==0:\n  print(0)\nelse:\n  temp=[w,h]\n  if h%2==0 and w%2==0:\n    temp.append(abs(int(w//3+1)*h-int(w-w//3-1)*int(h//2)))\n    temp.append(abs(int(w//3)*h-int(w-w//3)*int(h//2)))        \n    temp.append(abs(int(h//3+1)*w-int(h-h//3-1)*int(w//2)))\n    temp.append(abs(int(h//3)*w-int(h-h//3)*int(w//2)))  \n  elif h%2==0:\n    temp.append(max(int(h//3*w),int(h-h//3)*int(w//2),int(h-h//3)*int(w//2+1))-min(int(h//3*w),int(h-h//3)*int(w//2),int(h-h//3)*int(w//2+1)))\n    temp.append(max(int(h//3+1)*w,int(h-h//3-1)*int(w//2),int(h-h//3-1)*int(w//2+1))-min(int(h//3+1)*w,int(h-h//3-1)*int(w//2),int(h-h//3-1)*int(w//2+1)))\n    temp.append(abs(int(w//3+1)*h-int(w-w//3-1)*int(h//2)))\n    temp.append(abs(int(w//3)*h-int(w-w//3)*int(h//2)))             \n  elif w%2==0:\n    temp.append(max(int(w//3*h),int(w-w//3)*int(h//2),int(w-w//3)*int(h//2+1))-min(int(w//3*h),int(w-w//3)*int(h//2),int(w-w//3)*int(h//2+1)))\n    temp.append(max(int(w//3+1)*h,int(w-w//3-1)*int(h//2),int(w-w//3-1)*int(h//2+1))-min(int(w//3+1)*h,int(w-w//3-1)*int(h//2),int(w-w//3-1)*int(h//2+1)))\n    temp.append(abs(int(h//3+1)*w-int(h-h//3-1)*int(w//2)))\n    temp.append(abs(int(h//3)*w-int(h-h//3)*int(w//2)))                \n  else:\n    temp.append(max(int(h//3*w),int(h-h//3)*int(w//2),int(h-h//3)*int(w//2+1))-min(int(h//3*w),int(h-h//3)*int(w//2),int(h-h//3)*int(w//2+1)))\n    temp.append(max(int(h//3+1)*w,int(h-h//3-1)*int(w//2),int(h-h//3-1)*int(w//2+1))-min(int(h//3+1)*w,int(h-h//3-1)*int(w//2),int(h-h//3-1)*int(w//2+1)))\n    temp.append(max(int(w//3*h),int(w-w//3)*int(h//2),int(w-w//3)*int(h//2+1))-min(int(w//3*h),int(w-w//3)*int(h//2),int(w-w//3)*int(h//2+1)))\n    temp.append(max(int(w//3+1)*h,int(w-w//3-1)*int(h//2),int(w-w//3-1)*int(h//2+1))-min(int(w//3+1)*h,int(w-w//3-1)*int(h//2),int(w-w//3-1)*int(h//2+1)))\n  print(min(temp))", "passed": true, "time": 0.47, "memory": 14444.0, "status": "done"}, {"code": "h, w = list(map(int, input().split()))\nans = 10**9\nif h % 3 == 0 or w % 3 == 0:\n    ans = 0\nelse:\n    for width in range(1, w):\n        left = width * h\n        if h % 2 == 0:\n            right_up   = (w-width)*(h//2)\n            right_down = right_up\n        else:\n            right_up   = (w-width)*(h//2+1)\n            right_down = (w-width)*(h//2)\n        ans = min(ans, max(left, right_up, right_down) - min(left, right_up, right_down))\n    for height in range(1, h):\n        up = w * height\n        if w % 2 == 0:\n            down_left  =  (w//2)*(h-height)\n            down_right =  down_left\n        else:\n            down_left  =  (w//2)*(h-height)\n            down_right =  (w//2+1)*(h-height)\n        ans = min(ans, max(up, down_left, down_right) - min(up, down_left, down_right))\n    ans = min(ans, min(h, w))\nprint(ans)\n", "passed": true, "time": 0.33, "memory": 14152.0, "status": "done"}, {"code": "h,w = map(int,input().split())\n\nif h % 3 == 0 or w % 3 == 0:\n    print(0)\nelse:\n    best = (h*w)/3\n    # w\u304b\u3089\u5272\u308b\u65b9\u6cd5\n    col_num = int(round(best/h))\n    remain_w = w - col_num\n    h1 = h // 2\n    h2 = h - h1\n    w1 = remain_w // 2\n    w2 = remain_w - w1\n    min_area1 = min(remain_w*h1, remain_w*h2, col_num*h) # \u5782\u76f4\n    max_area1 = max(remain_w*h1, remain_w*h2, col_num*h)\n    min_area2 = min(w2*h, w1*h, col_num*h) # \u5e73\u884c\n    max_area2 = max(w2*h, w1*h, col_num*h)\n    num_w1 = max_area1 - min_area1\n    num_w2 = max_area2 - min_area2\n    # h\u304b\u3089\u5272\u308b\u65b9\u6cd5\n    row_num = int(round(best/w))\n    remain_h = h - row_num\n    w1 = w // 2\n    w2 = w - w1\n    h1 = remain_h // 2\n    h2 = remain_h - h1\n    min_area1 = min(remain_h*w1, remain_h*w2, row_num*w) # \u5782\u76f4\n    max_area1 = max(remain_h*w1, remain_h*w2, row_num*w)\n    min_area2 = min(h2*w, h1*w, row_num*w) # \u5e73\u884c   \n    max_area2 = max(h2*w, h1*w, row_num*w)\n    num_h1 = max_area1 - min_area1\n    num_h2 = max_area2 - min_area2\n    print(min(num_h1,num_w1,num_h2,num_w2))", "passed": true, "time": 0.15, "memory": 14312.0, "status": "done"}, {"code": "import collections \nh,w = map(int,input().split())\n\ndef hkara(h,w):\n  hans = 10**9\n  for i in range(1,h):\n    #yoko\n    fst = w*i\n    snd = w//2*(h-i)\n    trd = (w-w//2)*(h-i)\n    mx = max(max(fst,snd),trd)\n    mn = min(min(fst,snd),trd)\n    hans = min(mx-mn,hans)\n    #tate\n    tfst = w*i\n    tsnd = (h-i)//2*w\n    ttrd = (h-(h-i)//2-i)*w\n    tmx = max(max(tfst,tsnd),ttrd)\n    tmn = min(min(tfst,tsnd),ttrd)\n    hans = min(tmx-tmn,hans)\n  return hans\n\ndef wkara(h,w):\n  wans = 10**9\n  for i in range(1,w):\n    fst = h*i\n    snd = h//2*(w-i)\n    trd = (h-h//2)*(w-i)\n    mx = max(max(fst,snd),trd)\n    mn = min(min(fst,snd),trd)\n    wans = min(mx-mn,wans)\n    #tate\n    tfst = h*i\n    tsnd = (w-i)//2*h\n    ttrd = (w-(w-i)//2-i)*h\n    tmx = max(max(tfst,tsnd),ttrd)\n    tmn = min(min(tfst,tsnd),ttrd)\n    wans = min(tmx-tmn,wans)\n  return wans\n\nprint(min(hkara(h,w),wkara(h,w)))", "passed": true, "time": 0.7, "memory": 14428.0, "status": "done"}, {"code": "h,w=list(map(int,input().split()))\n\ndef sds(h,w):\n    sdmin=h*w\n    for hi in range(1,h):\n        s1=hi*w\n        s2=(h-hi)*(w//2)\n        s3=(h-hi)*(w-w//2)\n        sd=max(s1,s2,s3)-min(s1,s2,s3)\n        sdmin=min(sdmin,sd)\n    \n        h2=(h-hi)//2\n        s2=h2*w\n        s3=(h-hi-h2)*w\n        sd=max(s1,s2,s3)-min(s1,s2,s3)\n        sdmin=min(sdmin,sd)\n\n    return sdmin\n\nprint((min(sds(h,w),sds(w,h))))\n", "passed": true, "time": 0.53, "memory": 14292.0, "status": "done"}, {"code": "from math import ceil\n\n\ndef main():\n    H, W = list(map(int, input().split()))\n    if H*W % 3 == 0:\n        print((0))\n        return\n    ans1 = float('inf')\n    ans2 = float('inf')\n    ans3 = min(H, W)\n    # h == T\u306e\u4e0a\n    for h in range(1, H + 1):\n        if W % 2 == 0:\n            ans1 = min(ans1, abs(h*(W//2) - W*(H - h)))\n        else:\n            ans1 = min(\n                ans1,\n                max([\n                    abs((h*(W//2) - W*(H - h))),\n                    abs(h*((W + 1)//2) - W*(H - h)),\n                    h\n                ]))\n    for w in range(1, W + 1):\n        if H % 2 == 0:\n            ans2 = min(ans2, abs(w*(H//2) - H*(W - w)))\n        else:\n            ans2 = min(\n                ans2, max([abs((w*(H//2) - H*(W - w))), abs(w*((H + 1)//2) - H*(W - w)), w]))\n    print((min([ans1, ans2, ans3])))\n    return\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.34, "memory": 14096.0, "status": "done"}, {"code": "def main():\n    H, W = (int(_) for _ in input().split())\n    INF = 10 ** 11\n\n    def calc(h, w):\n        # \u7e26\u306b\u5272\u308b\n        w1 = w // 2\n        w2 = w - w1\n        ret = INF\n        for hh in range(1, h):\n            ret = min(ret, max(w * hh, (h-hh)*w1, (h-hh)*w2) - min(w * hh, (h-hh)*w1, (h-hh)*w2))\n        #\u6a2a\u306b\u5272\u308b\n        for hh in range(1, h):\n            h1 = (h-hh)//2\n            h2 = h - hh - h1\n            ret = min(ret, max(w*hh, w*h1, w*h2) - min(w*hh, w*h1, w*h2))\n        return ret\n    m1 = calc(H, W)\n    m2 = calc(W, H)\n    print((min(m1, m2)))\n    return\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.6, "memory": 14164.0, "status": "done"}, {"code": "H, W = map(int, input().split())\n\nh = min(H, W)\nw = max(H, W)\ns = h*w\n\nres = 10**10\n\nfor i in range(1, w):\n    a = h*i\n    b = (w-i)//2*h\n    c = s-a-b\n    res = min(max(a, b, c)-min(a, b, c), res)\n\n    b = (w-i)*(h//2)\n    c = s-a-b\n    res = min(max(a, b, c)-min(a, b, c), res)\n\n\nfor i in range(1, h):\n    a = w*i\n    \n    b = (h-i)//2*w\n    c = s-a-b\n    res = min(max(a, b, c)-min(a, b, c), res)\n\n    b = (h-i)*(w//2)\n    c = s-a-b\n    res = min(max(a, b, c)-min(a, b, c), res)\n\nprint(res)", "passed": true, "time": 0.51, "memory": 14380.0, "status": "done"}, {"code": "H,W=map(int,input().split())\n\nif H%3==0 or W%3==0:\n  print(0)\nelif H==2 or W==2:\n  ans0=min(H,W)\n  \n  H,W=min(H,W),max(H,W)\n  w1=W//3\n  w2=W-w1\n  s1=2*w1\n  s2=w2\n  ans1=s2-s1\n  \n  w1=W//3+1\n  w2=W-w1\n  s1=2*w1\n  s2=w2\n  ans2=s1-s2\n  print(min(ans0,ans1,ans2))\nelse:\n  ans0=min(H,W)\n  \n  h1=H//2\n  h2=H-h1\n  \n  w1=W//3\n  w2=W-w1\n  s1=w1*H\n  s2=w2*h1\n  s3=w2*h2\n  ans1=max(s1,s2,s3)-min(s1,s2,s3)\n  \n  w1=W//3+1\n  w2=W-w1\n  s1=w1*H\n  s2=w2*h1\n  s3=w2*h2\n  ans2=max(s1,s2,s3)-min(s1,s2,s3)\n  \n  H,W=W,H\n  h1=H//2\n  h2=H-h1\n  \n  w1=W//3\n  w2=W-w1\n  s1=w1*H\n  s2=w2*h1\n  s3=w2*h2\n  ans3=max(s1,s2,s3)-min(s1,s2,s3)\n  \n  w1=W//3+1\n  w2=W-w1\n  s1=w1*H\n  s2=w2*h1\n  s3=w2*h2\n  ans4=max(s1,s2,s3)-min(s1,s2,s3)\n  print(min(ans0,ans1,ans2,ans3,ans4))", "passed": true, "time": 0.26, "memory": 14432.0, "status": "done"}, {"code": "h,w=map(int,input().split())\nstand=h*w/3\nprevh,prevw=1,1\nmini=10**18\nfor i in range(2,h+1):\n    if abs(stand-i*w)<abs(stand-prevh*w):\n        prevh=i\nif h-prevh>=2:\n    mini=min(mini,max((h-prevh)//2*w,prevh*w,-(-(h-prevh)//2)*w)-min((h-prevh)//2*w,prevh*w,-(-(h-prevh)//2)*w))\nmini=min(mini,max(w//2*(h-prevh),prevh*w,-(-w//2)*(h-prevh))-min(w//2*(h-prevh),prevh*w,-(-w//2)*(h-prevh)))\n#print(mini)\nfor i in range(2,w+1):\n    if abs(stand-i*h)<abs(stand-prevw*h):\n        prevw=i\nif w-prevw>=2:\n    mini=min(mini,max((w-prevw)//2*h,prevw*h,-(-(w-prevw)//2)*h)-min((w-prevw)//2*h,prevw*h,-(-(w-prevw)//2)*h))\nmini=min(mini,max(h//2*(w-prevw),prevw*h,-(-h//2)*(w-prevw))-min(h//2*(w-prevw),prevw*h,-(-h//2)*(w-prevw)))\nprint(mini)", "passed": true, "time": 0.31, "memory": 14112.0, "status": "done"}, {"code": "import sys\n\n\ndef main():\n    h, w = map(int, input().split())\n    if h % 3 == 0 or w % 3 == 0:\n        print(0)\n        return\n\n    pattern = [h, w]\n    for x in range(1, w//2 + 2):\n        first = x * h\n        h1 = h // 2\n        h2 = h - h1\n        second = (w-x) * h1\n        thrid = (w-x) * h2\n        result = max(first, second, thrid) - min(first, second, thrid)\n        pattern.append(result)\n\n    for y in range(1, h//2 + 2):\n        first = y * w\n        w1 = w // 2\n        w2 = w - w1\n        second = (h-y) * w1\n        thrid = (h-y) * w2\n        result = max(first, second, thrid) - min(first, second, thrid)\n        pattern.append(result)\n\n    print(min(pattern))\n\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.37, "memory": 17328.0, "status": "done"}, {"code": "def f(x,y,z):\n    return max(x,y,z)-min(x,y,z)\n\nh, w = list(map(int, input().split()))\nl = []\nans1, ans2 = h*w, h*w\nfor i in range(1,h//2+1):\n        s1 = i*w\n        s2 = w*((h-i)//2)\n        s3 = h*w-s1-s2\n        s4 = (h-i)*(w//2)\n        s5 = h*w-s1-s4\n        ans1 = min(ans1, f(s1,s2,s3),f(s1,s4,s5))\n\nfor i in range(1,w//2+1):\n        s1 = i*h\n        s2 = h*((w-i)//2)\n        s3 = h*w-s1-s2\n        s4 = (w-i)*(h//2)\n        s5 = h*w-s1-s4\n        ans2 = min(ans2, f(s1,s2,s3),f(s1,s4,s5))\nprint((min(ans1,ans2)))\n", "passed": true, "time": 0.33, "memory": 14352.0, "status": "done"}, {"code": "import sys\ninput = sys.stdin.readline\n\nH,W = list(map(int,input().split()))\nS = H*W\ns1 = 0\nans = 10**10\nfor i in range(1,H):\n    s1 += W\n    s2 = (H-i)*(W//2)\n    s3 = S - s1 -s2\n    ans = min(ans,(max(s1,s2,s3)-min(s1,s2,s3)))\n\n    s2 = ((H-i)//2)*W\n    s3 = S - s1 -s2\n    ans = min(ans,(max(s1,s2,s3)-min(s1,s2,s3)))\n\ns1 = 0\nfor i in range(1,W):\n    s1 += H\n    s2 = (W-i)*(H//2)\n    s3 = S - s1 -s2\n    ans = min(ans,(max(s1,s2,s3)-min(s1,s2,s3)))\n\n    s2 = ((W-i)//2)*H\n    s3 = S - s1 -s2\n    ans = min(ans,(max(s1,s2,s3)-min(s1,s2,s3)))\n\nprint(ans)\n", "passed": true, "time": 0.51, "memory": 14304.0, "status": "done"}, {"code": "H, W = list(map(int, input().split(' ')))\n\nans = []\n\nfor h in range(1, H):\n    r1 = h * W\n\n    h = H - h\n\n    r2a = h // 2 * W\n    r3a = -1 * (-h // 2) * W\n    r2b = W // 2 * h\n    r3b = -1 * (-W // 2) * h\n\n    ans.append(max(r1, r2a, r3a) - min(r1, r2a, r3a))\n    ans.append(max(r1, r2b, r3b) - min(r1, r2b, r3b))\n\nfor w in range(1, W):\n    r1 = H * w\n\n    w = W - w\n\n    r2a = H // 2 * w\n    r3a = -1 * (-H // 2) * w\n    r2b = w // 2 * H\n    r3b = -1 * (-w // 2) * H\n\n    ans.append(max(r1, r2a, r3a) - min(r1, r2a, r3a))\n    ans.append(max(r1, r2b, r3b) - min(r1, r2b, r3b))\n\nprint((min(ans)))\n", "passed": true, "time": 0.51, "memory": 30424.0, "status": "done"}, {"code": "import sys\nreadline = sys.stdin.readline\nfrom decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN\n\ndef round(f, r=0):\n    return Decimal(str(f)).quantize(Decimal(str(r)), rounding=ROUND_HALF_UP)\n\ndef main():\n    H, W = map(int, readline().rstrip().split())\n    ans = H * W\n    if H >= 3:\n        y1 = int(round(H/3))\n        y2 = (H-y1) // 2\n        y3 = H - y1 - y2\n        ans = min(ans, max(W*y1, W*y2, W*y3)-min(W*y1, W*y2, W*y3))\n    if W >= 3:\n        x1 = int(round(W/3))\n        x2 = (W-x1) // 2\n        x3 = W - x1 - x2\n        ans = min(ans, max(x1*H, x2*H, x3*H)-min(x1*H, x2*H, x3*H))\n    \n    # \u7e26\u306b\u30b9\u30e9\u30a4\u30b9 + \u6b8b\u308a\u306b\u6a2a\u306b\u30b9\u30e9\u30a4\u30b9\n    x1 = int(round(W/3))\n    y1 = H\n    x2 = W - x1\n    x3 = x2\n    y2 = H // 2\n    y3 = H - y2\n    ans = min(ans, max((x1*y1), (x2*y2), (x3*y3)) - min((x1*y1), (x2*y2), (x3*y3)))\n\n    # \u6a2a\u306b\u30b9\u30e9\u30a4\u30b9 + \u6b8b\u308a\u306b\u7e26\u306b\u30b9\u30e9\u30a4\u30b9\n    y1 = int(round(H/3))\n    x1 = W\n    y2 = H - y1\n    y3 = y2\n    x2 = W // 2\n    x3 = W - x2\n    ans = min(ans, max((x1*y1), (x2*y2), (x3*y3)) - min((x1*y1), (x2*y2), (x3*y3)))\n\n    print(ans)\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.15, "memory": 14216.0, "status": "done"}, {"code": "h, w = list(map(int, input().split()))\n\n\ndef calc(a, b):\n    ret = a * b\n    for i in range(1, a):\n        area1 = b // 2 * i\n        area2 = -(-b // 2) * i\n        area3 = a * b - (area1 + area2)\n        #print(area1, area2, area3)\n        ret = min(ret, max(area1, area2, area3) - min(area1, area2, area3))\n    return ret\n\nif h % 3 == 0 or w % 3 == 0:\n    print((0))\nelse:\n    ans = h * w\n    for i in range(1, max(h, w) - 1):\n        area1 = min(h, w) * i\n        area2 = min(h, w) * ((max(h, w) - i) // 2)\n        area3 = min(h, w) * (-(-(max(h, w) - i) // 2))\n        #print(area1, area2, area3)\n        ans = min(ans, max(area1, area2, area3) - min(area1, area2, area3))\n    print((min(calc(h, w), calc(w, h), ans)))\n", "passed": true, "time": 0.63, "memory": 14180.0, "status": "done"}, {"code": "import sys\n\ndef solve(h, w):\n  res = [((h + 2) // 3 - h // 3) * w]\n  for d in [h // 3, (h + 2) // 3]:\n    cand = sorted([d * w, (h - d) * (w // 2), (h - d) * ((w + 1) // 2)])\n    res.append(cand[-1] - cand[0])\n  return min(res)\n\nh, w = map(int, sys.stdin.readline().split())\n\ndef main():\n  print(min(solve(h, w), solve(w, h)))\n\ndef __starting_point():\n  main()\n__starting_point()", "passed": true, "time": 0.14, "memory": 14324.0, "status": "done"}, {"code": "h, w = map(int, input().split())\n\nans = 10**9\nfor i in range(1,h):\n  x = h-i\n  s0 = i*w\n  s1 = x*(w//2)\n  s2 = x*(w-w//2)\n  s = max(s0,s1,s2)-min(s0,s1,s2)\n  ans = min(ans,s)\n  s3 = w*(x//2)\n  s4 = w*(x-x//2)\n  s = max(s0,s3,s4)-min(s0,s3,s4)\n  ans = min(ans,s)\n\nfor i in range(1,w):\n  x = w-i\n  s0 = i*h\n  s1 = x*(h//2)\n  s2 = x*(h-h//2)\n  s = max(s0,s1,s2)-min(s0,s1,s2)\n  ans = min(ans,s)\n  s3 = h*(x//2)\n  s4 = h*(x-x//2)\n  s = max(s0,s3,s4)-min(s0,s3,s4)\n  ans = min(ans, s)\nprint(ans)", "passed": true, "time": 0.52, "memory": 14344.0, "status": "done"}, {"code": "h, w = map(int, input().split())\nif not h%3 or not w%3:\n  print(0)\nelse:\n  ans = min([h, w])\n  for i in range(h):\n    sub = max([abs(w*i-w//2*(h-i)), abs(w*i-(w-w//2)*(h-i))])\n    if ans > sub:\n      ans = sub\n  for i in range(w):\n    sub = max([abs(h*i-h//2*(w-i)), abs(h*i-(h-h//2)*(w-i))])\n    if ans > sub:\n      ans = sub\n  print(ans)", "passed": true, "time": 0.31, "memory": 14112.0, "status": "done"}, {"code": "h,w=list(map(int,input().split()))\nans=[]\nimport sys\ndef s(a,b):\n    for i in range(a):\n        s=a*b\n        x=i*b\n        y=((a-i)//2)*b\n        z=s-x-y\n\n        d=(a-i)*(b//2)\n        e=s-x-d\n        ma=max(x,y,z)\n        mi=min(x,y,z)\n        mc=max(x,e,d)\n        mn=min(x,e,d)\n        res=min((ma-mi),(mc-mn))\n        ans.append(res)\n    return min(ans)\n        \nf=s(h,w)\ng=s(w,h)\nprint((min(f,g)))\n    \n# print(ans)\n# print(min(ans))\n    \n", "passed": true, "time": 0.51, "memory": 22008.0, "status": "done"}, {"code": "h,w = list(map(int, input().split()))\nans = 10**10\nif h%3 == 0 or w%3 == 0:\n    print(0)\n    return\n    \nfor H in range(1, h + 1):\n    a = H * w\n    b = (h - H) * (w // 2)\n    c = (h - H) * (w - w // 2)\n    ans = min(ans, max(a,b,c) - min(a,b,c))\n\nfor W in range(1, w + 1):\n    a = W * h\n    b = (w - W) * (h // 2)\n    c = (w - W) * (h - h // 2)\n    ans = min(ans, max(a,b,c) - min(a,b,c))\n\nif h > 3:\n    ans = min(ans, w*((h+2)//3) - w*(h//3))\n\nif w > 3:\n    ans = min(ans, h*((w+2)//3) - h*(w//3))\n    \nprint(ans)", "passed": true, "time": 0.33, "memory": 14140.0, "status": "done"}, {"code": "import sys\n\nsys.setrecursionlimit(10 ** 7)\nf_inf = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef resolve():\n    H, W = list(map(int, input().split()))\n\n    if H % 3 == 0 or W % 3 == 0:\n        print((0))\n        return\n\n    res = f_inf\n    for h in range(H):\n        A = h * W\n\n        B = W * ((H - h) // 2)\n        C = W * ((H - h) - (H - h) // 2)\n        ma = max(A, B, C)\n        mi = min(A, B, C)\n        res = min(res, ma - mi)\n\n        B = (H - h) * (W // 2)\n        C = (H - h) * (W - W // 2)\n        ma = max(A, B, C)\n        mi = min(A, B, C)\n        res = min(res, ma - mi)\n\n    for w in range(W):\n        A = w * H\n\n        B = H * ((W - w) // 2)\n        C = H * ((W - w) - (W - w) // 2)\n        ma = max(A, B, C)\n        mi = min(A, B, C)\n        res = min(res, ma - mi)\n\n        B = (W - w) * (H // 2)\n        C = (W - w) * (H - H // 2)\n        ma = max(A, B, C)\n        mi = min(A, B, C)\n        res = min(res, ma - mi)\n\n    print(res)\n\n\ndef __starting_point():\n    resolve()\n\n__starting_point()", "passed": true, "time": 0.56, "memory": 14180.0, "status": "done"}, {"code": "h,w = map(int, input().split())\nans = 10**9\nfor p,o in zip([h,w],[w,h]):\n  for i in range(1, p//2 + 1):\n    sa = i * o\n    hi = (p-i)//2\n    sb = o * hi\n    sc = o * (p - i - hi)\n    t = max(sa,sb,sc) - min(sa,sb,sc)\n    ans = min(ans, t)\n    \n    wi = o//2\n    sb = (p - i) * wi\n    sc = (p - i) * (o - wi)\n    t = max(sa,sb,sc) - min(sa,sb,sc)\n    ans = min(ans, t)\nprint(ans)", "passed": true, "time": 0.33, "memory": 14284.0, "status": "done"}, {"code": "H, W = map(int, input().split())\nM = 10 ** 10\n\nif H == 2 and W == 2:\n    M = 1\n\nif H > 2:\n    HH = H // 3\n    S1 = HH * W\n    HH = H - H // 3\n    HHH = HH // 2\n    S2 = HHH * W\n    HHH = HH - HH // 2\n    S3 = HHH * W\n    m = max(S1, S2, S3) - min(S1, S2, S3)\n    M = min(M, m)\n\n    HH = H // 3\n    S1 = HH * W\n    WW = W // 2\n    S2 = (H - HH) * WW\n    WW = W - W // 2\n    S3 = (H - HH) * WW\n    m = max(S1, S2, S3) - min(S1, S2, S3)\n    M = min(M, m)\n\n    HH = H // 3 + 1\n    S1 = HH * W\n    WW = W // 2\n    S2 = (H - HH) * WW\n    WW = W - W // 2\n    S3 = (H - HH) * WW\n    m = max(S1, S2, S3) - min(S1, S2, S3)\n    M = min(M, m)\n\nif W > 2:\n    WW = W // 3\n    S1 = WW * H\n    WW = W - W // 3\n    WWW = WW // 2\n    S2 = WWW * H\n    WWW = WW - WW // 2\n    S3 = WWW * H\n    m = max(S1, S2, S3) - min(S1, S2, S3)\n    M = min(M, m)\n\n    WW = W // 3\n    S1 = WW * H\n    HH = H // 2\n    S2 = (W - WW) * HH\n    HH = H - H // 2\n    S3 = (W - WW) * HH\n    m = max(S1, S2, S3) - min(S1, S2, S3)\n    M = min(M, m)\n\n    WW = W // 3 + 1\n    S1 = WW * H\n    HH = H // 2\n    S2 = (W - WW) * HH\n    HH = H - H // 2\n    S3 = (W - WW) * HH\n    m = max(S1, S2, S3) - min(S1, S2, S3)\n    M = min(M, m)\n\nprint(M)", "passed": true, "time": 0.14, "memory": 14176.0, "status": "done"}, {"code": "h,w = map(int,input().split())\nans = h*w\nfor i in range(1,h):\n    A = w*i\n    if w%2 == 0 or (h-i)%2 == 0:\n        B = ((h-i)*w)//2\n        C = ((h-i)*w)//2\n    else:\n        if h-i <= w:\n            B = (h-i)*((w//2)+1)\n            C = (h-i)*(w//2)\n        else:\n            B = ((h-i)//2 + 1) * w\n            C = ((h-i)//2) * w\n    ans = min(ans,max(A,max(B,C)) - min(A,min(B,C)))\n\nfor i in range(1,w):\n    A = h*i\n    if (w-i)%2 == 0 or h%2 == 0:\n        B = ((w-i)*h)//2\n        C = ((w-i)*h)//2\n    else:\n        if w-i <= h:\n            B = (w-i)*((h//2)+1)\n            C = (w-i)*(h//2)\n        else:\n            B = ((w-i)//2 + 1) * h\n            C = ((w-i)//2) * h\n    ans = min(ans,max(A,max(B,C)) - min(A,min(B,C)))\nprint(ans)", "passed": true, "time": 0.48, "memory": 14236.0, "status": "done"}, {"code": "def main():\n    h, w = list(map(int, input().split()))\n    if h % 3 == 0 or w % 3 == 0:\n        print((0))\n        return\n\n    ans = h * w\n    for _ in range(2):\n        i = h // 3\n        j = w // 2\n\n        x = [(i - 1, h - i + 1), (i, h - i), (i + 1, h - i - 1)]\n        y = [(j - 1, w - j + 1), (j, w - j), (j + 1, w - j - 1)]\n        for (u, v) in x:\n            # case1\n            a, b = v // 2, v - v // 2\n            s = [w * u, w * a, w * b]\n            d = max(s) - min(s)\n            ans = min(ans, d)\n            for (s, t) in y:\n                # case2\n                s = [u * w, v * s, v * t]\n                d = max(s) - min(s)\n                ans = min(ans, d)\n\n        w, h = h, w\n    print(ans)\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14408.0, "status": "done"}, {"code": "H,W = map(int, input().split())\n\ndif = 10**10\n\nif H%3==0 or W%3==0:\n\tprint(0)\n\treturn\n\nfor i in range(H):\n\ta = i*W\n\th = (H-i)//2\n\tabc = [a, h*W, (H-i-h)*W]\n\tif not(0 in abc):\n\t\tdif = min(dif, max(abc)-min(abc))\n\t\n\th = H-i\n\tw = W//2\n\tabc = [a, h*w, h*(W-w)]\n\tif not(0 in abc):\n\t\tdif = min(dif, max(abc)-min(abc))\n\nfor i in range(W):\n\ta = H*i\n\tw = (W-i)//2\n\tabc = [a, H*w, H*(W-i-w)]\n\tif not(0 in abc):\n\t\tdif = min(dif, max(abc)-min(abc))\n\t\n\tw = W-i\n\th = H//2\n\tabc = [a, h*w, (H-h)*w]\n\tif not(0 in abc):\n\t\tdif = min(dif, max(abc)-min(abc))\n\nprint(dif)", "passed": true, "time": 0.58, "memory": 14372.0, "status": "done"}, {"code": "from sys import stdin\ndef main():\n    #\u5165\u529b\n    readline=stdin.readline\n    h,w=map(int,readline().split())\n\n    if h*w%3==0:\n        ans=0\n    else:\n        ans=float(\"inf\")\n        #\u7e26\u65b9\u5411\u306b\u5168\u63a2\u7d22\n        s1=w//2*h\n        s2=h*w-s1\n        for i in range(1,h):\n            s3=i*w\n            s1-=w//2\n            s2-=w-w//2\n            ans=min(ans,max(s1,s2,s3)-min(s1,s2,s3))\n\n        for i in range(1,h-1):\n            s3=i*w\n            s1=(h-i)//2*w\n            s2=h*w-s3-s1\n            ans=min(ans,max(s1,s2,s3)-min(s1,s2,s3))\n\n        #\u6a2a\u65b9\u5411\u306b\u5168\u63a2\u7d22\n        s1=h//2*w\n        s2=h*w-s1\n        for j in range(1,w):\n            s3=j*h\n            s1-=h//2\n            s2-=h-h//2\n            ans=min(ans,max(s1,s2,s3)-min(s1,s2,s3))\n        \n        for j in range(1,w-1):\n            s3=j*h\n            s1=(w-j)//2*h\n            s2=h*w-s3-s1\n            ans=min(ans,max(s1,s2,s3)-min(s1,s2,s3))\n\n    print(ans)\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.53, "memory": 14264.0, "status": "done"}, {"code": "import sys\nreadline = sys.stdin.readline\nfrom math import floor, ceil\n\ndef main():\n    H, W = map(int, readline().rstrip().split())\n    ans = H * W\n    if H >= 3:\n        ans = min(ans, abs(W*(H//3) - W*(H-H//3*2)))\n    if W >= 3:\n        ans = min(ans, abs(H*(W//3) - H*(W-W//3*2)))\n    \n    # \u7e26\u306b\u30b9\u30e9\u30a4\u30b9 + \u6b8b\u308a\u306b\u6a2a\u306b\u30b9\u30e9\u30a4\u30b9\n    # x1_cand = [floor(W/3), ceil(W/3)]\n    x1_cand = [i for i in range(1, W)]\n    y1 = H\n    for x1 in x1_cand:\n        x2 = W - x1\n        x3 = x2\n        y2 = H // 2\n        y3 = H - y2\n        ans = min(ans, max((x1*y1), (x2*y2), (x3*y3)) - min((x1*y1), (x2*y2), (x3*y3)))\n\n        x2 = (W-x1) // 2\n        x3 = (W-x1-x2)\n        ans = min(ans, max((x1*H), (x2*H), (x3*H)) - min((x1*H), (x2*H), (x3*H)))\n\n    # \u6a2a\u306b\u30b9\u30e9\u30a4\u30b9 + \u6b8b\u308a\u306b\u7e26\u306b\u30b9\u30e9\u30a4\u30b9\n    # y1_cand = [floor(H/3), ceil(H/3)]\n    y1_cand = [i for i in range(1, H)]\n    x1 = W\n    for y1 in y1_cand:\n        y2 = H - y1\n        y3 = y2\n        x2 = W // 2\n        x3 = W - x2\n        ans = min(ans, max((x1*y1), (x2*y2), (x3*y3)) - min((x1*y1), (x2*y2), (x3*y3)))\n\n        y2 = (H-y1) // 2\n        y3 = (H-y1-y2)\n        ans = min(ans, max((W*y1), (W*y2), (W*y3)) - min((W*y1), (W*y2), (W*y3)))\n\n    print(ans)\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.59, "memory": 20780.0, "status": "done"}, {"code": "h , w = list(map(int, input().split()))\nmi=h*w\ns=h*w\nfor i in range(h):\n    s1=w*i\n    if w%2==0 or (h-i)%2==0:\n        s2=(s-s1)//2\n        s3=s2\n    elif h-i<w:\n        s2=(h-i)*(w-1)//2\n        s3=(h-i)*(w+1)//2\n    else:\n        s2=(h-i-1)//2*w\n        s3=(h-i+1)//2*w\n    d=abs(min(s1,s2,s3)-max(s1,s2,s3))\n    if d<mi:\n        mi=d\nfor i in range(w):\n    s1=h*i\n    if (w-i)%2==0 or h%2==0:\n        s2=(s-s1)//2\n        s3=s2\n    elif w-i<h:\n        s2=(w-i)*(h-1)//2\n        s3=(w-i)*(h+1)//2\n    else:\n        s2=(w-i-1)//2*h\n        s3=(w-i+1)//2*h\n    d=abs(min(s1,s2,s3)-max(s1,s2,s3))\n    if d<mi:\n        mi=d\nprint(mi)\n", "passed": true, "time": 0.31, "memory": 14392.0, "status": "done"}, {"code": "h, w = list(map(int, input().split()))\ntanpen = min(h, w)\nchohen = max(h, w)\n\nif h%3 == 0 or w%3 == 0:\n    print((0))\nelse:\n    def findmin(h, w):\n        ans = h*w\n        for i in range(1, h):\n            remi = h - i\n            s1 = i*w\n            s2 = (w//2) * remi\n            s3 = (w - w//2) * remi\n            ans = min(ans, max(s1, s2, s3) - min(s1, s2))\n\n            s2 = w * (remi//2)\n            s3 = w * (remi - remi//2)\n            ans = min(ans, max(s1, s2, s3) - min(s1, s2))\n        return ans\n    print((min(findmin(h, w), findmin(w, h))))\n", "passed": true, "time": 0.5, "memory": 14272.0, "status": "done"}, {"code": "# coding: utf-8\nimport re\nimport math\nfrom collections import defaultdict\nfrom collections import deque\nimport collections\nfrom fractions import Fraction\nimport itertools\nfrom copy import deepcopy\nimport random\nimport time\nimport os\nimport queue\nimport sys\nimport datetime\nfrom functools import lru_cache\n#@lru_cache(maxsize=None)\nreadline=sys.stdin.readline\nsys.setrecursionlimit(2000000)\n#import numpy as np\nalphabet=\"abcdefghijklmnopqrstuvwxyz\"\nmod=int(10**9+7)\ninf=int(10**20)\ndef yn(b):\n    if b:\n        print(\"yes\")\n    else:\n        print(\"no\")\ndef Yn(b):\n    if b:\n        print(\"Yes\")\n    else:\n        print(\"No\")\ndef YN(b):\n    if b:\n        print(\"YES\")\n    else:\n        print(\"NO\")\nclass union_find():\n    def __init__(self,n):\n        self.n=n\n        self.P=[a for a in range(n)]\n        self.rank=[0]*n\n \n    def find(self,x):\n        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])\n        return self.P[x]\n \n    def same(self,x,y):\n        return self.find(x)==self.find(y)\n \n    def link(self,x,y):\n        if self.rank[x]<self.rank[y]:\n            self.P[x]=y\n        elif self.rank[y]<self.rank[x]:\n            self.P[y]=x\n        else:\n            self.P[x]=y\n            self.rank[y]+=1\n \n    def unite(self,x,y):\n        self.link(self.find(x),self.find(y))\n \n    def size(self):\n        S=set()\n        for a in range(self.n):\n            S.add(self.find(a))\n        return len(S)\ndef ispow(a,b):#a\u306fb\u306e\u7d2f\u4e57\u6570\u304b\n    now=b\n    while now<a:\n        now*=b\n    if now==a:return True\n    else:return False\ndef getbin(num,size):\n    A=[0]*size\n    for a in range(size):\n        if (num>>(size-a-1))&1==1:\n            A[a]=1\n        else:\n            A[a]=0\n    return A\ndef getfacs(n,mod_=0):\n    A=[1]*(n+1)\n    for a in range(2,len(A)):\n        A[a]=A[a-1]*a\n        if(mod_>0):A[a]%=mod_\n    return A\ndef comb(n,r,mod,fac):\n    if(n-r<0):return 0\n    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod\ndef nextcomb(num,size):\n    x=num&(-num)\n    y=num+x\n    z=num&(~y)\n    z//=x\n    z=z>>1\n    num=(y|z)\n    if(num>=(1<<size)):return False\n    else:return num\ndef getprimes(n,type=\"int\"):\n    if n==0:\n        if type==\"int\":return []\n        else:return [False]\n    A=[True]*(n+1)\n    A[0]=False\n    A[1]=False\n    for a in range(2,n+1):\n        if A[a]:\n            for b in range(a*2,n+1,a):\n                A[b]=False\n    if(type==\"bool\"):return A\n    B=[]\n    for a in range(n+1):\n        if(A[a]):B.append(a)\n    return B\ndef isprime(num):\n    if(num<=1):return False\n    i=2\n    while i*i<=num:\n       if(num%i==0):return False\n       i+=1\n    return True\ndef ifelse(a,b,c):\n    if a:return b\n    else:return  c\ndef join(A,c=\"\"):\n    n=len(A)\n    A=list(map(str,A))\n    s=\"\"\n    for a in range(n):\n        s+=A[a]\n        if(a<n-1):s+=c\n    return s\ndef factorize(n,type_=\"dict\"):\n    b = 2\n    list_ = []\n    while b * b <= n:\n        while n % b == 0:\n            n //= b\n            list_.append(b)\n        b+=1\n    if n > 1:list_.append(n)\n    if type_==\"dict\":\n        dic={}\n        for a in list_:\n            if a in dic:\n                dic[a]+=1\n            else:\n                dic[a]=1\n        return dic\n    elif type_==\"list\":\n        return list_\n    else:\n        return None\ndef pm(x):\n    return x//abs(x)\ndef inputintlist():\n    return list(map(int,input().split()))\n######################################################################################################\n\nH,W=inputintlist()\nans=inf\nfor a in range(1,H):\n    A=a*W\n    #\u4e26\u884c\u306b\u5206\u5272\n    B=((H-a)//2)*W\n    C=H*W-A-B\n    ans=min(ans,max([A,B,C])-min([A,B,C]))\n    \n    #\u5782\u76f4\u306b\u5206\u5272\n    B=(W//2)*(H-a)\n    C=H*W-A-B\n    ans=min(ans,max([A,B,C])-min([A,B,C]))\n    \nH,W=W,H\nfor a in range(1,H):\n    A=a*W\n    #\u4e26\u884c\u306b\u5206\u5272\n    B=((H-a)//2)*W\n    C=H*W-A-B\n    ans=min(ans,max([A,B,C])-min([A,B,C]))\n    \n    #\u5782\u76f4\u306b\u5206\u5272\n    B=(W//2)*(H-a)\n    C=H*W-A-B\n    ans=min(ans,max([A,B,C])-min([A,B,C]))\n    \n\nprint(ans)\n\n\n\n\n\n\n\n\n\n\n", "passed": true, "time": 0.64, "memory": 17904.0, "status": "done"}, {"code": "h,w=map(int,input().split())\na1=min(h*(w%3!=0),w*(h%3!=0))\na2=10**6\na3=10**6\nfor i in range(1,h):\n  mx=max(w*i,(w//2)*(h-i),((w+1)//2)*(h-i))\n  mn=min(w*i,(w//2)*(h-i),((w+1)//2)*(h-i))\n  a2=min(a2,mx-mn)\nfor i in range(1,w):\n  mx=max(h*i,(h//2)*(w-i),((h+1)//2)*(w-i))\n  mn=min(h*i,(h//2)*(w-i),((h+1)//2)*(w-i))\n  a3=min(a3,mx-mn)\nprint(min(a1,a2,a3))", "passed": true, "time": 0.41, "memory": 14264.0, "status": "done"}]