Language: C++

#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
using namespace std;
typedef long long LL;
const int SIZE=305;
const LL INF=1<<30;
int maps[SIZE][SIZE];
int CAL[SIZE][SIZE];
int DP[SIZE][SIZE];
int H,W;
LL calc(int a,int b,int x){
	if(max(a,b)==H) return 0;
	if(CAL[a][b]!=-1) return CAL[a][b];
	return CAL[a][b]=calc(a+1,b+1,x)+(maps[a][x]==maps[b][x+1]);
}
LL solve3(int a,int b,int x){
	if(max(a,b)==H) return 0;
	if(DP[a][b]!=-1) return DP[a][b];
	int ans=0;
	ans=calc(a,b,x);
	return DP[a][b]=min(solve3(a,b+1,x),solve3(a+1,b,x))+ans;
}
LL solve2(int x){
	REP(i,SIZE) REP(j,SIZE) DP[i][j]=-1;
	REP(i,SIZE) REP(j,SIZE) CAL[i][j]=-1;
	return solve3(0,0,x);
}
LL solve(){
	cin >> H >> W;
	REP(i,H){
		string s;
		cin >> s;
		REP(j,W){
			maps[H-i-1][j]=s[j]-'a';
		}
	}
	int ans=0;
	REP(i,W-1) ans+=solve2(i);
	return ans;
}
int main(){
 
	cout << solve() << endl;
	return 0;
}

Compiler output:
a.cc: In function 'LL solve2(int)':
a.cc:2:24: error: 'ut' was not declared in this scope
    2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
      |                        ^~
a.cc:3:18: note: in expansion of macro 'FOR'
    3 | #define REP(i,b) FOR(i,0,b)
      |                  ^~~
a.cc:25:9: note: in expansion of macro 'REP'
   25 |         REP(i,SIZE) REP(j,SIZE) DP[i][j]=-1;
      |         ^~~
a.cc:25:13: error: 'i' was not declared in this scope
   25 |         REP(i,SIZE) REP(j,SIZE) DP[i][j]=-1;
      |             ^
a.cc:2:33: note: in definition of macro 'FOR'
    2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
      |                                 ^
a.cc:25:9: note: in expansion of macro 'REP'
   25 |         REP(i,SIZE) REP(j,SIZE) DP[i][j]=-1;
      |         ^~~
a.cc:25:25: error: expected ';' before 'j'
   25 |         REP(i,SIZE) REP(j,SIZE) DP[i][j]=-1;
      |                         ^
a.cc:2:27: note: in definition of macro 'FOR'
    2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
      |                           ^
a.cc:25:21: note: in expansion of macro 'REP'
   25 |         REP(i,SIZE) REP(j,SIZE) DP[i][j]=-1;
      |                     ^~~
a.cc:25:25: error: 'j' was not declared in this scope
   25 |         REP(i,SIZE) REP(j,SIZE) DP[i][j]=-1;
      |                         ^
a.cc:2:33: note: in definition of macro 'FOR'
    2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
      |                                 ^
a.cc:25:21: note: in expansion of macro 'REP'
   25 |         REP(i,SIZE) REP(j,SIZE) DP[i][j]=-1;
      |                     ^~~
a.cc:2:24: error: 'ut' was not declared in this scope
    2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
      |                        ^~
a.cc:3:18: note: in expansion of macro 'FOR'
    3 | #define REP(i,b) FOR(i,0,b)
      |                  ^~~
a.cc:26:9: note: in expansion of macro 'REP'
   26 |         REP(i,SIZE) REP(j,SIZE) CAL[i][j]=-1;
      |         ^~~
a.cc:26:13: error: 'i' was not declared in this scope
   26 |         REP(i,SIZE) REP(j,SIZE) CAL[i][j]=-1;
      |             ^
a.cc:2:33: note: in definition of macro 'FOR'
    2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
      |                                 ^
a.cc:26:9: note: in expansion of macro 'REP'
   26 |         REP(i,SIZE) REP(j,SIZE) CAL[i][j]=-1;
      |         ^~~
a.cc:26:25: error: expected ';' before 'j'
   26 |         REP(i,SIZE) REP(j,SIZE) CAL[i][j]=-1;
      |                         ^
a.cc:2:27: note: in definition of macro 'FOR'
    2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
      |                           ^
a.cc:26:21: note: in expansion of macro 'REP'
   26 |         REP(i,SIZE) REP(j,SIZE) CAL[i][j]=-1;
      |                     ^~~
a.cc:26:25: error: 'j' was not declared in this scope
   26 |         REP(i,SIZE) REP(j,SIZE) CAL[i][j]=-1;
      |                         ^
a.cc:2:33: note: in definition of macro 'FOR'
    2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
      |                                 ^
a.cc:26:21: note: in expansion of macro 'REP'
   26 |         REP(i,SIZE) REP(j,SIZE) CAL[i][j]=-1;
      |                     ^~~
a.cc: In function 'LL solve()':
a.cc:2:24: error: 'ut' was not declared in this scope
    2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
      |                        ^~
a.cc:3:18: note: in expansion of macro 'FOR'
    3 | #define REP(i,b) FOR(i,0,b)
      |                  ^~~
a.cc:31:9: note: in expansion of macro 'REP'
   31 |         REP(i,H){
      |         ^~~
a.cc:31:13: error: 'i' was not declared in this scope
   31 |         REP(i,H){
      |             ^
a.cc:2:33: note: in definition of macro 'FOR'
    2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
      |                                 ^
a.cc:31:9: note: in expansion of macro 'REP'
   31 |         REP(i,H){
      |         ^~~
a.cc:34:21: error: expected ';' before 'j'
   34 |                 REP(j,W){
      |                     ^
a.cc:2:27: note: in definition of macro 'FOR'
    2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
      |                           ^
a.cc:34:17: note: in expansion of macro 'REP'
   34 |                 REP(j,W){
      |                 ^~~
a.cc:34:21: error: 'j' was not declared in this scope
   34 |                 REP(j,W){
      |                     ^
a.cc:2:33: note: in definition of macro 'FOR'
    2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
      |                                 ^
a.cc:34:17: note: in expansion of macro 'REP'
   34 |                 REP(j,W){
      |                 ^~~
a.cc:2:24: error: 'ut' was not declared in this scope
    2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
      |                        ^~
a.cc:3:18: note: in expansion of macro 'FOR'
    3 | #define REP(i,b) FOR(i,0,b)
      |                  ^~~
a.cc:39:9: note: in expansion of macro 'REP'
   39 |         REP(i,W-1) ans+=solve2(i);
      |         ^~~
a.cc:39:13: error: 'i' was not declared in this scope
   39 |         REP(i,W-1) ans+=solve2(i);
      |             ^
a.cc:2:33: note: in definition of macro 'FOR'
    2 | #define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
      |                                 ^
a.cc:39:9: note: in expansion of macro 'REP'
   39 |         REP(i,W-1) ans+=solve2(i);
      |         ^~~