Language: C++

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define inf 1000000000000000000
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  
  ll h, w; cin >> h >> w;
  vector<vector<ll>> a(h, vector<ll>(w));
  vector<vector<ll>> b(h, vector<ll>(w));
  vector<vector<ll>> c(h, vector<ll>(w));
  rep(i, h) {
    rep(j, w) {
      cin >> a[i][j];
    }
  }
  rep(i, h) {
    rep(j, w) {
      cin >> b[i][j];
    }
  }
  rep(i, h) {
    rep(j, w) {
      c[i][j] = abs(a[i][j] - b[i][j]);
    }
  }

  vector<vector<vector<ll>>> dp(h, vector<vector<ll>>(w,vector<ll>(80 * (h + w) + 1)), false);
  dp[0][0][c[0][0]] = true;
  rep(i, h) {
    rep(j, w) {
      rep(k, 80 * (h + w) + 1) {
        if (0 <= i + 1 && i + 1 < h && dp[i][j][k]) {
          if (0 <= k + c[i + 1][j] && k + c[i + 1][j] <= 80 * (h + w)) dp[i + 1][j][k + c[i + 1][j]] = true;
          if (0 <= abs(k - c[i + 1][j]) && abs(k - c[i + 1][j]) <= 80 * (h + w)) dp[i + 1][j][abs(k - c[i + 1][j])] = true;
        }
        if (0 <= j + 1 && j + 1 < w && dp[i][j][k]) {
          if (0 <= k + c[i][j + 1] && k + c[i][j + 1] <= 80 * (h + w)) dp[i][j + 1][k + c[i][j + 1]] = true;
          if (0 <= abs(k - c[i][j + 1]) && abs(k - c[i][j + 1]) <= 80 * (h + w)) dp[i][j + 1][abs(k - c[i][j + 1])] = true;
        }
      }
    }
  }
  rep(k, 80 * (h + w) + 1) {
    if (dp[h - 1][w - 1][k]) {
      cout << k << endl;
      exit(0);
    }
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:93: error: no matching function for call to 'std::__debug::vector<std::__debug::vector<std::__debug::vector<long long int> > >::vector(ll&, std::__debug::vector<std::__debug::vector<long long int> >, bool)'
   39 |   vector<vector<vector<ll>>> dp(h, vector<vector<ll>>(w,vector<ll>(80 * (h + w) + 1)), false);
      |                                                                                             ^
In file included from /usr/include/c++/14/vector:76,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:2:
/usr/include/c++/14/debug/vector:212:9: note: candidate: 'template<class _InputIterator, class> std::__debug::vector<_Tp, _Allocator>::vector(_InputIterator, _InputIterator, const _Allocator&) [with <template-parameter-2-2> = _InputIterator; _Tp = std::__debug::vector<std::__debug::vector<long long int> >; _Allocator = std::allocator<std::__debug::vector<std::__debug::vector<long long int> > >]'
  212 |         vector(_InputIterator __first, _InputIterator __last,
      |         ^~~~~~
/usr/include/c++/14/debug/vector:212:9: note:   template argument deduction/substitution failed:
a.cc:39:93: note:   deduced conflicting types for parameter '_InputIterator' ('long long int' and 'std::__debug::vector<std::__debug::vector<long long int> >')
   39 |   vector<vector<vector<ll>>> dp(h, vector<vector<ll>>(w,vector<ll>(80 * (h + w) + 1)), false);
      |                                                                                             ^
/usr/include/c++/14/debug/vector:250:7: note: candidate: 'std::__debug::vector<_Tp, _Allocator>::vector(_Base_ref) [with _Tp = std::__debug::vector<std::__debug::vector<long long int> >; _Allocator = std::allocator<std::__debug::vector<std::__debug::vector<long long int> > >]'
  250 |       vector(_Base_ref __x)
      |       ^~~~~~
/usr/include/c++/14/debug/vector:250:7: note:   candidate expects 1 argument, 3 provided
/usr/include/c++/14/debug/vector:241:7: note: candidate: 'std::__debug::vector<_Tp, _Allocator>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = std::__debug::vector<std::__debug::vector<long long int> >; _Allocator = std::allocator<std::__debug::vector<std::__debug::vector<long long int> > >; allocator_type = std::allocator<std::__debug::vector<std::__debug::vector<long long int> > >]'
  241 |       vector(initializer_list<value_type> __l,
      |       ^~~~~~
/usr/include/c++/14/debug/vector:241:7: note:   candidate expects 2 arguments, 3 provided
/usr/include/c++/14/debug/vector:232:7: note: candidate: 'std::__debug::vector<_Tp, _Allocator>::vector(std::__debug::vector<_Tp, _Allocator>&&, std::__type_identity_t<_Alloc>&) [with _Tp = std::__debug::vector<std::__debug::vector<long long int> >; _Allocator = std::allocator<std::__debug::vector<std::__debug::vector<long long int> > >; std::__type_identity_t<_Alloc> = std::allocator<std::__debug::vector<std::__debug::vector<long long int> > >]'
  232 |       vector(vector&& __x, const __type_identity_t<allocator_type>& __a)
      |       ^~~~~~
/usr/include/c++/14/debug/vector:232:7: note:   candidate expects 2 arguments, 3 provided
/usr/include/c++/14/debug/vector:228:7: note: candidate: 'std::__debug::vector<_Tp, _Allocator>::vector(const std::__debug::vector<_Tp, _Allocator>&, std::__type_identity_t<_Alloc>&) [with _Tp = std::__debug::vector<std::__debug::vector<long long int> >; _Allocator = std::allocator<std::__debug::vector<std::__debug::vector<long long int> > >; std::__type_identity_t<_Alloc> = std::allocator<std::__debug::vector<std::__debug::vector<long long int> > >]'
  228 |       vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
      |       ^~~~~~
/usr/include/c++/14/debug/vector:228:7: note:   candidate expects 2 arguments, 3 provided
/usr/include/c++/14/debug/vector:225:7: note: candidate: 'std::__debug::vector<_Tp, _Allocator>::vector(std::__debug::vector<_Tp, _Allocator>&&) [with _Tp = std::__debug::vector<std::__debug::vector<long long int> >; _Allocator = std::allocator<std::__debug::vector<std::__debug::vector<long long int> > >]'
  225 |       vector(vector&&) = default;
      |       ^~~~~~
/usr/include/c++/14/debug/vector:225:7: note:   candidate expects 1 argument, 3 provided
/usr/include/c++/14/debug/vector:224:7: note: candidate: 'std::__debug::vector<_Tp, _Allocator>::vector(const std::__debug::vector<_Tp, _Allocator>&) [with _Tp = std::__debug::vector<std::__debug::vector<long long int> >; _Allocator = std::allocator<std::__debug::vector<std::__debug::vector<long long int> > >]'
  224 |       vector(const vector&) = default;
      |       ^~~~~~
/usr/include/c++/14/debug/vector:224:7: note:   candidate expects 1 argument, 3 provided
/usr/include/c++/14/debug/vector:195:7: note: candidate: 'std::__debug::vector<_Tp, _Allocator>::vector(size_type, std::__type_identity_t<_Alloc>&, const _Allocator&) [with _Tp = std::__debug::vector<std::__debug::vector<long long int> >; _Allocator = std::allocator<std::__debug::vector<std::__debug::vector<long long int> > >; size_type = long unsigned int; std::__type_identity_t<_Alloc> = std::__debug::vector<std::__debug::vector<long long int> >]'
  195 |       vector(size_type __n, const __type_identity_t<_Tp>& __value,
      |       ^~~~~~
/usr/include/c++/14/debug/vector:196:32: note:   no known conversion for argument 3 from 'bool' to 'const std::allocator<std::__debug::vector<std::__debug::vector<long long int> > >&'
  196 |              const _Allocator& __a = _Allocator())
      |              ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/debug/vector:191:7: note: candidate: 'std::__debug::vector<_Tp, _Allocator>::vector(size_type, const _Allocator&) [with _Tp = std::__debug::vector<std::__debug::vector<long long int> >; _Allocator = std::allocator<std::__debug::vector<std::__debug::vector<long long int> > >; size_type = long unsigned int]'
  191 |       vector(size_type __n, const _Allocator& __a = _Allocator())
      |       ^~~~~~
/usr/include/c++/14/debug/vector:191:7: note:   candidate expects 2 arguments, 3 provided
/usr/include/c++/14/debug/vector:185:7: note: candidate: 'std::__debug::vector<_Tp, _Allocator>::vector(const _Allocator&) [with _Tp = std::__debug::vector<std::__debug::vector<long long int> >; _Allocator = std::allocator<std::__debug::vector<std::__debug::vector<long long int> > >]'
  185 |       vector(const _Allocator& __a) _GLIBCXX_NOEXCEPT
      |       ^~~~~~
/usr/include/c++/14/debug/vector:185:7: note:   candidate expects 1 argument, 3 provided
/usr/include/c++/14/debug/vector:180:7: note: candidate: 'std::__debug::vector<_Tp, _Allocator>::vector() [with _Tp = std::__debug::vector<std::__debug::vector<long long int> >; _Allocator = std::allocator<std::__debug::vector<std::__debug::vector<long long int> > >]'
  180 |       vector() = default;
      |       ^~~~~~
/usr/include/c++/14/debug/vector:180:7: note:   candidate expects 0 arguments, 3 provided