[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]:
make string vector word
make integer vector be and af
create int set g
declare sf taking in string s and returning int
    make int n = s.size()
    if n is greater than or equal to 4 and s.substr(n - 4, 4) is equal to "lios"
        return to indicate successful execution
    else if n is greater than 5 and s.substr(n - 5, 5) is equal to "liala"
        return 1
    else if n is greater than or equal to 3 and s.substr(n - 3, 3) is equal to "etr"
        return 2
    else if n is greater than or equal to 4 and s.substr(n - 4, 4) is equal to "etra"
        return 3
    else if n is greater than or equal to 6 and s.substr(n - 6, 6) equals "initis"
        return 4
    else if n is greater than or equal to 6 and s.substr(n - 6, 6) equals "inites"
        return 5
    else do
        return -1
    end of the block
end of the block
define the main function
    make string s
    read s and while it's truthy, append s to word
    for i = 0 to size of word exclusive
        make integer j = sf(word[i])
        if j is equal to -1
            print "NO"
            return to indicate successful execution
        end of the block
        insert j % 2 to g
        append j / 2 to be
        append j / 2 to af
    end of the block
    if size of word is 1
        print "YES"
        return to indicate successful execution
    end of the block
    sort af
    if g.size() is not 1
        print "NO"
        return to indicate successful execution
    end of the block
    make integer cnt = 0
    for i = 0 to af.size() exclusive
        if af[i] is not equal to be[i]
            show "NO"
            return to indicate successful execution
        end of the block
        if af[i] is equal to 1, increment cnt
    end of the block
    if cnt is equal to 0 and size of word is not equal to 1
        show "NO"
        return to indicate successful execution
    else if cnt is not 1 and cnt is not 0
        display "NO"
        return to indicate successful execution
    end of the block
    output "YES"
    return to indicate successful execution
end of the block

[CODE]:

vector<string> word;
vector<int> be, af;
set<int> g;
int sf(string s) {
    int n = s.size();
    if (n >= 4 && s.substr(n - 4, 4) == "lios") {
        return 0;
    } else if (n >= 5 && s.substr(n - 5, 5) == "liala") {
        return 1;
    } else if (n >= 3 && s.substr(n - 3, 3) == "etr") {
        return 2;
    } else if (n >= 4 && s.substr(n - 4, 4) == "etra") {
        return 3;
    } else if (n >= 6 && s.substr(n - 6, 6) == "initis") {
        return 4;
    } else if (n >= 6 && s.substr(n - 6, 6) == "inites") {
        return 5;
    } else {
        return -1;
    }
}
int main() {
    string s;
    while (cin >> s) { word.push_back(s); }
    for (int i = 0; i < word.size(); i++) {
        int j = sf(word[i]);
        if (j == -1) {
            cout << "NO" << endl;
            return 0;
        }
        g.insert(j % 2);
        be.push_back(j / 2);
        af.push_back(j / 2);
    }
    if (word.size() == 1) {
        cout << "YES" << endl;
        return 0;
    }
    sort(af.begin(), af.end());
    if (g.size() != 1) {
        cout << "NO" << endl;
        return 0;
    }
    int cnt = 0;
    for (int i = 0; i < af.size(); i++) {
        if (af[i] != be[i]) {
            cout << "NO" << endl;
            return 0;
        }
        if (af[i] == 1) { cnt++; }
    }
    if (cnt == 0 && word.size() != 1) {
        cout << "NO" << endl;
        return 0;
    } else if (cnt != 1 && cnt != 0) {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    return 0;
}