Language: C++

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,avx,avx2,popcnt,tune=native")
#pragma comment(linker, "/STACK:36777216")
#pragma GCC optimize("Ofast")
#define _CRT_SECURE_NO_WARNINGS

#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
#include <iomanip>
#include <numeric>
#include <time.h>//////////////
#include <ctime>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define queuel queue<long long>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(), v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for (auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for (int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for (int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for (int i = 0; i < n; ++i){int a; cin >> a; s.insert(a); }
#define fastio() ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0); srand(time(NULL))
#define sp system("pause")
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;//СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚СЂСџВ¦Р‚
					//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const int MAXN = 6e3 + 228;
const int inf = 1e9;
const ld PI = acos(-1);
const int mod = (int)998244353;
const int MOD = 1000000007;
const int MOD9 = 1000000009;
const int a228 = 18;
const ld obr = (ld)1 / sqrt(2);
vector<int> pf(string &s)
{
	vector<int> p(s.size());
	int k = 0;
	for (int i = 1; i < s.size(); ++i)
	{
		while (k && s[i] != s[k])
		{
			k = p[k - 1];
		}
		k += (s[i] == s[k]);
		p[i] = k;
	}
	return p;
}
bool check(string &s, string & t, int m)
{
	string kek = "";
	for (int i = 0; i < m; ++i) kek += t;
	string tkek = s;
	while (tkek.size() / 2 < kek.size()) tkek += tkek;
	auto lole = pf(kek + '#' + tkek);
	if (find(all(lole), kek.size()) != lole.end())
	{
		return 1;
	}
	return 0;
}
int main()
{
	string s, t;
	cin >> s >> t;
	int l = -1, r = max(2*(int)s.size()/ (int)t.size() , 50);
	while (r - l > 1)
	{
		int  m = (l + r) / 2;
		if (check(s,t,m)) l = m;
		else r = m;
	}
	if (!check(s,t,r)) r--;
	if (r != 0 && r == max(2 * (int)s.size() / (int)t.size(), 50))
	{
		cout << -1;
		return 0;
	}
	cout << r;
//	sp;
}


//you should actually read the stuff at the bottom
/* stuff you should look for
* int overflow, array bounds
* special cases (n=1?), set tle
* do smth instead of nothing and stay organized
*/

Compiler output:
a.cc: In function 'bool check(std::string&, std::string&, int)':
a.cc:84:34: error: cannot bind non-const lvalue reference of type 'std::string&' {aka 'std::__cxx11::basic_string<char>&'} to an rvalue of type 'std::__cxx11::basic_string<char>'
   84 |         auto lole = pf(kek + '#' + tkek);
      |                        ~~~~~~~~~~^~~~~~
a.cc:63:24: note:   initializing argument 1 of 'std::vector<int> pf(std::string&)'
   63 | vector<int> pf(string &s)
      |                ~~~~~~~~^