fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define endl '\n'
  5. #define int long long
  6.  
  7. const int N = 2e5, oo = 2e18, MOD = 1e9+7;
  8.  
  9.  
  10. void solve() {
  11. string s; cin >> s;
  12. int n = s.size();
  13. if (n & 1) {
  14. cout << "NO";
  15. return;
  16. }
  17.  
  18. char fr[26] = {0};
  19. for (char c : s) fr[c-'a']++;
  20. for (int i = 0; i< 26; i++) {
  21. if (fr[i] > (n / 2)) {
  22. cout << "NO";
  23. return;
  24. }
  25. }
  26. cout << "YES";
  27.  
  28. }
  29.  
  30.  
  31. signed main() {
  32. ios_base::sync_with_stdio(false);
  33. cin.tie(NULL); cout.tie(NULL);
  34. // #ifndef ONLINE_JUDGE
  35. // freopen("input.txt", "r", stdin);
  36. // freopen("output.txt", "w", stdout);
  37. // #endif
  38. int t; t = 1;
  39. // cin >> t;
  40. while (t--) solve();
  41. return 0;
  42. }
  43.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
YES