Language: C++

int main() {
    string s;
    cin >> s;
    map<char, int> cnt;
    for (char c : s) cnt[c]++;

    if (cnt.size() == 1) {
        if (s.size() == 1) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
        return 0;
    } else if (cnt.size() == 2) {
        if (s.size() < 3) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
        return 0;
    } else {
        if (max({cnt['a'], cnt['b'], cnt['c']}) - min({cnt['a'], cnt['b'], cnt['c']}) <= 1) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:2:5: error: 'string' was not declared in this scope
    2 |     string s;
      |     ^~~~~~
a.cc:3:5: error: 'cin' was not declared in this scope
    3 |     cin >> s;
      |     ^~~
a.cc:3:12: error: 's' was not declared in this scope
    3 |     cin >> s;
      |            ^
a.cc:4:5: error: 'map' was not declared in this scope
    4 |     map<char, int> cnt;
      |     ^~~
a.cc:4:9: error: expected primary-expression before 'char'
    4 |     map<char, int> cnt;
      |         ^~~~
a.cc:5:22: error: 'cnt' was not declared in this scope; did you mean 'int'?
    5 |     for (char c : s) cnt[c]++;
      |                      ^~~
      |                      int
a.cc:7:9: error: 'cnt' was not declared in this scope; did you mean 'int'?
    7 |     if (cnt.size() == 1) {
      |         ^~~
      |         int
a.cc:9:13: error: 'cout' was not declared in this scope
    9 |             cout << "YES" << endl;
      |             ^~~~
a.cc:9:30: error: 'endl' was not declared in this scope
    9 |             cout << "YES" << endl;
      |                              ^~~~
a.cc:11:13: error: 'cout' was not declared in this scope
   11 |             cout << "NO" << endl;
      |             ^~~~
a.cc:11:29: error: 'endl' was not declared in this scope
   11 |             cout << "NO" << endl;
      |                             ^~~~
a.cc:16:13: error: 'cout' was not declared in this scope
   16 |             cout << "YES" << endl;
      |             ^~~~
a.cc:16:30: error: 'endl' was not declared in this scope
   16 |             cout << "YES" << endl;
      |                              ^~~~
a.cc:18:13: error: 'cout' was not declared in this scope
   18 |             cout << "NO" << endl;
      |             ^~~~
a.cc:18:29: error: 'endl' was not declared in this scope
   18 |             cout << "NO" << endl;
      |                             ^~~~
a.cc:22:13: error: 'max' was not declared in this scope
   22 |         if (max({cnt['a'], cnt['b'], cnt['c']}) - min({cnt['a'], cnt['b'], cnt['c']}) <= 1) {
      |             ^~~
a.cc:22:51: error: 'min' was not declared in this scope; did you mean 'main'?
   22 |         if (max({cnt['a'], cnt['b'], cnt['c']}) - min({cnt['a'], cnt['b'], cnt['c']}) <= 1) {
      |                                                   ^~~
      |                                                   main
a.cc:23:13: error: 'cout' was not declared in this scope
   23 |             cout << "YES" << endl;
      |             ^~~~
a.cc:23:30: error: 'endl' was not declared in this scope
   23 |             cout << "YES" << endl;
      |                              ^~~~
a.cc:25:13: error: 'cout' was not declared in this scope
   25 |             cout << "NO" << endl;
      |             ^~~~
a.cc:25:29: error: 'endl' was not declared in this scope
   25 |             cout << "NO" << endl;
      |                             ^~~~