Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

constexpr long long to_int64(char x) {
  return (long long)x;
}

template<class T> struct RollingHash {  // not verified

  const array<int, 3> mods = {{int(1e9+7), int(1e9+9), int(1234567891)}};
  const array<int, 3> Ks = {{1007, 1009, 1013}};

  vector<T> S;
  vector<vector<long long>> hash;
  vector<vector<long long>> pow_table;

  void construct() {
    hash.resize(mods.size());
    rep(i, mods.size()) hash[i].resize(S.size() + 1);
    rep(i, mods.size()) {
      for(int j=(int)S.size()-1; j>=0; j--) {
        hash[i][j] = hash[i][j+1] * Ks[i];
        hash[i][j] += to_int64(S[j]);
        hash[i][j] %= mods[i];
      }
    }

    pow_table.resize(mods.size());
    rep(i, mods.size()) pow_table[i].resize(S.size() + 1);

    rep(i, mods.size()) {
      pow_table[i][0] = 1;
      REP(j, 1, S.size() + 1) {
        pow_table[i][j] = (pow_table[i][j-1] * Ks[i]) % mods[i];
      }
    }
  }

  RollingHash(vector<T> const& S) {
    this->S = S;
    construct();
  }

  RollingHash(string const& S) {
    int n = S.size();
    rep(i, n) { this->S.push_back(S[i]); }
    construct();
  }

  long long get_hash(int t, int start, int end) const {
    auto r = hash[t][start] - hash[t][end] * pow_table[t][end - start];
    r %= mods[t];
    if(r < 0) { r += mods[t]; }
    return r;
  }

  // ???????????\????????¨??????MOD??§?????´?????????????????????????????????
  bool same(int a_start, int a_end, int b_start, int b_end) const {
    int const len = a_end - a_start;
    if(len != b_end - b_start) { return false; }
    rep(i, mods.size()) {
      if(get_hash(i, a_start, a_end) != get_hash(i, b_start, b_end)) { return false; }
    }
    return true;
  }

  // ????????????????????¨??????????????¨????????´???????????????
  bool same(int a_start, int a_end, int b_start, int b_end, shared_ptr<RollingHash<T>> const& rh) const {
    if(rh == nullptr) { return same(a_start, a_end, b_start, b_end); }
    int const len = a_end - a_start;
    if(len != b_end - b_start) { return false; }
    rep(i, mods.size()) {
      if(get_hash(i, a_start, a_end) != rh->get_hash(i, b_start, b_end)) { return false; }
    }
    return true;
  }

  // ???????????§?°???????
  bool compare(int a_start, int a_end, int b_start, int b_end, shared_ptr<RollingHash<T>> const& rh = nullptr) const {
    int a_len = a_end - a_start;
    int b_len = b_end - b_start;

    int len = min(a_len, b_len);
    int max_len = len + 1;
    int min_len = 0;

    // ???????????§?????´????????????????????¢?´¢??§?????????
    while(min_len + 1 < max_len) {
      int next_len = (min_len + max_len) / 2;
      if(same(a_start, a_start + next_len, b_start, b_start + next_len, rh)) {
        min_len = next_len;
      }
      else {
        max_len = next_len;
      }
    }

    if(a_start + min_len == a_end) {
      if(b_start + min_len == b_end) { return 0; }
      else { return -1; }
    }
    else {
      if(b_start + min_len == b_end) { return 1; }
      else { return S[a_start + min_len] == S[b_start + min_len]; }
    }

  }

};

int main() {

  string a, b; cin >> a >> b;
  RollingHash<char> ra(a), rb(b);
  int n = a.size(), m = b.size();
  if(n < m) { return 0; }

  rep(i, n-m+1) {
    if(ra.same(i, i+m, 0, m, make_shared<RollingHash<char>>(rb))) {
      cout << i << endl;
    }
  }

  return 0;
}

Compiler output:
a.cc:99:61: error: 'shared_ptr' has not been declared
   99 |   bool same(int a_start, int a_end, int b_start, int b_end, shared_ptr<RollingHash<T>> const& rh) const {
      |                                                             ^~~~~~~~~~
a.cc:99:71: error: expected ',' or '...' before '<' token
   99 |   bool same(int a_start, int a_end, int b_start, int b_end, shared_ptr<RollingHash<T>> const& rh) const {
      |                                                                       ^
a.cc:110:64: error: 'shared_ptr' has not been declared
  110 |   bool compare(int a_start, int a_end, int b_start, int b_end, shared_ptr<RollingHash<T>> const& rh = nullptr) const {
      |                                                                ^~~~~~~~~~
a.cc:110:74: error: expected ',' or '...' before '<' token
  110 |   bool compare(int a_start, int a_end, int b_start, int b_end, shared_ptr<RollingHash<T>> const& rh = nullptr) const {
      |                                                                          ^
a.cc: In member function 'bool RollingHash<T>::same(int, int, int, int, int) const':
a.cc:100:8: error: 'rh' was not declared in this scope
  100 |     if(rh == nullptr) { return same(a_start, a_end, b_start, b_end); }
      |        ^~
a.cc:104:41: error: 'rh' was not declared in this scope
  104 |       if(get_hash(i, a_start, a_end) != rh->get_hash(i, b_start, b_end)) { return false; }
      |                                         ^~
a.cc: In member function 'bool RollingHash<T>::compare(int, int, int, int, int) const':
a.cc:121:73: error: 'rh' was not declared in this scope
  121 |       if(same(a_start, a_start + next_len, b_start, b_start + next_len, rh)) {
      |                                                                         ^~
a.cc: In function 'int main()':
a.cc:150:30: error: 'make_shared' was not declared in this scope
  150 |     if(ra.same(i, i+m, 0, m, make_shared<RollingHash<char>>(rb))) {
      |                              ^~~~~~~~~~~
a.cc:21:1: note: 'std::make_shared' is defined in header '<memory>'; this is probably fixable by adding '#include <memory>'
   20 | #include <bitset>
  +++ |+#include <memory>
   21 | 
a.cc:150:58: error: expected primary-expression before '>' token
  150 |     if(ra.same(i, i+m, 0, m, make_shared<RollingHash<char>>(rb))) {
      |                                                          ^~