Language: C++

        #include <bits/stdc++.h>
        #include<iostream>
        #include<cstdio>
        #include<vector>
        #include<queue>
        #include<map>
        #include<cstring>
        #include<string>
        #include <math.h>
        #include<algorithm>
    //    #include <boost/multiprecision/cpp_int.hpp>
        #include<functional>
      #define int long long
        #define inf  1000000007
        #define pa pair<int,int>
#define ll long long
        #define pal pair<ll,ll>
        #define ppa pair<int,pa>
        #define  mp make_pair
        #define EPS (1e-10)
        #define equals(a,b) (fabs((a)-(b))<EPS)

        using namespace std;

        class Point{
        	public:
        	double x,y;
        	Point(double x=0,double y=0):x(x),y(y) {}
        	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
        	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
        	Point operator * (double a) {return Point(x*a,y*a);}
        	Point operator / (double a) {return Point(x/a,y/a);}
        	double absv() {return sqrt(norm());}
        	double norm() {return x*x+y*y;}
        	bool operator < (const Point &p) const{
        		return x != p.x ? x<p.x: y<p.y;
        	}
        	bool operator == (const Point &p) const{
        		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
        	}
        };
        typedef Point Vector;

        struct Segment{
        Point p1,p2;
        };

    double hen(Vector a){
    if(fabs(a.x)<EPS && a.y>0) return acos(0);
    else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
    else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
    else if(fabs(a.y)<EPS && a.x>0) return 0.0;
    else if(a.y>0) return acos(a.x/a.absv());
    else return 2*acos(0)+acos(-a.x/a.absv());

    }

        double dot(Vector a,Vector b){
        	return a.x*b.x+a.y*b.y;
        }
        double cross(Vector a,Vector b){
        	return a.x*b.y-a.y*b.x;
        }
        int dx[4] = {1, 0, -1, 0};
        int dy[4] = {0, 1, 0, -1};
        //----------------kokomade temple------------
int a[400][5]={0};

int dp[310][310][310];
signed main(){
string s;

	int h,w;
	cin>>h>>w;
	
	for(int i=1;i<=h;i++){
		cin>>s;
		for(int j=0;j<w;j++){
			a[i][j+1]=1+(s[j]-'a');
		}
		
	}
	
	
	
	for(int i=0;i<=304;i++)for(int j=0;j<=304;j++) for(int k=0;k<=304;k++) dp[i][j][k]=inf;
	dp[0][0][0]=0;
	
	for(int i=0;i<=h;i++)for(int j=0;j<=h;j++) for(int k=0;k<=h;k++){
		if(i==0&& j==0 && k==0) continue;
		
		if(i!=0){
			int u=0;
			for(int l=max(1,j-i+1);l<=h+1-i;l++){
				if(a[1][l]==a[2][l+(j-i)])u++;
			}
			dp[i][j][k] =min(dp[i][j][k],u+dp[i+1][j][k]);
			
		}
		if(k!=0){
			int u=0;
			for(int l=max(1,j-k+1);l<=h+1-k;l++){
				if(a[1][l]==a[2][l+(j-k)])u++;
			}
			dp[i][j][k] =min(dp[i][j][k],u+dp[i][j][k+1]);
			
		}
		if(l!=0){
			int u=0;
			for(int l=max(1,k-j+1);l<=h+1-j;l++){
				if(a[1][l]==a[2][l+(k-j)])u++;
			}
			for(int l=max(1,i-j+1);l<=h+1-j;l++){
				if(a[1][l]==a[2][l+(i-j)])u++;
			}
			
			
			dp[i][j][k] =min(dp[i][j][k],u+dp[i][j][k+1]);
			
		}
	}
	
	cout<<dp[h][h][h]<<endl;
	
//	cout<<ans<<endl;
	return 0;
}

//printf("%.10f\n",ans);


Compiler output:
a.cc: In function 'int main()':
a.cc:94:38: error: no matching function for call to 'max(int, long long int)'
   94 |                         for(int l=max(1,j-i+1);l<=h+1-i;l++){
      |                                   ~~~^~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:94:38: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   94 |                         for(int l=max(1,j-i+1);l<=h+1-i;l++){
      |                                   ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:94:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   94 |                         for(int l=max(1,j-i+1);l<=h+1-i;l++){
      |                                   ~~~^~~~~~~~~
a.cc:102:38: error: no matching function for call to 'max(int, long long int)'
  102 |                         for(int l=max(1,j-k+1);l<=h+1-k;l++){
      |                                   ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:102:38: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  102 |                         for(int l=max(1,j-k+1);l<=h+1-k;l++){
      |                                   ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:102:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  102 |                         for(int l=max(1,j-k+1);l<=h+1-k;l++){
      |                                   ~~~^~~~~~~~~
a.cc:108:20: error: 'l' was not declared in this scope
  108 |                 if(l!=0){
      |                    ^
a.cc:110:38: error: no matching function for call to 'max(int, long long int)'
  110 |                         for(int l=max(1,k-j+1);l<=h+1-j;l++){
      |                                   ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:110:38: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  110 |                         for(int l=max(1,k-j+1);l<=h+1-j;l++){
      |                                   ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:110:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  110 |                         for(int l=max(1,k-j+1);l<=h+1-j;l++){
      |                                   ~~~^~~~~~~~~
a.cc:113:38: error: no matching function for call to 'max(int, long long int)'
  113 |                         for(int l=max(1,i-j+1);l<=h+1-j;l++){
      |                                   ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:113:38: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  113 |                         for(int l=max(1,i-j+1);l<=h+1-j;l++){
      |                                   ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:113:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  113 |                         for(int l=max(1,i-j+1);l<=h+1-j;l++){
      |                                   ~~~^~~~~~~~~