[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]:
integer array = n,d[111]
array a size 111, s, t = string
create character variable
define the main function
    read n
    for i = 1 to less than or equal to n do the following
        read a[i]
        for j = 0 to less than a[i].size() do the following
            if a[i][j] is greater than or equal to a then subtract 32 from a[i][j]
    end of the block
    read s
    set t to s
    read lucky
    if lucky is greater than or equal to a then subtract 32 from lucky
    integers = sl = s.length()
    for i = 0 to less than sl do the following
        if s[i] is greater than or equal to a then subtract 32 from s[i], d[i] = 1
    end of the block
    for i = 0 to less than sl do the following
        for j = 1 to less than or equal to n do the following
            integers l = a[j].length()
            if i + l is less than or equal to sl and s.substr(i, l) is a[j]then do the following
                for k = 0 to less than l do the following
                    if s[i + k] is lucky then do the following
                        if lucky is A then do the following
                            set t[i + k] to b if d[i + k] is true or else d[i+k] = B)
                        else
                            set t[i + k] to b if d[i + k] is true or else d[i+k] = A)
                    else
                        set t[i + k] to lucky+32 if d[i + k]is true else t[i+k] = lucky
                end of the block
            end of the block
        end of the block
    end of the block
    output t
    return to indicate successful execution
end of the block

[CODE]:

int n, d[111];
string a[111], s, t;
char lucky;
int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        for (int j = 0; j < a[i].size(); j++)
            if (a[i][j] >= 'a') a[i][j] -= 32;
    }
    cin >> s;
    t = s;
    cin >> lucky;
    if (lucky >= 'a') lucky -= 32;
    int sl = s.length();
    for (int i = 0; i < sl; i++) {
        if (s[i] >= 'a') s[i] -= 32, d[i] = 1;
    }
    for (int i = 0; i < sl; i++) {
        for (int j = 1; j <= n; j++) {
            int l = a[j].length();
            if (i + l <= sl && s.substr(i, l) == a[j]) {
                for (int k = 0; k < l; k++) {
                    if (s[i + k] == lucky) {
                        if (lucky == 'A')
                            t[i + k] = (d[i + k] ? 'b' : 'B');
                        else
                            t[i + k] = (d[i + k] ? 'a' : 'A');
                    } else
                        t[i + k] = (d[i + k] ? lucky + 32 : lucky);
                }
            }
        }
    }
    cout << t << "\n";
    return 0;
}