// This file is generated by mkfile.py
// Date: 2025-12-05

#include <solution/1668.h>
#include <stdbool.h>
#include <string.h>

#define max(x, y) ((x) > (y) ? (x) : (y))

int maxRepeating(char *sequence, char *word)
{
    int n = strlen(sequence), m = strlen(word);
    if (n < m)
        return 0;

    int dp[n];
    memset(dp, 0, sizeof(dp));
    for (int i = m - 1; i < n; i++)
    {
        bool valid = true;
        for (int j = 0; j < m; j++)
        {
            if (sequence[i - m + 1 + j] != word[j])
            {
                valid = false;
                break;
            }
        }
        if (valid)
            dp[i] = (i == m - 1 ? 0 : dp[i - m]) + 1;
    }

    int ret = dp[0];
    for (int i = 1; i < n; i++)
        ret = max(ret, dp[i]);

    return ret;
}