Language: C++

#include "bits/stdc++.h"
using namespace std;
#ifdef _debug
#define out(i) cout << #i << ' ' << i << ' '
#else 
#define out(i) //
#endif
using ll = long long;
using ull = unsigned long long;
const int maxn = 500001;
string s, t;
int f[maxn], cnt[maxn << 2];
void build_kmp(const string &w){
	for(int i = 1, q = 0;i < w.size();++i){
		while(q and w[i] != w[q])q = f[q - 1];
		f[i] = q += w[i] == w[q];
	}
}
int os, sl;
int form(int i){
	return i >= os ? i - os : i;
}
bool infinity(int b){
	static bool tried[maxn << 2] = {};
	int e = b;
	for(b = form(b + t.size());b != e;b = form(b + t.size())){
		if(tried[b] || !cnt[(b < sl ? b + sl : b)])return false;
		tried[b] = true;
	}
	return cnt[e < sl ? e + sl : e];
}
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> s >> t;
	while(s.size() < t.size() * 2)s += s;
	build_kmp(t);
	sl = s.size();
	os = sl * 3;
	s += s + s + s;
	for(int i = 0, q = 0;i < s.size();++i){
		while(q and s[i] != t[q])q = f[q - 1];
		q += s[i] == t[q];
		cnt[max(0, (i - (int)t.size() + 1))] = (q == t.size()) ? t.size() : 0;
		if(cnt[i])q = f[q - 1];
	}
	ull res = 0;
	for(int i = 0;i < s.size();++i){
		if(cnt[i]){
			if(i >= t.size() and cnt[i - t.size()])cnt[i] += cnt[i - t.size()];
			if(s.size() - cnt[i] == sl)res = -1;
			res = max(res, cnt[i] / t.size());
		}
	}
	for(int i = 0;i < t.size() and res != -1;++i)
		if(infinity(i))res = -1;
	cout << (int)res << '\n';
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:34: error: no matching function for call to 'max(ull&, std::__cxx11::basic_string<char>::size_type)'
   51 |                         res = max(res, cnt[i] / t.size());
      |                               ~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:51:34: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
   51 |                         res = max(res, cnt[i] / t.size());
      |                               ~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:51:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
   51 |                         res = max(res, cnt[i] / t.size());
      |                               ~~~^~~~~~~~~~~~~~~~~~~~~~~~