Language: C++

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2019-12-18 21:55:05
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;
template<class T> ostream& operator<<(ostream& os, vector<T>& _) { os << '{'; for (T& x : _) { os << x; if (&x != &_.back()) os << ','; } os << '}'; return os; }
template<class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

#ifdef LOCAL
#define debug(_) cerr << #_ << ": " << (_) << '\n'
#else
#define debug(_) 1728
#endif

class RollingHash {
 public:
  using ull = unsigned long long;
  RollingHash(const std::string& s) : s_(s) { Initialize(); }
  std::pair<ull, ull> GetHash(int left, int right) {
    ull ret0 =
        (hash0_[right] - hash0_[left] * power0_[right - left] % mod0_ + mod0_) %
        mod0_;
    ull ret1 =
        (hash1_[right] - hash1_[left] * power1_[right - left] % mod1_ + mod1_) %
        mod1_;
    return {ret0, ret1};
  }

 private:
  const std::string s_;
  static ull base0_;
  static ull base1_;
  static constexpr ull mod0_ = 2020202077;
  static constexpr ull mod1_ = 2020202111;
  std::vector<ull> hash0_;
  std::vector<ull> hash1_;
  static std::vector<ull> power0_;
  static std::vector<ull> power1_;
  static std::mt19937_64 mt_;
  void Initialize() {
    size_t n = s_.size();
    hash0_.assign(n + 1, 0);
    hash1_.assign(n + 1, 0);
    for (size_t i = 0; i < n; ++i) {
      hash0_[i + 1] = (hash0_[i] * base0_ + s_[i]) % mod0_;
      hash1_[i + 1] = (hash1_[i] * base1_ + s_[i]) % mod1_;
    }
    while (power0_.size() <= n) {
      power0_.emplace_back(power0_.back() * base0_ % mod0_);
      power1_.emplace_back(power1_.back() * base1_ % mod1_);
    }
  }
};

void RollingHash::Initialize() {
  size_t n = s_.size();
  hash0_.assign(n + 1, 0);
  hash1_.assign(n + 1, 0);
  for (size_t i = 0; i < n; ++i) {
    hash0_[i + 1] = (hash0_[i] * base0_ + s_[i]) % mod0_;
    hash1_[i + 1] = (hash1_[i] * base1_ + s_[i]) % mod1_;
  }
  while (power0_.size() <= n) {
    power0_.emplace_back(power0_.back() * base0_ % mod0_);
    power1_.emplace_back(power1_.back() * base1_ % mod1_);
  }
}

std::mt19937_64 RollingHash::mt_(
    std::chrono::steady_clock::now().time_since_epoch().count());
unsigned long long RollingHash::base0_ = std::uniform_int_distribution<ull>(
    2, RollingHash::mod0_)(RollingHash::mt_);
unsigned long long RollingHash::base1_ = std::uniform_int_distribution<ull>(
    2, RollingHash::mod1_)(RollingHash::mt_);
std::vector<unsigned long long> RollingHash::power0_{1};
std::vector<unsigned long long> RollingHash::power1_{1};

void ABC141_E() {
  int n; cin >> n;
  string s; cin >> s;
  RollingHash rh(s);

  auto ok = [&](int x) -> bool{
    for (int i = 0; i + 2 * x <= n; ++i) {
      for (int j = i + x; j + x <= n; ++j) {
        if (rh.GetHash(i, i + x) == rh.GetHash(j, j + x)) {
          return true;
        }
      }
    }
    return false;
  };

  int low = 0, high = n / 2 + 1;

  while (high - low > 1) {
    int mid = (low + high) >> 1;
    if (ok(mid)) {
      low = mid;
    } else {
      high = mid;
    }
  }

  cout << low << '\n';
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  ABC141_E();

  return 0;
}

Compiler output:
a.cc:78:6: error: redefinition of 'void RollingHash::Initialize()'
   78 | void RollingHash::Initialize() {
      |      ^~~~~~~~~~~
a.cc:63:8: note: 'void RollingHash::Initialize()' previously defined here
   63 |   void Initialize() {
      |        ^~~~~~~~~~