Language: C++

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	s := scanString()
	t := scanString()

	n := (len(t) + len(s) - 1) / len(s)
	ss := strings.Repeat(s, n+1)

	zarr := Zalgorithm(t + "#" + ss)
	zarr = zarr[len(t)+1:][:len(s)]

	for i := 0; i < len(s); i++ {
		zarr[i] = zarr[i] / len(t)
		if zarr[i] != 0 {
			zarr[i] = 1
		}
	}

	cnt := 0
	done := make([]int, len(s))
	memo := make([]int, len(s))
	var dfs func(to int) int
	dfs = func(to int) int {
		if cnt == done[to] {
			return -1
		}

		if zarr[to] == 0 {
			return 0
		}

		done[to] = cnt
		if memo[to] == 0 {
			memo[to] = dfs((to + len(t)) % len(s))
			if memo[to] != -1 {
				memo[to]++
			}
		}
		return memo[to]
	}

	ans := 0
	for i := 0; i < len(s); i++ {
		if zarr[i] == 0 {
			continue
		}
		cnt++
		t := dfs(i)
		if t == -1 {
			fmt.Fprintln(wr, -1)
			return
		}
		ans = max(ans, t)
	}

	fmt.Fprintln(wr, ans)

}

// Zalgorithm function
func Zalgorithm(s string) []int {
	n := len(s)
	res := make([]int, n)
	i, j := 1, 0
	for i < n {
		for i+j < n && s[j] == s[i+j] {
			j++
		}
		res[i] = j
		if j == 0 {
			i++
			continue
		}
		k := 1
		for i+k < n && k+res[k] < j {
			res[i+k] = res[k]
			k++
		}
		i += k
		j -= k
	}
	return res
}


Compiler output:
a.cc:1:1: error: 'package' does not name a type
    1 | package main
      | ^~~~~~~
a.cc:14:1: error: 'func' does not name a type
   14 | func scanRunes() []rune    { return []rune(scanString()) }
      | ^~~~
a.cc:15:1: error: 'func' does not name a type
   15 | func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
      | ^~~~
a.cc:16:1: error: 'func' does not name a type
   16 | func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
      | ^~~~
a.cc:17:1: error: 'func' does not name a type
   17 | func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }
      | ^~~~
a.cc:19:1: error: 'func' does not name a type
   19 | func scanInts(n int) []int {
      | ^~~~
a.cc:27:1: error: 'func' does not name a type
   27 | func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }
      | ^~~~
a.cc:27:28: error: expected unqualified-id before ')' token
   27 | func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }
      |                            ^
a.cc:29:1: error: 'func' does not name a type
   29 | func abs(a int) int {
      | ^~~~
a.cc:35:1: error: 'func' does not name a type
   35 | func min(a, b int) int {
      | ^~~~
a.cc:41:1: error: 'func' does not name a type
   41 | func max(a, b int) int {
      | ^~~~
a.cc:49:1: error: 'func' does not name a type
   49 | func main() {
      | ^~~~
a.cc:112:1: error: 'func' does not name a type
  112 | func Zalgorithm(s string) []int {
      | ^~~~