Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
vector<int> find_all(const string& str, const string& subStr) {
    vector<int> result;
    
    int subStrSize = subStr.size();
    int pos = str.find(subStr);
    
    while (pos != string::npos) {
        result.push_back(pos);
        pos = str.find(subStr, min(pos + subStrSize, str.size()));
    }
    
    return result;
}
void ans(string& s,string& t){
    s+=s;
    vector<int> memo=find_all(s,t);
    int ans=0,ans1=0;
    for(int i=0;i<memo.size();i++){
        if(i==0)ans++;
        else{
            if(memo[i-1]+1+t.size()==memo[i]){
                ans++;
            }
            else{
                ans=1;
            }
        }
        ans1=max(ans,ans1);
    }
    cout<<ans1<<endl;
}
int main(){
    string s,t;
    cin>>s>>t;
    ll a,b;
    a=s.size();b=t.size();
    if(a>=b){
        if(a%b==0){
            for(int i=0;i<a/b;i++)t+=t;
            if(s==t)cout<<"-1"<<endl;
            else ans(s,t);
        }
        else ans(s,t);
    }
    else ans(t,s);
}


Compiler output:
a.cc: In function 'std::vector<int> find_all(const std::string&, const std::string&)':
a.cc:12:35: error: no matching function for call to 'min(int, std::__cxx11::basic_string<char>::size_type)'
   12 |         pos = str.find(subStr, min(pos + subStrSize, str.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: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:12:35: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
   12 |         pos = str.find(subStr, min(pos + subStrSize, str.size()));
      |                                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:12:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   12 |         pos = str.find(subStr, min(pos + subStrSize, str.size()));
      |                                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~