[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;
}


[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]:
mpu = map from character to character
vec is vector of long longs of size 1000006
let b and a be empty integer arrays of size 1000006
let visit be empty boolean array of size 1000006
define the main function
    declare string variable s
    read s
    n and sum are long longs with sum = 0
    n = size of s
    declare vector of long longs called v
    for i = 2 to n inclusive
        set boolean t to 0
        for integer j = 2 to i exclusive
            if i % j = 0
                assign value of 1 to the t
                stop the loop
            end of the block
        end of the block
        if t = 0, push i into v
    end of the block
    w is an empty array of integers with size 26
    for i = 0 to length of s exclusive
        integer t = s[i] - 'a' casted to int
        increase w[t]
    end of the block
    for integer i = 0 to length of v exclusive
        if v[i] * 2 is greater than n, break
        for k = v[i] to length of s inclusive incrementing by v[i]
            if visit[k - 1] = 1, continue
            increment sum
            visit[k - 1] = 1
        end of the block
    end of the block
    if sum = 0
        print "YES\n", s and a new line
        return to indicate successful execution
    end of the block
    assign value -1 to the integer p
    for integer i = 0 to 26 exclusive
        if w[i] >= sum, set p to i
    end of the block
    if p = -1
        print "NO\n"
        return to indicate successful execution
    end of the block
    print "YES\n"
    for i = 0 to n exclusive
        if visit[i] = 1
            s[i] = char(p) + 'a'
            decrease w[p]
        end of the block
    end of the block
    for integer i = 0 to n exclusive
        if visit[i] = 1, continue
        for integer j = 0 to 26 exclusive
            if w[j] is greater than 0
                s[i] = char(j) + 'a'
                decrease w[j]
                stop the loop
            end of the block
        end of the block
    end of the block
    print s and a new line
end of the block

[CODE]:

map<char, char> mpu;
vector<long long> vec[1000006];
int b[1000006] = {}, a[1000006] = {};
bool visit[1000006] = {};
int main() {
    string s;
    cin >> s;
    long long n, sum = 0;
    n = s.size();
    vector<long long> v;
    for (int i = 2; i <= n; i++) {
        bool t = 0;
        for (int j = 2; j < i; j++) {
            if (i % j == 0) {
                t = 1;
                break;
            }
        }
        if (t == 0) { v.push_back(i); }
    }
    int w[26] = {};
    for (int i = 0; i < s.size(); i++) {
        int t = int(s[i] - 'a');
        w[t]++;
    }
    for (int i = 0; i < v.size(); i++) {
        if (v[i] * 2 > n) break;
        for (int k = v[i]; k <= s.size(); k += v[i]) {
            if (visit[k - 1] == 1) continue;
            sum++;
            visit[k - 1] = 1;
        }
    }
    if (sum == 0) {
        cout << "YES\n" << s << endl;
        return 0;
    }
    int p = -1;
    for (int i = 0; i < 26; i++) {
        if (w[i] >= sum) { p = i; }
    }
    if (p == -1) {
        cout << "NO\n";
        return 0;
    }
    cout << "YES\n";
    for (int i = 0; i < n; i++) {
        if (visit[i] == 1) {
            s[i] = char(p) + 'a';
            w[p]--;
        }
    }
    for (int i = 0; i < n; i++) {
        if (visit[i] == 1) continue;
        for (int j = 0; j < 26; j++) {
            if (w[j] > 0) {
                s[i] = char(j) + 'a';
                w[j]--;
                break;
            }
        }
    }
    cout << s << endl;
}


[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]:
let pal be an array of characters of size 1100
declare array of integers qtd with size 1100
declare array of integers d with size 1100
primo is a boolean function with integer argument n
    return 0 if n = 1
    for i = 2 while i squared <= n
        return 0 if n % i = 0
    end of the block
    return 1
end of the block
res = array of characters of length 1100
define the main function
    declare integer called i
    declare string called a
    read a
    declare integer variable called n = length of s
    for i = 0 to length of a exclusive increment qtd[a[i]]
    declare integer called dois = 0
    for i = 2 to length of a casted to integer inclusive
        if primo(i) && i * 2 is greater than n
            d[i] = 0
        else
            d[i] = 1
            increase dois by one
        end of the block
    end of the block
    assign value 0 to character l
    for i = 'a' to 'z' inclusive
        if qtd[i] >= dois
            set l to i
            decrease qtd[i] by dois
            break the loop
        end of the block
    end of the block
    declare integer called j = 'a'
    if l != 0
        print "YES" and a new line
        for i = 1 to n inclusive
            if d[i] = 1
                print l
            else
                increment j while qtd[j] = 0
                decrease qtd[j] by one
                print j casted to char
            end of the block
        end of the block
        print new line
    else
        print "NO" and a new line
    end of the block
