[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
define the main function
    create string a
    read a
    create integer n with n = integer casted size of a
    if n is less than or equal to 3
        print "YES" print '\n'
        print a print '\n'
        return to indicate successful execution
    end of the block
    create integer vector f initialized with 26
    for i = 0 to n exclusive, increment f[a[i] - 'a']
    create character vector ans initialized with n + 1
    create boolean vector flags initialized with n + 1
    for i = 2 to n inclusive, incrementing i by 2, set flags[i] to true
    for i = 3 to n inclusive
        if not flags[i] and i * 2 is less than or equal to n
            for j = i to n inclusive, incrementing j by i, set flags[j] to true
        end of the block
    end of the block
    create integer cont with cont = 0
    for i = 1 to n inclusive, increment cont by flags[i]
    create integers most, pos with most = -1, pos = -1
    for i = 0 to 26 exclusive
        if f[i] is greater than most
            set most to f[i]
            set pos to i
        end of the block
    if most is less than cont
        print "NO" print '\n'
        return to indicate successful execution
    end of the block
    decrement f[pos] by cont
    for i = 1 to n inclusive
        if flags[i] is true, set ans[i] to character casted ( pos + 'a' )
    for i = 1 to n inclusive
        if flags[i] is false
            for j = 0 to 26 exclusive
                if f[j] is greater than 0
                    decrement f[j]
                    set ans[i] to character casted ( j + 'a' )
                    set flags[i] to true
                    break loop
                end of the block
            end of the block
        end of the block
    end of the block
    for i = 1 to n inclusive
        if flags[i] is false
            print "NO" print '\n'
            return to indicate successful execution
        end of the block
    end of the block
    print "YES" print '\n'
    for i = 1 to n inclusive, print ans[i]
    print '\n'
    return to indicate successful execution
end of the block

[CODE]:

int main() {
    string a;
    cin >> a;
    int n = (int)a.size();
    if (n <= 3) {
        cout << "YES" << '\n';
        cout << a << '\n';
        return 0;
    }
    vector<int> f(26);
    for (int i = 0; i < n; i++) f[a[i] - 'a']++;
    vector<char> ans(n + 1);
    vector<bool> flags(n + 1);
    for (int i = 2; i <= n; i += 2) flags[i] = true;
    for (int i = 3; i <= n; i++) {
        if (!flags[i] && i * 2 <= n) {
            for (int j = i; j <= n; j += i) flags[j] = true;
        }
    }
    int cont = 0;
    for (int i = 1; i <= n; i++) cont += flags[i];
    int most = -1, pos = -1;
    for (int i = 0; i < 26; i++)
        if (f[i] > most) {
            most = f[i];
            pos = i;
        }
    if (most < cont) {
        cout << "NO" << '\n';
        return 0;
    }
    f[pos] -= cont;
    for (int i = 1; i <= n; i++)
        if (flags[i]) ans[i] = (char)(pos + 'a');
    for (int i = 1; i <= n; i++) {
        if (!flags[i]) {
            for (int j = 0; j < 26; j++) {
                if (f[j] > 0) {
                    f[j]--;
                    ans[i] = (char)(j + 'a');
                    flags[i] = true;
                    break;
                }
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        if (!flags[i]) {
            cout << "NO" << '\n';
            return 0;
        }
    }
    cout << "YES" << '\n';
    for (int i = 1; i <= n; i++) cout << ans[i];
    cout << '\n';
    return 0;
}