Language: C++

#include <iostream>
#include <vector>
#include <cstdint>

using i64 = int64_t;
using i32 = int32_t;

void run() {
    i32 h, w;
    std::cin >> h >> w;
    std::vector<std::vector<i32>> a;
    for (i32 i = 0; i < h; ++i) {
        std::vector<i32> b;
        for (i32 j = 0; j < w; ++j) {
            i32 v;
            std::cin >> v;
            b.emplace_back(v);
        }
        a.push_back(b);
    }
    for (auto& b : a) {
        for (auto& c : b) {
            i32 d;
            std::cin >> d;
            c -= d;
            c = std::abs(c);
        }
    }
    const i32 m = (80 + 80) * 80;
    using bits = std::bitset<2 * m + 1>;
    std::vector<bits> now(w);
    now.at(0).set(m);
    for (const auto& b : a) {
        std::vector<bits> next;
        bits prev(0);
        for (i32 i = 0; i < w; ++i) {
            i32 d = b.at(i);
            bits val = prev | now.at(i);
            bits ans = (val << d) | (val >> d);
            next.push_back(ans);
            prev = ans;
        }
        now = next;
    }
    i32 ans = m;
    bits& cond = now.at(w - 1);
    for (i32 i = 0; i <= 2 * m; ++i) {
        if (cond.test(i)) {
            ans = std::min(ans, std::abs(m - i));
        }
    }
    std::cout << ans << '\n';
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    run();
    return 0;
}


Compiler output:
a.cc: In function 'void run()':
a.cc:30:23: error: 'bitset' in namespace 'std' does not name a template type
   30 |     using bits = std::bitset<2 * m + 1>;
      |                       ^~~~~~
a.cc:4:1: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>'
    3 | #include <cstdint>
  +++ |+#include <bitset>
    4 | 
a.cc:31:17: error: 'bits' was not declared in this scope
   31 |     std::vector<bits> now(w);
      |                 ^~~~
a.cc:31:21: error: template argument 1 is invalid
   31 |     std::vector<bits> now(w);
      |                     ^
a.cc:31:21: error: template argument 2 is invalid
a.cc:32:9: error: request for member 'at' in 'now', which is of non-class type 'int'
   32 |     now.at(0).set(m);
      |         ^~
a.cc:34:25: error: template argument 2 is invalid
   34 |         std::vector<bits> next;
      |                         ^
a.cc:35:13: error: expected ';' before 'prev'
   35 |         bits prev(0);
      |             ^~~~~
      |             ;
a.cc:38:17: error: expected ';' before 'val'
   38 |             bits val = prev | now.at(i);
      |                 ^~~~
      |                 ;
a.cc:39:17: error: expected ';' before 'ans'
   39 |             bits ans = (val << d) | (val >> d);
      |                 ^~~~
      |                 ;
a.cc:40:18: error: request for member 'push_back' in 'next', which is of non-class type 'int'
   40 |             next.push_back(ans);
      |                  ^~~~~~~~~
a.cc:40:28: error: 'ans' was not declared in this scope; did you mean 'abs'?
   40 |             next.push_back(ans);
      |                            ^~~
      |                            abs
a.cc:41:13: error: 'prev' was not declared in this scope; did you mean 'std::prev'?
   41 |             prev = ans;
      |             ^~~~
      |             std::prev
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: 'std::prev' declared here
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:46:11: error: 'cond' was not declared in this scope
   46 |     bits& cond = now.at(w - 1);
      |           ^~~~
a.cc:46:22: error: request for member 'at' in 'now', which is of non-class type 'int'
   46 |     bits& cond = now.at(w - 1);
      |                      ^~