[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]:
ip, ip2 and n are ints with ip and ip2 = 0
declare vector of integers called v
s is a new array of characters with 100010 elements
in the function next_token that returns boolean
    set the value of ip to ip2
    while ip < n and (s[ip] < 'a' or s[ip] > 'z')
    if ip is equal to n, return false
    change ip2 to ip
    while ip2 < n and s[ip2] >= 'a' and s[ip2] <= 'z'
    return true
end of the block
declare character z
function get_type that returns integer
    define new integer len with value ip2-ip
    change z to s[ip2]
    assign the new value = 0 to s[ip2]
    if s + ip + len - 4 matches "lios", return 0
    if result of s + ip + len - 5 = "liala" return 1
    if s + ip + len - 3 matches "etr" return 10
    if strcmp(s + ip + len - 4,"etra") returns 0, return 11
    if comparison of s + ip + len - 6 with "initis" returns 0, return 20
    return 21 if s + ip + len - 6 matches "inites"
    return -1
end of the block
boolean function solve
    in a for loop, change i from 0 to length of v exclusive
        if v[i] is equal to -1, return false
    return true if length of v = 1
    start for loop from i = 0 to length of v exclusive incrementing i
        in a for loop, change j from 0 to i exclusive
            return false if v[i] % 10 != v[j] % 10
    start for loop from i = 0 to length of v - 1 exclusive incrementing i
        if v[i] is greater than v[i + 1], return false
    create new integer cnt = 0
    increment i in a loop from i = 0 to length of v exclusive
        if v[i] / 10 = 1, increment cnt
    if cnt is equal to 1
        return true
    else
        return false
end of the block
define the main function
    store input into s
    change n to length of s
    while next_token() returns true
        push new value = the result of get_type() into v
        change s[ip2] to z
    end of the block
    if call to solve() returned true
        print "YES"
    else
        print "NO" to standard output
    return to indicate successful execution
end of the block

[CODE]:

int ip = 0, ip2 = 0, n;
vector<int> v;
char s[100010];
bool next_token() {
    ip = ip2;
    while (ip < n && (s[ip] < 'a' || s[ip] > 'z')) ip++;
    if (ip == n) return false;
    ip2 = ip;
    while (ip2 < n && s[ip2] >= 'a' && s[ip2] <= 'z') ip2++;
    return true;
}
char z;
int get_type() {
    int len = ip2 - ip;
    z = s[ip2];
    s[ip2] = 0;
    if (strcmp(s + ip + len - 4, "lios") == 0) return 0;
    if (strcmp(s + ip + len - 5, "liala") == 0) return 1;
    if (strcmp(s + ip + len - 3, "etr") == 0) return 10;
    if (strcmp(s + ip + len - 4, "etra") == 0) return 11;
    if (strcmp(s + ip + len - 6, "initis") == 0) return 20;
    if (strcmp(s + ip + len - 6, "inites") == 0) return 21;
    return -1;
}
bool solve() {
    for (int i = 0; i < v.size(); i++)
        if (v[i] == -1) return false;
    if (v.size() == 1) return true;
    for (int i = 0; i < v.size(); i++)
        for (int j = 0; j < i; j++)
            if (v[i] % 10 != v[j] % 10) return false;
    for (int i = 0; i < v.size() - 1; i++)
        if (v[i] > v[i + 1]) return false;
    int cnt = 0;
    for (int i = 0; i < v.size(); i++)
        if (v[i] / 10 == 1) cnt++;
    if (cnt == 1)
        return true;
    else
        return false;
}
int main() {
    gets(s);
    n = strlen(s);
    while (next_token()) {
        v.push_back(get_type());
        s[ip2] = z;
    }
    if (solve())
        puts("YES");
    else
        puts("NO");
    return 0;
}