Language: C++

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

vector<int> xx;

void KMP(string &P, string &T){
	int ps = P.size(), ts = T.size();
	int table[ps+1] = {-1,};
	for(int i = 0, j = -1; i < ps; i++){//cout<<i<<endl;
		while(j >= 0 && P[i] != P[j]) j = table[j];
		j++;
		if(P[i+1] == P[j]) table[i+1] = table[j];
		else table[i+1] = j;
		table[i+1] = j;
	}
	for(int i = 0, j = 0; i < ts;i++){//cout<<i<<" "<<j<<endl;
		while(j >= 0 && T[i] != P[j]) j = table[j];
		j++;
		if(j == ps){
			// cout<<i-ps+1<<endl;
			xx.push_back(i-ps+1);
			j = table[ps];
		}
	}
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	string s, t;
	int con = 0;
	
	cin>>s>>t;
	
	for(int i = 0; i < max(s.size(), t.size())*2; i++){
		if(s[i%s.size()] != t[i%t.size()]){
			con++;
			break;
		}
	}
	
	if(con == 0)cout<<-1<<endl;
	else {
		string x = s+s;
		KMP(t,x);
		// for(int y : xx){
			// cout<<y<<endl;
		// }
		int con = min(xx.size(),1ll), now = 0;
		for(int i = 1; i < xx.size(); i++){
			if(xx[now]+t.size() == x[i]){
				con++;
				now = i;
			}
		}
		
		cout<<con<<endl;
	}
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:66:30: error: no matching function for call to 'min(std::vector<long long int>::size_type, long long int)'
   66 |                 int con = min(xx.size(),1ll), now = 0;
      |                           ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/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:66:30: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'long long int')
   66 |                 int con = min(xx.size(),1ll), now = 0;
      |                           ~~~^~~~~~~~~~~~~~~
/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,
                 from a.cc:6:
/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:66:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   66 |                 int con = min(xx.size(),1ll), now = 0;
      |                           ~~~^~~~~~~~~~~~~~~
a.cc:68:31: error: 'now' was not declared in this scope; did you mean 'pow'?
   68 |                         if(xx[now]+t.size() == x[i]){
      |                               ^~~
      |                               pow