fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  5. #define ll long long
  6. #define rep(i, a, b) for (int i = (a); i < (b); ++i)
  7. #define repr(i, a, b) for (int i = (a); i >= (b); --i)
  8.  
  9. void solve() {
  10. //dharmil here
  11. string s; cin>>s;
  12. ll mini = INT_MAX,c = 0,nx=0;
  13. ll n = s.size();
  14. bool a = false;
  15. rep(i,0,n)
  16. {
  17. if(s[i]=='x'){
  18. c++;
  19. nx++;
  20. }else{
  21. mini = min(c,mini);
  22. c = 0;
  23. }
  24. if( i+1 < n && s[i]=='y' && s[i+1]=='y')
  25. {
  26. a = true;
  27. }
  28. }
  29.  
  30. if(a){
  31. cout << nx <<endl;
  32. }else{
  33. cout << nx - mini <<endl;
  34. }
  35. }
  36.  
  37. int main() {
  38. fastio;
  39. solve();
  40. return 0;
  41. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
-2147483647