[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 int variables flag, gender, ok, t and cnt
declare new string called s
define new array of strings filled with elements "lios", "liala", "etr", "etra", "initis" and "inites"
integer function cmp with string arguments a and b
    define integers len1 = length of a, and lent2 = length of b
    start for loop from i = 0 to len2 exclusive
        return 0 if a[len1 - len2 + i] != b[i]
    end of the block
    return 1
end of the block
define the main function
    assign the new value = 3 to gender
    read s and keep looping
        set ok to 0
        for integer i = 0 to 6 exclusive incrementing i
            if cmp(s, x[i]) is not 0
                assign 1 to ok
                increment cnt by one
                if gender = 3
                    set the value of gender to i modulo 2
                else if i % 2 != gender
                    print "NO"
                    return to indicate successful execution
                end of the block
                assign the new value = i / 2 + 1 to t
                if t is equal to 1 and flag = 0
                    change flag to 1
                else if t and flag are both 1
                    change flag to 1
                else if t is equal to 2 and flag is equal to 1
                    set the value of flag to 2
                else if t is equal to 2 and flag = 0
                    assign the new value = 2 to flag
                else if t is equal to 3 and flag = 0
                    assign the new value = -1 to flag
                else if t is equal to 3 and flag = 2
                    set the value of flag to 3
                else if t and flag are both equal to 3
                    change flag to 3
                else
                    print "NO"
                    return to indicate successful execution
                end of the block
            end of the block
        end of the block
        if ok is equal to 0
            print "NO"
            return to indicate successful execution
        end of the block
        if character from the input is equal to '\n', break the loop
    end of the block
    if flag = 1 and cnt > 1
        print "NO"
    else
        print "YES"
    return to indicate successful execution
end of the block

[CODE]:

int flag, gender, ok, t, cnt;
string s;
string x[6] = {"lios", "liala", "etr", "etra", "initis", "inites"};
int cmp(string a, string b) {
    int len1 = a.size(), len2 = b.size();
    for (int i = 0; i < len2; i++) {
        if (a[len1 - len2 + i] != b[i]) return 0;
    }
    return 1;
}
int main() {
    gender = 3;
    while (cin >> s) {
        ok = 0;
        for (int i = 0; i < 6; i++) {
            if (cmp(s, x[i])) {
                ok = 1;
                cnt++;
                if (gender == 3)
                    gender = i % 2;
                else if (i % 2 != gender) {
                    cout << "NO" << endl;
                    return 0;
                }
                t = i / 2 + 1;
                if (t == 1 && flag == 0)
                    flag = 1;
                else if (t == 1 && flag == 1)
                    flag = 1;
                else if (t == 2 && flag == 1)
                    flag = 2;
                else if (t == 2 && flag == 0)
                    flag = 2;
                else if (t == 3 && flag == 0)
                    flag = -1;
                else if (t == 3 && flag == 2)
                    flag = 3;
                else if (t == 3 && flag == 3)
                    flag = 3;
                else {
                    cout << "NO" << endl;
                    return 0;
                }
            }
        }
        if (ok == 0) {
            cout << "NO" << endl;
            return 0;
        }
        if (cin.get() == '\n') break;
    }
    if (flag == 1 && cnt > 1)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
    return 0;
}