Language: C++

void ABC141E()
{
	int N;
	cin >> N;
	string S;
	cin >> S;

	map<string, vector<int> > checkMap;
	vector<int> candidates(N);
	iota(candidates.begin(), candidates.end(), 0);
	vector<int> nextCandidates;
	for (int i = 1; i < 2500; ++i)
	{
		checkMap.clear();
		for (auto& x : candidates)
		{
			if (x + i > N)
				continue;
			string y = S.substr(x, i);
			checkMap[y].push_back(x);
		}
		for (auto& x : checkMap)
		{
			if (x.second.size() == 1)
				continue;
			auto& y = x.second;
			vector<int> tmpCand;
			for (int j = 0; j < y.size() - 1; ++j)
			{
				if (y[j] + i <= y[j + 1])
					tmpCand.push_back(y[j]);
			}
			tmpCand.push_back(y[y.size() - 1]);
			if (tmpCand.size() > 1)
				nextCandidates.insert(nextCandidates.end(), tmpCand.begin(), tmpCand.end());
		}

		if (nextCandidates.empty())
		{
			cout << i - 1 << endl;
			return;
		}
		sort(nextCandidates.begin(), nextCandidates.end());
		nextCandidates.erase(unique(nextCandidates.begin(), nextCandidates.end()), nextCandidates.end());
		candidates = move(nextCandidates);
	}

}
int main()
{
	ABC141E();
	return 0;
}

Compiler output:
a.cc: In function 'void ABC141E()':
a.cc:4:9: error: 'cin' was not declared in this scope
    4 |         cin >> N;
      |         ^~~
a.cc:5:9: error: 'string' was not declared in this scope
    5 |         string S;
      |         ^~~~~~
a.cc:6:16: error: 'S' was not declared in this scope
    6 |         cin >> S;
      |                ^
a.cc:8:9: error: 'map' was not declared in this scope
    8 |         map<string, vector<int> > checkMap;
      |         ^~~
a.cc:8:21: error: 'vector' was not declared in this scope
    8 |         map<string, vector<int> > checkMap;
      |                     ^~~~~~
a.cc:8:28: error: expected primary-expression before 'int'
    8 |         map<string, vector<int> > checkMap;
      |                            ^~~
a.cc:9:16: error: expected primary-expression before 'int'
    9 |         vector<int> candidates(N);
      |                ^~~
a.cc:10:14: error: 'candidates' was not declared in this scope
   10 |         iota(candidates.begin(), candidates.end(), 0);
      |              ^~~~~~~~~~
a.cc:10:9: error: 'iota' was not declared in this scope
   10 |         iota(candidates.begin(), candidates.end(), 0);
      |         ^~~~
a.cc:11:16: error: expected primary-expression before 'int'
   11 |         vector<int> nextCandidates;
      |                ^~~
a.cc:14:17: error: 'checkMap' was not declared in this scope
   14 |                 checkMap.clear();
      |                 ^~~~~~~~
a.cc:19:31: error: expected ';' before 'y'
   19 |                         string y = S.substr(x, i);
      |                               ^~
      |                               ;
a.cc:20:34: error: 'y' was not declared in this scope
   20 |                         checkMap[y].push_back(x);
      |                                  ^
a.cc:27:32: error: expected primary-expression before 'int'
   27 |                         vector<int> tmpCand;
      |                                ^~~
a.cc:31:41: error: 'tmpCand' was not declared in this scope
   31 |                                         tmpCand.push_back(y[j]);
      |                                         ^~~~~~~
a.cc:33:25: error: 'tmpCand' was not declared in this scope
   33 |                         tmpCand.push_back(y[y.size() - 1]);
      |                         ^~~~~~~
a.cc:35:33: error: 'nextCandidates' was not declared in this scope
   35 |                                 nextCandidates.insert(nextCandidates.end(), tmpCand.begin(), tmpCand.end());
      |                                 ^~~~~~~~~~~~~~
a.cc:38:21: error: 'nextCandidates' was not declared in this scope
   38 |                 if (nextCandidates.empty())
      |                     ^~~~~~~~~~~~~~
a.cc:40:25: error: 'cout' was not declared in this scope
   40 |                         cout << i - 1 << endl;
      |                         ^~~~
a.cc:40:42: error: 'endl' was not declared in this scope
   40 |                         cout << i - 1 << endl;
      |                                          ^~~~
a.cc:43:22: error: 'nextCandidates' was not declared in this scope
   43 |                 sort(nextCandidates.begin(), nextCandidates.end());
      |                      ^~~~~~~~~~~~~~
a.cc:43:17: error: 'sort' was not declared in this scope; did you mean 'short'?
   43 |                 sort(nextCandidates.begin(), nextCandidates.end());
      |                 ^~~~
      |                 short
a.cc:44:38: error: 'unique' was not declared in this scope
   44 |                 nextCandidates.erase(unique(nextCandidates.begin(), nextCandidates.end()), nextCandidates.end());
      |                                      ^~~~~~
a.cc:45:30: error: 'move' was not declared in this scope
   45 |                 candidates = move(nextCandidates);
      |                              ^~~~