Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const double pi=acos(-1);
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<MOD>;
vector<bool> seen,finished;
int pos = -1;
int ca=0;
int f=0;
void dfs(const Graph &G, int v, int p) {
    seen[v] = true;
    for (auto nv : G[v]) {
        if (nv == p) continue;
        if (finished[nv]) continue;
      if (seen[nv] && !finished[nv]) {
            pos = nv;f++; 
            return;
        }
      dfs(G, nv, v);
 
        // サイクル検出したならば真っ直ぐに抜けていく
        if (pos != -1) {
        return;}}
      finished[v] = true;
}
    
mint calc(long long N, long long K) {
    mint res = 1;
    for (long long n = 0; n < K; ++n) {
        res *= (N - n);
        res /= (n + 1);
    }
    return res;
}
struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
 
    UnionFind(ll N) : par(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
    }
 
    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
 
    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
 
    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};
int main(){
ll n,S; cin>>n>>S;
ll ca = 0;
ll s = "";
for(ll m=1; m<=n; m++){
s = S.substr(i,n+1-m);
vector<ll> Z(s.size());
Z[0] = s.size();
ll i = 1, j = 0;
while(i < s.size()){
    while(i + j < s.size() && s[j] == s[i + j]) j++;
    Z[i] = j;

    if(j == 0){
        i++;
        continue;
    }
    ll k = 1;
    while(k < j && k + Z[k] < j){
        Z[i + k] = Z[k];
        k++;
    }
    i += k;
    j -= k;
}
rep(i, s.size()){
if(Z[i]<=m) ca=max(Z[i],ca);}
}
cout << ca << endl;}
//cout << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:136:8: error: invalid conversion from 'const char*' to 'll' {aka 'long long int'} [-fpermissive]
  136 | ll s = "";
      |        ^~
      |        |
      |        const char*
a.cc:138:7: error: request for member 'substr' in 'S', which is of non-class type 'll' {aka 'long long int'}
  138 | s = S.substr(i,n+1-m);
      |       ^~~~~~
a.cc:138:14: error: 'i' was not declared in this scope
  138 | s = S.substr(i,n+1-m);
      |              ^
a.cc:139:16: error: request for member 'size' in 's', which is of non-class type 'll' {aka 'long long int'}
  139 | vector<ll> Z(s.size());
      |                ^~~~
a.cc:140:10: error: request for member 'size' in 's', which is of non-class type 'll' {aka 'long long int'}
  140 | Z[0] = s.size();
      |          ^~~~
a.cc:142:13: error: request for member 'size' in 's', which is of non-class type 'll' {aka 'long long int'}
  142 | while(i < s.size()){
      |             ^~~~
a.cc:143:21: error: request for member 'size' in 's', which is of non-class type 'll' {aka 'long long int'}
  143 |     while(i + j < s.size() && s[j] == s[i + j]) j++;
      |                     ^~~~
a.cc:143:32: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
  143 |     while(i + j < s.size() && s[j] == s[i + j]) j++;
      |                                ^
a.cc:158:10: error: request for member 'size' in 's', which is of non-class type 'll' {aka 'long long int'}
  158 | rep(i, s.size()){
      |          ^~~~
a.cc:4:31: note: in definition of macro 'rep'
    4 | #define rep(i,n) for(ll i=0;i<n;i++)
      |                               ^