[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 constant integer N = 1e5 + 7
declare constant string array s = {"lios", "liala", "etr", "etra", "initis", "inites"}
declare map from string to integer mp
declare string array h size N
declare integer a size N
declare inline get_s with string address s as argument, returning integer
    if size of s is less than 3, return 0 from function
    for i = 3 to 6 inclusive
        if i is greater than size of s, return 0 from function
        if first index of ( substring of s from size of s - i to i ) in mp is not end of mp, return mp[substring of s from size of s - i to i]
    end of the block
    return to indicate successful execution
end of the block
define the main function
    declare integer cnt = 0
    for i = 0 to 6 exclusive, let mp[s[i]] be i + 1
    while ( read h[cnt] ), increment cnt
    declare booleans f1 = 0, f2 = 0
    for i = 0 to cnt exclusive
        let a[i] be result of run get_s(h[i])
        if not a[i], return 0 * print "NO"
        let f1 be f1 bitwise or (bitwise and 1 ), let f2 be f2 bitwise or ( bitwise not a[i] bitwise and 1 )
    end of the block
    if cnt is 1, return 0 * print "YES"
    if f1 and f2, return 0 * print "NO"
    for i = 0 to cnt exclusive, increment a[i] by 1, let a[i] be a[i] bitshift right 1
    declare integer p = 0
    while p is less than cnt - 1 and a[p] is a[p+1] and a[p] is 1, increment p
    if a[p] is 1
        increment p
    else if a[p] is 3
        return 0 * print "NO"
    if a[p] is not 2
        return 0 * print "NO"
    else
        increment p
    while p is less than cnt
        if a[increment p] is not 3, return 0 * print "NO"
    if a[increment p] is not 3, return 0 * print "NO"
    return to indicate successful execution
end of the block

[CODE]:

const int N = 1e5 + 7;
const string s[] = {"lios", "liala", "etr", "etra", "initis", "inites"};
map<string, int> mp;
string h[N];
int a[N];
inline int get_s(string &s) {
    if (s.size() < 3) return 0;
    for (int i = 3; i <= 6; i++) {
        if (i > s.size()) return 0;
        if (mp.find(s.substr(s.size() - i, i)) != mp.end()) return mp[s.substr(s.size() - i, i)];
    }
    return 0;
}
int main() {
    int cnt = 0;
    for (int i = 0; i < 6; i++) mp[s[i]] = i + 1;
    while (cin >> h[cnt]) cnt++;
    bool f1 = 0, f2 = 0;
    for (int i = 0; i < cnt; i++) {
        a[i] = get_s(h[i]);
        if (!a[i]) return 0 * puts("NO");
        f1 |= a[i] & 1, f2 |= ~a[i] & 1;
    }
    if (cnt == 1) return 0 * puts("YES");
    if (f1 && f2) return 0 * puts("NO");
    for (int i = 0; i < cnt; i++) (a[i] += 1) >>= 1;
    int p = 0;
    while (p < cnt - 1 && a[p] == a[p + 1] && a[p] == 1) p++;
    if (a[p] == 1)
        p++;
    else if (a[p] == 3)
        return 0 * puts("NO");
    if (a[p] != 2)
        return 0 * puts("NO");
    else
        p++;
    while (p < cnt)
        if (a[p++] != 3) return 0 * puts("NO");
    puts("YES");
    return 0;
}