end of the block

[CODE]:

char pal[1100];
int qtd[1100];
bool d[1100];
bool primo(int n) {
    if (n == 1) return 0;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) return 0;
    }
    return 1;
}
char res[1100];
int main() {
    int i;
    string a;
    cin >> a;
    int n = (int)a.size();
    for (i = 0; i < (int)a.size(); i++) { qtd[(int)a[i]]++; }
    int dois = 0;
    for (i = 2; i <= (int)a.size(); i++) {
        if (primo(i) && i * 2 > n) {
            d[i] = 0;
        } else {
            d[i] = 1;
            dois++;
        }
    }
    char l = 0;
    for (i = 'a'; i <= 'z'; i++) {
        if (qtd[i] >= dois) {
            l = i;
            qtd[i] -= dois;
            break;
        }
    }
    int j = 'a';
    if (l != 0) {
        cout << "YES" << endl;
        for (i = 1; i <= n; i++) {
            if (d[i] == 1) {
                cout << l;
            } else {
                while (qtd[j] == 0) { j++; }
                qtd[j]--;
                cout << (char)j;
            }
        }
        cout << endl;
    } else {
        cout << "NO" << endl;
    }
}


[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 constant integer MAXN with value 1001
declare integer called n
let s be an array of characters of length MAXN
c is an array of integers with size 256 filled with 0
f is an array of booleans with size MAXN
define the main function
    read input to s
    assign length of s to n
    memset with arguments c, sizeof(c) and 0
    for i = 0 to n exclusive incremen c[s[i]]
    k is integer = 0
    for i = 0 to 256 exclusive
        if c[i] is greater than c[k] set k to i
    memset with arguments f, true and sizeof(f)
    for integer i = 2 to i * i <= n
        if f[i] is true
            for integer j = i * i to n inclusive with step of i, set f[j] to false
    set value of f[1] to true
    for integer i = 2 to i + i <= n, set f[j] to false
    for i = 1 to n inclusive
        if f[i] is false
            if c[k] = 0
                print "NO" and a new line
                return to indicate successful execution
            end of the block
            decrease c[s[i - 1] = k] by one
        end of the block
    assign value of 0 to k
    for integer i = 1 to n inclusive
        if f[i] is true
            increment k while c[k] = 0
            decrease c[s[i - 1] = k] by one
        end of the block
    print "YES" and a new line
    print s and a new line
    return to indicate successful execution
end of the block

[CODE]:

const int MAXN = 1001;
int n;
char s[MAXN];
int c[256] = {0};
bool f[MAXN];
int main() {
    gets(s);
    n = strlen(s);
    memset(c, sizeof(c), 0);
    for (int i = 0; i < n; i++) c[s[i]]++;
    int k = 0;
    for (int i = 0; i < 256; i++)
        if (c[i] > c[k]) k = i;
    memset(f, true, sizeof(f));
    for (int i = 2; i * i <= n; i++)
        if (f[i])
            for (int j = i * i; j <= n; j += i) f[j] = false;
    f[1] = true;
    for (int i = 2; i + i <= n; i++) f[i] = false;
    for (int i = 1; i <= n; i++)
        if (!f[i]) {
            if (c[k] == 0) {
                cout << "NO" << endl;
                return 0;
            }
            c[s[i - 1] = k]--;
        }
    k = 0;
    for (int i = 1; i <= n; i++)
        if (f[i]) {
            while (c[k] == 0) k++;
            c[s[i - 1] = k]--;
        }
    cout << "YES" << endl;
    cout << s << endl;
    return 0;
}


[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;
}


[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 constant integer MAXN with MAXN = 1001
create integer n
create character array s with size MAXN
create integer array c with size 256
declare boolean array f with size MAXN
define the main function
    read string into s
    set n to string length of s
    for i = 0 to n exclusive, increment c[s[i]]
    create integer k with k = 0
    for i = 0 to 256 exclusive
        if c[i] is greater than c[k], set k to i
    set bytes from f to size of f to true
    for i = 2 to i * i is less than or equal to n, incrementing i
        if f[i] is true
            for j = i * i to n inclusive, incrementing j by i, set f[j] to false
    set f[1] to true
    for i = 2 to i + i is less than or equal to n, incrementing i, set f[i] to false
    for i = 1 to n inclusive
        if not f[i]
            if c[k] is 0
                print "NO"
                return to indicate successful execution
            end of the block
            decrement c[set s[i-1] to k]
        end of the block
    set k to 0
    for i = 1 to n inclusive
        if f[i] is true
            while c[k] is 0, increment k
            decrement c[set s[i-1] to k]
        end of the block
    print "YES"
    print s
    return to indicate successful execution
end of the block

[CODE]:

const int MAXN = 1001;
int n;
char s[MAXN];
int c[256];
bool f[MAXN];
int main() {
    gets(s);
    n = strlen(s);
    for (int i = 0; i < n; ++i) c[s[i]]++;
    int k = 0;
    for (int i = 0; i < 256; ++i)
        if (c[i] > c[k]) k = i;
    memset(f, true, sizeof(f));
    for (int i = 2; i * i <= n; i++)
        if (f[i])
            for (int j = i * i; j <= n; j += i) f[j] = false;
    f[1] = true;
    for (int i = 2; i + i <= n; i++) f[i] = false;
    for (int i = (1); i <= (n); ++i)
        if (!f[i]) {
            if (c[k] == 0) {
                puts("NO");
                return 0;
            }
            c[s[i - 1] = k]--;
        }
    k = 0;
    for (int i = (1); i <= (n); ++i)
        if (f[i]) {
            while (c[k] == 0) k++;
            c[s[i - 1] = k]--;
        }
    puts("YES");
    puts(s);
    return 0;
}


[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]:
declare prime with integer x as argument, returning integer
    for i = 2 to x exclusive
        if x % i is 0, return false from function
    end of the block
    return true from function
end of the block
define the main function
    create string s
    read s
    create integer comp with comp = length of s - 1
    for i = 2 to length of s inclusive
        if 2 * i is greater than length of s and result of run prime with i as argument, decrement comp
    end of the block
    create integer vector letters initialized with 26, 0
    for i = 0 to length of s exclusive, increment letter[s[i] - 'a' ]
    create boolean ok with ok = false
    create integer let
    for i = 0 to 26 exclusive
        if letters[i] is greater than or equal to comp
            set let to i, set ok to true
            break loop
        end of the block
    end of the block
    create integer cur with cur = 0
    if not ok
        print "NO\n"
        return to indicate successful execution
    end of the block
    decrement letters[let] by comp
    print "YES\n"
    create string t with t = ""
    for i = 1 to length of s inclusive
        if i is 1 or ( 2 * i is greater than length of s and result of run prime with i as argument )
            while letters[cur] is 0, increment cur
            increment to by character casted ( 'a' + cur )
            decrement letters[cur]
        else
            increment t by character casted ( 'a' + let )
        end of the block
    end of the block
    print t print newline
    return to indicate successful execution
end of the block

[CODE]:

int prime(int x) {
    for (int i = 2; i < x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}
int main() {
    string s;
    cin >> s;
    int comp = s.length() - 1;
    for (int i = 2; i <= s.length(); i++) {
        if (2 * i > s.length() && prime(i)) comp--;
    }
    vector<int> letters(26, 0);
    for (size_t i = 0; i < s.length(); i++) { ++letters[s[i] - 'a']; }
    bool ok = false;
    int let;
    for (int i = 0; i < 26; i++) {
        if (letters[i] >= comp) {
            let = i, ok = true;
            break;
        }
    }
    int cur = 0;
    if (!ok) {
        cout << "NO\n";
        return 0;
    }
    letters[let] -= comp;
    cout << "YES\n";
    string t = "";
    for (int i = 1; i <= s.length(); i++) {
        if (i == 1 || (2 * i > s.length() && prime(i))) {
            while (letters[cur] == 0) cur++;
            t += (char)('a' + cur);
            --letters[cur];
        } else {
            t += (char)('a' + let);
        }
    }
    cout << t << endl;
    return 0;
}


[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;
}


[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]:
let st be a string
let temp, bst be strings
create a set of strings by name v
let rl be a function that accepts string st and returns a string value
    the character value of c is equal to st[0]
    st[0] is equal to st[1]
    st[1] is equal to st[2]
    st[2] is equal to st[3]
    st[3] is equal to c
    return the value of st
end of the block
let ru be a function that accepts string st and returns a string value
    the character value of temp is equal to st[4]
    st[4] is equal to st[0]
    st[0] is equal to st[5]
    st[5] is equal to st[2]
    st[2] is equal to temp
    return the value of st
end of the block
define the main function
    read st
    sort the values of st from beginning to end
    do
        temp is equal to st
        bst is equal to temp
        for integer iter = 1 to 2000 inclusive
            if rand() modulo 2
                temp is equal to rl(temp)
            else do the following
                temp is equal to ru(temp)
            if bst is greater than temp , bst is equal to temp
        end of the block
        insert bst into v
    while next_permutation of st from beginning to end
    print length of v and newline
    read a character
    read a character
    return to indicate successful execution
end of the block

[CODE]:

string st;
string temp, bst;
set<string> v;
string rl(string st) {
    char c = st[0];
    st[0] = st[1];
    st[1] = st[2];
    st[2] = st[3];
    st[3] = c;
    return st;
}
string ru(string st) {
    char temp = st[4];
    st[4] = st[0];
    st[0] = st[5];
    st[5] = st[2];
    st[2] = temp;
    return st;
}
int main() {
    cin >> st;
    sort(st.begin(), st.end());
    do {
        temp = st;
        bst = temp;
        for (int iter = 1; iter <= 2000; iter++) {
            if (rand() % 2)
                temp = rl(temp);
            else
                temp = ru(temp);
            if (bst > temp) bst = temp;
        }
        v.insert(bst);
    } while (next_permutation(st.begin(), st.end()));
    cout << v.size() << endl;
    cin.get();
    cin.get();
    return 0;
}


[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 const int MAXN = 5005
declare izq taking in string c and returning string
    create string temp = c
    set temp[0] to c[3]
    set temp[1] to c[5]
    set temp[3] to c[1]
    set temp[5] to c[0]
    return temp
end of the block
declare abajo taking in string c and returning string
    make string temp = c
    for i = 2 to 5 exclusive, swap values of temp[i] and temp[i + 1]
    return temp
end of the block
declare last taking in string c and returning string
    make string ans = c
    for i = 0 to 4 exclusive
        for j = 0 to 4 exclusive
            for k = 0 to 4 exclusive
                set ans to max of ans and c
                set c to izq(c)
            end of the block
            set c to abajo(c)
        end of the block
        set c to izq(c)
    end of the block
    return ans
end of the block
define the main function
    make string color
    read color
    sort color
    make string set ans
    do insert last(color) into ans while next_permutation(color.begin(), color.end()) returns true
    show ans.size()
    return to indicate successful execution
end of the block

[CODE]:

int const MAXN = 5005;
string izq(string c) {
    string temp = c;
    temp[0] = c[3];
    temp[1] = c[5];
    temp[3] = c[1];
    temp[5] = c[0];
    return temp;
}
string abajo(string c) {
    string temp = c;
    for (int i = 2; i < 5; ++i) swap(temp[i], temp[i + 1]);
    return temp;
}
string last(string c) {
    string ans = c;
    for (int i = 0; i < 4; ++i) {
        for (int j = 0; j < 4; ++j) {
            for (int k = 0; k < 4; ++k) {
                ans = max(ans, c);
                c = izq(c);
            }
            c = abajo(c);
        }
        c = izq(c);
    }
    return ans;
}
int main() {
    string color;
    cin >> color;
    sort(color.begin(), color.end());
    set<string> ans;
    do { ans.insert(last(color)); } while (next_permutation(color.begin(), color.end()));
    cout << ans.size() << '\n';
    return 0;
}


[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 s
    read s
    create set<string> ss
    sort s
    do
        create string m = s
        create vector<string> v
        for i = 0 to 3 exclusive do push s.substr(2 * i, 2) onto v
        for i = 0 to 4 exclusive
            for i = 0 to 4 exclusive
                for i = 0 to 4 exclusive
                    create string str = v[0] + v[1] + v[2]
                    set m to min of m and str
                    swap v[1] and v[2]
                    swap v[2][0] and v[2][1]
                end of the block
                swap v[0] and v[1]
                swap v[0][0] and v[0][1]
            end of the block
            swap v[0] and v[2]
            swap v[2][0] and v[2][1]
        end of the block
        insert m into ss
    while next_permutation(s.begin(), s.end())
    print ss size
end of the block

[CODE]:

int main() {
    string s;
    cin >> s;
    set<string> ss;
    sort(s.begin(), s.end());
    do {
        string m = s;
        vector<string> v;
        for (int i = 0; i < 3; i++) { v.push_back(s.substr(2 * i, 2)); }
        for (int i = 0; i < 4; i++) {
            for (int i = 0; i < 4; i++) {
                for (int i = 0; i < 4; i++) {
                    string str = v[0] + v[1] + v[2];
                    m = min(m, str);
                    swap(v[1], v[2]);
                    swap(v[2][0], v[2][1]);
                }
                swap(v[0], v[1]);
                swap(v[0][0], v[0][1]);
            }
            swap(v[0], v[2]);
            swap(v[2][0], v[2][1]);
        }
        ss.insert(m);
    } while (next_permutation(s.begin(), s.end()));
    cout << ss.size() << "\n";
}


[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 constant int N = 2e5 + 5
create string s
create queue<string> q
create map mp of string to int
in function bfs taking string s
    mp[s] = true
    push s onto q
    while q is not empty
        create string u = front of q, v1, v2, v3
        pop q
        v1 = v2 = v3 = u
        v1[0] = u[3], v1[1] = u[0], v1[2] = u[1], v1[3] = u[2]
        v2[0] = u[4], v2[5] = u[0], v2[2] = u[5], v2[4] = u[2]
        v3[5] = u[1], v3[3] = u[5], v3[4] = u[3], v3[1] = u[4]
        if not mp[v1] then mp[v1] = true, push v1 onto q
        if not mp[v2] then mp[v2] = true, push v2 onto q
        if not mp[v3] then mp[v3] = true, push v3 onto q
    end of the block
end of the block
define the main function
    read s
    create int res = 0
    sort s
    do
        if mp[s] then continue
        add 1 to res
        call bfs on s
    while next_permutation(s.begin(), s.end())
    print res
    return to indicate successful execution
end of the block

[CODE]:

const int N = 2e5 + 5;
string s;
queue<string> q;
map<string, int> mp;
void bfs(string s) {
    mp[s] = true;
    q.push(s);
    while (!q.empty()) {
        string u = q.front(), v1, v2, v3;
        q.pop();
        v1 = v2 = v3 = u;
        v1[0] = u[3], v1[1] = u[0], v1[2] = u[1], v1[3] = u[2];
        v2[0] = u[4], v2[5] = u[0], v2[2] = u[5], v2[4] = u[2];
        v3[5] = u[1], v3[3] = u[5], v3[4] = u[3], v3[1] = u[4];
        if (!mp[v1]) mp[v1] = true, q.push(v1);
        if (!mp[v2]) mp[v2] = true, q.push(v2);
        if (!mp[v3]) mp[v3] = true, q.push(v3);
    }
}
int main() {
    cin >> s;
    int res = 0;
    sort(s.begin(), s.end());
    do {
        if (mp[s]) continue;
        res++;
        bfs(s);
    } while (next_permutation(s.begin(), s.end()));
    cout << res << '\n';
    return 0;
}


[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]:
x,res=int
t=map from string to bool
s,r=string
define the main function
    read s
    sort s
    do
        if not t[s]
            increment res
            r=s[0]
            append s[1] to r
            append s[2] to r
            append s[3] to r
            append s[4] to r
            append s[5] to r
            t[r]=true
            r=s[0]
            append s[2] to r
            append s[3] to r
            append s[4] to r
            append s[1] to r
            append s[5] to r
            t[r]=true
            r=s[0]
            append s[3] to r
            append s[4] to r
            append s[1] to r
            append s[2] to r
            append s[5] to r
            t[r]=true
            r=s[0]
            append s[4] to r
            append s[1] to r
            append s[2] to r
            append s[3] to r
            append s[5] to r
            t[r]=true
            r=s[5]
            append s[4] to r
            append s[3] to r
            append s[2] to r
            append s[1] to r
            append s[0] to r
            t[r]=true
            r=s[5]
            append s[1] to r
            append s[4] to r
            append s[3] to r
            append s[2] to r
            append s[0] to r
            t[r]=true
            r=s[5]
            append s[2] to r
            append s[1] to r
            append s[4] to r
            append s[3] to r
            append s[0] to r
            t[r]=true
            r=s[5]
            append s[3] to r
            append s[2] to r
            append s[1] to r
            append s[4] to r
            append s[0] to r
            t[r]=true
            r=s[1]
            append s[5] to r
            append s[2] to r
            append s[0] to r
            append s[4] to r
            append s[3] to r
            t[r]=true
            r=s[1]
            append s[2] to r
            append s[0] to r
            append s[4] to r
            append s[5] to r
            append s[3] to r
            t[r]=true
            r=s[1]
            append s[0] to r
            append s[4] to r
            append s[5] to r
            append s[2] to r
            append s[3] to r
            t[r]=true
            r=s[1]
            append s[4] to r
            append s[5] to r
            append s[2] to r
            append s[0] to r
            append s[3] to r
            t[r]=true
            r=s[3]
            append s[4] to r
            append s[0] to r
            append s[2] to r
            append s[5] to r
            append s[1] to r
            t[r]=true
            r=s[3]
            append s[5] to r
            append s[4] to r
            append s[0] to r
            append s[2] to r
            append s[1] to r
            t[r]=true
            r=s[3]
            append s[2] to r
            append s[5] to r
            append s[4] to r
            append s[0] to r
            append s[1] to r
            t[r]=true
            r=s[3]
            append s[0] to r
            append s[2] to r
            append s[5] to r
            append s[4] to r
            append s[1] to r
            t[r]=true
            r=s[2]
            append s[3] to r
            append s[0] to r
            append s[1] to r
            append s[5] to r
            append s[4] to r
            t[r]=true
            r=s[2]
            append s[5] to r
            append s[3] to r
            append s[0] to r
            append s[1] to r
            append s[4] to r
            t[r]=true
            r=s[2]
            append s[1] to r
            append s[5] to r
            append s[3] to r
            append s[0] to r
            append s[4] to r
            t[r]=true
            r=s[2]
            append s[0] to r
            append s[1] to r
            append s[5] to r
            append s[3] to r
            append s[4] to r
            t[r]=true
            r=s[4]
            append s[5] to r
            append s[1] to r
            append s[0] to r
            append s[3] to r
            append s[2] to r
            t[r]=true
            r=s[4]
            append s[3] to r
            append s[5] to r
            append s[1] to r
            append s[0] to r
            append s[2] to r
            t[r]=true
            r=s[4]
            append s[0] to r
            append s[3] to r
            append s[5] to r
            append s[1] to r
            append s[2] to r
            t[r]=true
            r=s[4]
            append s[1] to r
            append s[0] to r
            append s[3] to r
            append s[5] to r
            append s[2] to r
            t[r]=true
        end of the block
    while next permutation of s
    print res
    return to indicate successful execution
end of the block

[CODE]:


[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]:
new char array called colors filled with 'R', 'O', 'Y', 'G', 'B', 'V'
declare vector of integers called v
declare new array of integers tedad with size 300
define the main function
    declare string variable with name s
    read s from the user input
    for integer i = 0 to length of s exclusive, increment tedad[s[i]]
    create new vector of integers v
    for i from 0 to 6 exclusive
        if tedad[color[i]] != 0, add tedad[color[i]] after the last element of v
    sort v
    if length of v = 1
        print 1
    else if length of v = 2
        if v[0] is equal to 1
            print 1
        else
            print 2 to the standard output
    else if length of v is equal to 3
        if v[0] = 1
            if v[1] is equal to 1
                print 2
            else
                print 3
        else
            print 6 to the stdout
    else if length of v is equal to 4
        if v[3] = 3
            print 5 to the standard output
        else if v[3] = 2
            print 8 to the output
    else if length of v = 5
        print 15
    else if length of v is equal to 6
        print 30
    return to indicate successful execution
end of the block

[CODE]:

char color[6] = {'R', 'O', 'Y', 'G', 'B', 'V'};
vector<int> v;
int tedad[300];
int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) tedad[s[i]]++;
    vector<int> v;
    for (int i = 0; i < 6; i++)
        if (tedad[color[i]]) v.push_back(tedad[color[i]]);
    sort(v.begin(), v.end());
    if (v.size() == 1)
        cout << 1 << endl;
    else if (v.size() == 2) {
        if (v[0] == 1)
            cout << 1 << endl;
        else
            cout << 2 << endl;
    } else if (v.size() == 3) {
        if (v[0] == 1) {
            if (v[1] == 1)
                cout << 2 << endl;
            else
                cout << 3 << endl;
        } else
            cout << 6 << endl;
    } else if (v.size() == 4) {
        if (v[3] == 3)
            cout << 5 << endl;
        else if (v[3] == 2)
            cout << 8 << endl;
    } else if (v.size() == 5)
        cout << 15 << endl;
    else if (v.size() == 6)
        cout << 30 << endl;
    return 0;
}