[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]:
num is an integer array with 30 elements and vis is an integer array with 1010 elements
str and ans are character arrays with size 1010
define the main function
    declare integer variables t, q, i, j, k, len, t1 and mx, with mx = 0
    read str + 1
    len = length of (str + 1)
    for i = 1 to len inclusive
        t = str[i] - 'a' + 1
        increase num[t] by one
        if num[t] is greater than num[mx] set mx to t
    end of the block
    let cur = 1 and nf = 0 be integers
    for i = 2 to len inclusive
        continue the loop if vis[i] is not 0
        if i * 2 <= len
            for j = i to len inclusive incrementing j by i
                continue if vis[j] is not 0
                if num[mx] <= 0
                    assign value of 1 to nf
                    stop the loop
                end of the block
                ans[j] = mx - 1 + 'a'
                decrease num[mx]
                set vis[j] to 1
            end of the block
        end of the block
        if nf is not 0, break
    end of the block
    for i = 1 to len while - <= len and !nf
        continue if vis[i] is not 0
        while num[cur] <= 0 && cur <= 26 increment cur
        if cur is greater than 26
            assign value of 1 to nf
            stop the loop
        end of the block
        ans[i] = cur - 1 + 'a'
        decrease num[cur] by one
    end of the block
    if nf is not 0
        print "NO\n"
    else
        print "YES\n", ans + 1 and a new line
    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, t1, mx = 0;
    cin >> str + 1;
    len = strlen(str + 1);
    for (i = 1; i <= len; i++) {
        t = str[i] - 'a' + 1;
        num[t]++;
        if (num[t] > num[mx]) mx = 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[mx] <= 0) {
                    nf = 1;
                    break;
                }
                ans[j] = mx - 1 + 'a';
                num[mx]--;
                vis[j] = 1;
            }
        }
        if (nf) break;
    }
    for (i = 1; i <= len && !nf; 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;
}