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:6:9: error: 'cnt' was not declared in this scope; did you mean 'int'?
    6 |     if (cnt.size() == 1) {
      |         ^~~
      |         int
a.cc:8:13: error: 'cout' was not declared in this scope
    8 |             cout << "YES" << endl;
      |             ^~~~
a.cc:8:30: error: 'endl' was not declared in this scope
    8 |             cout << "YES" << endl;
      |                              ^~~~
a.cc:10:13: error: 'cout' was not declared in this scope
   10 |             cout << "NO" << endl;
      |             ^~~~
a.cc:10:29: error: 'endl' was not declared in this scope
   10 |             cout << "NO" << endl;
      |                             ^~~~
a.cc:15:13: error: 'cout' was not declared in this scope
   15 |             cout << "YES" << endl;
      |             ^~~~
a.cc:15:30: error: 'endl' was not declared in this scope
   15 |             cout << "YES" << endl;
      |                              ^~~~
a.cc:17:13: error: 'cout' was not declared in this scope
   17 |             cout << "NO" << endl;
      |             ^~~~
a.cc:17:29: error: 'endl' was not declared in this scope
   17 |             cout << "NO" << endl;
      |                             ^~~~
a.cc:21:13: error: 'max' was not declared in this scope
   21 |         if (max({cnt['a'], cnt['b'], cnt['c']}) - min({cnt['a'], cnt['b'], cnt['c']}) <= 1) {
      |             ^~~
a.cc:21:51: error: 'min' was not declared in this scope; did you mean 'main'?
   21 |         if (max({cnt['a'], cnt['b'], cnt['c']}) - min({cnt['a'], cnt['b'], cnt['c']}) <= 1) {
      |                                                   ^~~
      |                                                   main
a.cc:22:13: error: 'cout' was not declared in this scope
   22 |             cout << "YES" << endl;
      |             ^~~~
a.cc:22:30: error: 'endl' was not declared in this scope
   22 |             cout << "YES" << endl;
      |                              ^~~~
a.cc:24:13: error: 'cout' was not declared in this scope
   24 |             cout << "NO" << endl;
      |             ^~~~
a.cc:24:29: error: 'endl' was not declared in this scope
   24 |             cout << "NO" << endl;
      |                             ^~~~