[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]:
create integer arrays num, vis with num size 30, vis size 1010
create character arrays str, ans, with str size 1010, ans size 1010
define the main function
    create integers t, q, i, j, k, len, mx, mp, with mx = 0
    create character mw
    read str + 1
    set len to string length of ( str + 1 )
    for i = 1 to len inclusive
        set t to str[i] - 'a' + 1
        increment num[t]
        if num[t] is greater than mx
            set mx to num[t]
            set mp to t
        end of the block
    end of the block
    create integers cur, nf with cur = 1, nf = 0
    for i = 2 to len inclusive
        if vis[i] is true, break current loop iteration
        if i * 2 is less than or equal to len
            for j = i to len inclusive, increment j by i
                if vis[j] is true, break current loop iteration
                if num[mp] is less than or equal to 0
                    set nf to 1
                    break loop
                end of the block
                set ans[j] to mp - 1 + 'a'
                decrement num[mp]
                set vis[j] to 1
            end of the block
        end of the block
        if nf is true, break loop
    end of the block
    for i = 1 to len inclusive
        if vis[i] is true, break current loop iteration
        while num[cur] is lesser than or equal to 0 and cur is lesser than or equal to 26, increment cur
        if cur is greater than 26
            set nf to 1
            break loop
        end of the block
        set ans[i] to cur - 1 + 'a'
        decrement num[cur]
    end of the block
    if nf is true
        print "NO\n"
    else
        print "YES\n" print ans + 1 print newline
    return to indicate successful execution
end of the block

[CODE]:

int num[30], vis[1010];
char str[1010], ans[1010];
int main() {
    int t, q, i, j, k, len, mx = 0, mp;
    char mw;
    cin >> str + 1;
    len = strlen(str + 1);
    for (i = 1; i <= len; i++) {
        t = str[i] - 'a' + 1;
        num[t]++;
        if (num[t] > mx) {
            mx = num[t];
            mp = t;
        }
    }
    int cur = 1, nf = 0;
    for (i = 2; i <= len; i++) {
        if (vis[i]) continue;
        if (i * 2 <= len) {
            for (j = i; j <= len; j += i) {
                if (vis[j]) continue;
                if (num[mp] <= 0) {
                    nf = 1;
                    break;
                }
                ans[j] = mp - 1 + 'a';
                num[mp]--;
                vis[j] = 1;
            }
        }
        if (nf) break;
    }
    for (i = 1; i <= len; i++) {
        if (vis[i]) continue;
        while (num[cur] <= 0 && cur <= 26) cur++;
        if (cur > 26) {
            nf = 1;
            break;
        }
        ans[i] = cur - 1 + 'a';
        num[cur]--;
    }
    if (nf)
        cout << "NO\n";
    else
        cout << "YES\n" << ans + 1 << endl;
    return 0;
}