Language: C++

#include<bits/stdc++.h>
 
using namespace std;

#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX 1000000
#define ll long long
#define db double
#define str string
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Forrev(i,s,e) for (ll i=(s); i>=(e); i--)
#define all(v) v.begin(),v.end()

#define vll vector<ll>
#define vs vector<string>
#define mapll map<ll,ll>
#define pll pair<ll,ll>
#define initialise(a, x) memset(a, x, sizeof(a))
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll> ,greater<ll>>

#define ff first
#define ss second
#define endl "\n"
#define mp make_pair
const ll mod=1e9 + 7;

ll takemod(ll a) {
    return ((a%mod)+mod)%mod;
}

ll gcd(ll a, ll b) { 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);        
}

ll fast_exp(ll base, ll expo) {
    ll res=1;
    while(expo>0) {
        if(expo&1) res=(res*base)%mod;
        base=(base*base)%mod;
        expo>>=1;}
    return res;
}

ll modinv(ll a) {
    return takemod(fast_exp(takemod(a), mod-2));
}


void computeLPSArray(string pat, int M, int* lps); 
  
// Prints occurrences of txt[] in pat[] 
vll KMPSearch(string pat, string txt) 
{ 
    int M = pat.length(); 
    int N = txt.length(); 
  
    // create lps[] that will hold the longest prefix suffix 
    // values for pattern 
    int lps[M]; 
  	vll ans;
    // Preprocess the pattern (calculate lps[] array) 
    computeLPSArray(pat, M, lps); 
  
    int i = 0; // index for txt[] 
    int j = 0; // index for pat[] 
    while (i < N) { 
        if (pat[j] == txt[i]) { 
            j++; 
            i++; 
        } 
  
        if (j == M) { 
        	ans.pb(i-j);
            j = lps[j - 1]; 
        } 
  
        // mismatch after j matches 
        else if (i < N && pat[j] != txt[i]) { 
            // Do not match lps[0..lps[j-1]] characters, 
            // they will match anyway 
            if (j != 0) 
                j = lps[j - 1]; 
            else
                i = i + 1; 
        } 
    } 
    return ans;
} 
  
// Fills lps[] for given patttern pat[0..M-1] 
void computeLPSArray(string pat, int M, int* lps) 
{ 
    // length of the previous longest prefix suffix 
    int len = 0; 
  
    lps[0] = 0; // lps[0] is always 0 
  
    // the loop calculates lps[i] for i = 1 to M-1 
    int i = 1; 
    while (i < M) { 
        if (pat[i] == pat[len]) { 
            len++; 
            lps[i] = len; 
            i++; 
        } 
        else // (pat[i] != pat[len]) 
        { 
            // This is tricky. Consider the example. 
            // AAACAAAA and i = 7. The idea is similar 
            // to search step. 
            if (len != 0) { 
                len = lps[len - 1]; 
  
                // Also, note that we do not increment 
                // i here 
            } 
            else // if (len == 0) 
            { 
                lps[i] = 0; 
                i++; 
            } 
        } 
    } 
} 

signed main() 
{
    fast_cin();
    // #ifndef ONLINE_JUDGE
    // freopen("C:/IO/in.txt", "r", stdin);
    // freopen("C:/IO/out.txt", "w", stdout);
    // #endif
    string s1,s2;
    cin>>s1>>s2;
    string final="";
    while(final.length()<s2.length())
    	final+=s1;
    final+=final;

    vll ans1=KMPSearch(s2,final);
    vll ans;
    if(ans1.size()==0)
    	cout<<0<<endl;
    else
    {
    	
    	ll prev=ans1[ans1.size()-1];
    	ans.pb(prev);
    	for(int i=ans1.size()-2;i>=0;i--)
    	{
    		if(prev>=a+s2.size())
    		{
    			ans.pb(a);
    			prev=a;
    		}
    	}
    	// for(ll a: ans)
    	// 	cout<<a<<" ";
    	// cout<<endl;
    	ll finalans=1;
    	ll temp=ans[0],tempans=1,flag=0;
    	For(i,1,ans.size())
    	{
    		if(temp+s2.size()==ans[i])
    		{
    			tempans++;
    			temp=ans[i];
    		}
    		else
    		{
    			flag=1;
    			finalans=max(finalans,tempans);
    			tempans=1;
    			temp=ans[i];
    		}
    	}
    	if(flag==0)
    		cout<<-1<<endl;
    	else
    	{
    		finalans=max(finalans,tempans);
    		cout<<finalans<<endl;
    	}
    }
    return 0;    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:155:26: error: 'a' was not declared in this scope
  155 |                 if(prev>=a+s2.size())
      |                          ^