fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int maxi;
  4. string s, t;
  5. map<string, int> a;
  6. int main() {
  7. ios::sync_with_stdio(false);
  8. cin.tie(0);
  9. cout.tie(0);
  10. cin >> s;
  11. for(int i = 0; i < s.size(); i++){
  12. t = s[i];
  13. a[t]++;
  14. for(int j = i + 1; j < s.size(); j++){
  15. t = s[i];
  16. t += s[j];
  17. a[t]++;
  18. }
  19. }
  20. map<string, int>::iterator it;
  21. for (it = a.begin(); it != a.end(); it++)
  22. {
  23. maxi = max(maxi, it->second);
  24. }
  25. cout << maxi;
  26. }
Success #stdin #stdout 0s 4440KB
stdin
qdpinbmcrfwxpdbfgozvvocemjructoadewegtvbvbfwwrpgyeaxgddrwvlqnygwmwhmrhaizpyxvgaflrsvzhhzrouvpxrkxfza
stdout
37