Language: C++

#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

#define ceil(a,b) (a%b?a/b+1:a/b)

#define dump1(v) for(auto i:v) std::cout << i << ' '; std::cout << "\n";

struct FastIO
{
  FastIO() {
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(0); 
  }
}fastio;

struct ZAlgorithm
{
	std::vector<int> z;
	ZAlgorithm(std::string s) : z(s.size(),0) {
		int l,r;
		// [l,r)
		l=r=0;
		for(int i=1;i<s.size();i++) {
			if(i>=r) {
				l=r=i;
				while(r<s.size() && s[r]==s[r-l]) r++;
				z[i] = r-l;
				continue;
			}
			if(z[i-l]<r-i) {
				z[i] = z[i-l];
				continue;
			}
			l=i;
			while(r<s.size() && s[r]==s[r-l]) r++;
			z[i] = r-l;
			continue;
		}
		z[0] = s.size();
	}
};

int dfs(int i,int c,std::vector<int>&to,std::vector<int>&went) {
	if(to[c]==i) return -1;
	if(to[c]==-1) return 0;
	if(went[c]>0) return went[c];
	int x = dfs(i,to[c],to,went);
	if(x==-1) return -1;
	return went[c]=x+1;
}

signed main() {
	std::string s;
	std::string t;
	std::cin >> s >> t;

	std::string a = "";

	int t_sz = t.size();
	int s_sz = s.size();
	rep(i,ceil(t_sz,s_sz)+1) a = a+s;

	std::string x = t + '$' + a;
	ZAlgorithm z(x);

	std::vector<int> zz(s_sz);
	rep(i,s_sz) zz[i] = z.z[t_sz+1+i];

	std::vector<int> to(s_sz,-1);
	rep(i,s_sz) if(zz[i]==t_sz) to[i] = (i+t_sz)%s_sz;

	std::vector<int> went(s_sz,0);
	rep(i,s_sz) {
		if(zz[i]!=t_sz) continue;

//		if(dfs(i,i,to,went)==-1) {
			print(-1);
			return 0;
		}
	}
	int max = 0;
	for(auto i:went) max = std::max(max,i);
	dump1(went);
	print(max);
	return 0;
}


Compiler output:
a.cc:103:9: error: expected unqualified-id before 'for'
  103 |         for(auto i:went) max = std::max(max,i);
      |         ^~~
a.cc:27:18: error: expected unqualified-id before 'for'
   27 | #define dump1(v) for(auto i:v) std::cout << i << ' '; std::cout << "\n";
      |                  ^~~
a.cc:104:9: note: in expansion of macro 'dump1'
  104 |         dump1(went);
      |         ^~~~~
a.cc:27:60: error: 'cout' in namespace 'std' does not name a type
   27 | #define dump1(v) for(auto i:v) std::cout << i << ' '; std::cout << "\n";
      |                                                            ^~~~
a.cc:104:9: note: in expansion of macro 'dump1'
  104 |         dump1(went);
      |         ^~~~~
In file included from a.cc:1:
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:20:23: error: 'cout' in namespace 'std' does not name a type
   20 | #define print(i) std::cout << (i) << "\n"
      |                       ^~~~
a.cc:105:9: note: in expansion of macro 'print'
  105 |         print(max);
      |         ^~~~~
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:106:9: error: expected unqualified-id before 'return'
  106 |         return 0;
      |         ^~~~~~
a.cc:107:1: error: expected declaration before '}' token
  107 | }
      | ^