Language: C++

#include <bits/stdc++.h>
using namespace std;

int main(){
  long long h, w; cin >> h >> w;
  vector<vector<long long> a(h + 1, vector<long long>(w + 1, 0));
  vector<vector<long long> b(h + 1, vector<long long>(w + 1, 0));
  vector<vector<long long> sa(h + 1, vector<long long>(w + 1, 0));
  for(int i = 1; i < h + 1; i++){
    for(int j = 1; j < w + 1; j++){
      cin >> a.at(i).at(j);
    }
  }
  for(int i = 1; i < h + 1; i++){
    for(int j = 1; j < w + 1; j++){
      cin >> b.at(i).at(j);
      sa.at(i).at(j) = a.at(i).at(j) - b.at(i).at(j);
      if(sa.at(i).at(j) < 0) sa.at(i).at(j) *= -1;
    }
  }
  long long k = 80 * 80 * 80;
  vector<vector<vector<int>>> dp(h + 1, vector<vector<int>(k, 0)>(w + 1));
  for(int i = 1; i < h + 1; i++){
    for(int j = 1; j < w + 1; j++){
      for(int l = 0; l < k; l++){
        long long kpi, kpj, kmi, kmj;
        kpi = l + sa.at(i).at(j);
        kpj = l + sa.at(i).at(j);
        kmi = l - sa.at(i).at(j);
        kmj = l - sa.at(i).at(j);
        if(kmi < 0) kmi *= -1;
        if(kmj < 0) kmj *= -1;
        if(dp.at(i - 1).at(j).at(kpi) == 1 | dp.at(i - 1).at(j).at(kmi) == 1 | dp.at(i).at(j - 1).at(kpi) == 1 | dp.at(i).at(j - 1).at(kmi) == 1){
          dp.at(i).at(j).at(l) = 1;
        }
      }
    }
  }
  for(int i = 0; i < k; i++){
    if(dp.at(h + 1).at(w + 1).at(i) == 1){
      cout << i;
      return 0;
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:64: error: template argument 1 is invalid
    6 |   vector<vector<long long> a(h + 1, vector<long long>(w + 1, 0));
      |                                                                ^
a.cc:6:64: error: template argument 2 is invalid
a.cc:7:64: error: template argument 1 is invalid
    7 |   vector<vector<long long> b(h + 1, vector<long long>(w + 1, 0));
      |                                                                ^
a.cc:7:64: error: template argument 2 is invalid
a.cc:8:65: error: template argument 1 is invalid
    8 |   vector<vector<long long> sa(h + 1, vector<long long>(w + 1, 0));
      |                                                                 ^
a.cc:8:65: error: template argument 2 is invalid
a.cc:11:14: error: 'a' was not declared in this scope
   11 |       cin >> a.at(i).at(j);
      |              ^
a.cc:16:14: error: 'b' was not declared in this scope
   16 |       cin >> b.at(i).at(j);
      |              ^
a.cc:17:7: error: 'sa' was not declared in this scope
   17 |       sa.at(i).at(j) = a.at(i).at(j) - b.at(i).at(j);
      |       ^~
a.cc:17:24: error: 'a' was not declared in this scope
   17 |       sa.at(i).at(j) = a.at(i).at(j) - b.at(i).at(j);
      |                        ^
a.cc:22:48: error: temporary of non-literal type 'std::vector<int>' in a constant expression
   22 |   vector<vector<vector<int>>> dp(h + 1, vector<vector<int>(k, 0)>(w + 1));
      |                                                ^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:428:11: note: 'std::vector<int>' is not literal because:
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector<int>' has a non-trivial destructor
a.cc:22:65: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector'
   22 |   vector<vector<vector<int>>> dp(h + 1, vector<vector<int>(k, 0)>(w + 1));
      |                                                                 ^
a.cc:22:65: note:   expected a type, got 'std::vector<int>(((std::vector<int>::size_type)k), 0, std::allocator<int>())'
a.cc:22:65: error: template argument 2 is invalid
a.cc:27:19: error: 'sa' was not declared in this scope
   27 |         kpi = l + sa.at(i).at(j);
      |                   ^~