Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;


/*
int solve(string s, string t, int n, int m){
    /*for (int i=1; i<=n; ++i) {
        for (int j=1; j<=m; ++j) {
            if (s[i] == t[j]) {
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else {
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
        }
    }*/
 /*   int maxcase_len=0;
    for(int off = -(int)s.size(); off <= (int)t.size(); off++) {
        int len = 0;
        for(int i = max(off, 0); i < min(s.size()+off, t.size()); i++) {
            if(len > maxcase_len) {
                //maxcase_off1 = i-len-off;
                //maxcase_off2 = i-len;
                maxcase_len = len;
            }
            if(s[i-off] != t[i]) {
                len = 0;
            } else {
                len++;
            }
        }
    }
    cout << maxcase_len<< endl;
    return maxcase_len;
}*/

static int LCSuff[6000][6000];

int LCSubStr(string X, string Y, int m, int n)
{
    //cout << X << " " << m << endl;
    //cout << Y << " " << n <<endl;
    int result = 0;
    for (int i=0; i<=m; i++)
    {
        for (int j=0; j<=n; j++)
        {

            if (i == 0 || j == 0)
                LCSuff[i][j] = 0;
            
            else if (X[i-1] == Y[j-1])
            {
                LCSuff[i][j] = LCSuff[i-1][j-1] + 1;
                result = max(result, LCSuff[i][j]);
            }
            else LCSuff[i][j] = 0;
        }
    }
    //cout << result << endl;
    return result;
}

int main(void){
    int N;
    string S;
    MEMSET(dp, 0);
    cin >> N >> S;
    int Maximum = 0;
    
    rep(k, N-1){
        int result = 0;
        string X = LCSubStr(S.substr(0, k+1);
                            string Y = S.substr(k+1);
        for (int i=0; i<=m; i++)
        {
            for (int j=0; j<=n; j++)
            {
                
                if (i == 0 || j == 0)
                    LCSuff[i][j] = 0;
                
                else if (X[i-1] == Y[j-1])
                {
                    LCSuff[i][j] = LCSuff[i-1][j-1] + 1;
                    result = max(result, LCSuff[i][j]);
                }
                else LCSuff[i][j] = 0;
            }
        }
       Maximum = max(result, Maximum);
    }
    cout << Maximum << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:79:12: error: 'dp' was not declared in this scope
   79 |     MEMSET(dp, 0);
      |            ^~
a.cc:11:30: note: in definition of macro 'MEMSET'
   11 | #define MEMSET(v, h) memset((v), h, sizeof(v))
      |                              ^
a.cc:85:45: error: expected ')' before ';' token
   85 |         string X = LCSubStr(S.substr(0, k+1);
      |                            ~                ^
      |                                             )
a.cc:87:26: error: 'm' was not declared in this scope
   87 |         for (int i=0; i<=m; i++)
      |                          ^
a.cc:89:30: error: 'n' was not declared in this scope
   89 |             for (int j=0; j<=n; j++)
      |                              ^