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