Language: C++

/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

string s,ss,t;
LL h[4000010],pw[4000010],hn=9839183,ht[1000010],ans=0;

LL gethash(LL a,LL b)
{
	return (h[b+1]-h[a]*pw[b-a+1]%MOD+MOD)%MOD;
}

LL gethash2(LL a,LL b)
{
	return (ht[b+1]-ht[a]*pw[b-a+1]%MOD+MOD)%MOD;
}

int main()
{
	pw[0]=1;
	repn(i,4000005) pw[i]=pw[i-1]*hn%MOD;
	cin>>s>>t;
	ss=s;
	s+=s;
	while(s.size()<t.size()*4) s+=ss;
	repn(i,s.size()) h[i]=(h[i-1]*hn+s[i-1]-'a')%MOD;
	repn(i,t.size()) ht[i]=(ht[i-1]*hn+t[i-1]-'a')%MOD;
	rep(i,ss.size())
	{
		LL lb=i,num=0;
		//cout<<i<<endl;
		while(lb<s.size())
		{
			//cout<<gethash(lb,min(lb+t.size()-1,s.size()-1))<<' '<<gethash2(0,min(lb+t.size()-1,s.size()-1)-lb)
			//<<' '<<min(lb+t.size()-1,s.size()-1)-lb<<endl;
			if(gethash(lb,min(lb+t.size()-1,s.size()-1))!=gethash2(0,min(lb+t.size()-1,s.size()-1)-lb)) break;
			num++;
			lb+=t.size();
		}
		if(lb>=s.size())
		{
			puts("-1");
			return 0;
		}
		ans=max(ans,num);
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:42: error: no matching function for call to 'min(long long unsigned int, std::__cxx11::basic_string<char>::size_type)'
   52 |                         if(gethash(lb,min(lb+t.size()-1,s.size()-1))!=gethash2(0,min(lb+t.size()-1,s.size()-1)-lb)) break;
      |                                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
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:5:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:52:42: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
   52 |                         if(gethash(lb,min(lb+t.size()-1,s.size()-1))!=gethash2(0,min(lb+t.size()-1,s.size()-1)-lb)) break;
      |                                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281: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:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:52:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
   52 |                         if(gethash(lb,min(lb+t.size()-1,s.size()-1))!=gethash2(0,min(lb+t.size()-1,s.size()-1)-lb)) break;
      |                                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:52:85: error: no matching function for call to 'min(long long unsigned int, std::__cxx11::basic_string<char>::size_type)'
   52 |                         if(gethash(lb,min(lb+t.size()-1,s.size()-1))!=gethash2(0,min(lb+t.size()-1,s.size()-1)-lb)) break;
      |                                                                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:52:85: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
   52 |                         if(gethash(lb,min(lb+t.size()-1,s.size()-1))!=gethash2(0,min(lb+t.size()-1,s.size()-1)-lb)) break;
      |                                                                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:52:85: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
   52 |                         if(gethash(lb,min(lb+t.size()-1,s.size()-1))!=gethash2(0,min(lb+t.size()-1,s.size()-1)-lb)) break;
      |                                                                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~