#include #include const int INF = 1001001001; const std::string G = "good", P = "problem"; std::string S; int L; int cost(int index, int offset, const std::string& s){ if(index+offset < 0 || index+offset+s.size() > L){return INF;} int res = 0; for(int i=0;i L){return INF;} return cost(index, 0, P); } int solve(int index){ if(index+11 > L){return INF;} int res = INF; for(int i=index+4;i> N; while(N--){ std::cin >> S; L = S.size(); int res = INF; for(int i=0;i