p460.cpp
======================
#include <bits/stdc++.h>
#define endl '\n'

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

using namespace std;
template<class T, class T2>
inline void chkmax(T& x, const T2& y) {
    if(x < y) {
        x = y;
    }
}
template<class T, class T2>
inline void chkmin(T& x, const T2& y) {
    if(x > y) {
        x = y;
    }
}
const int MAXN = (1 << 20);

string s;

void read() { cin >> s; }

void solve() {
    if(s.back() == 'y') {
        s.erase(prev(s.end()));
        cout << s << "ies" << endl;
    } else if((s.back() == 'h' && s[s.size() - 2] == 'c') || s.back() == 'o' || s.back() == 'x' || s.back() == 's') {
        cout << s << "es" << endl;
    } else if(s.back() == 'f' || (s[s.size() - 2] == 'f' && s.back() == 'e')) {
        while(s.back() != 'f') {
            s.pop_back();
        }
        s[s.size() - 1] = 'v';
        s += "es";
        cout << s << endl;
    } else {
        cout << s << "s" << endl;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int T;
    cin >> T;
    while(T--) {
        read();
        solve();
    }

    return 0;
}

=================
statement.txt
======================
460. Plural Form of Nouns
Time limit per test: 0.25 second(s)
Memory limit: 65536 kilobytes
input: standard
output: standard

In the English language, nouns are inflected by grammatical number — that is singular or plural. In this problem we use a simple model of constructing plural from a singular form. This model doesn't always make English plural forms correctly, but it works in most cases. Forget about the real rules you know while solving the problem and use the statement as a formal document.

You are given several nouns in a singular form and your program should translate them into plural form using the following rules:


If a singular noun ends with ch, x, s, o the plural is formed by adding es. For example, witch -> witches, tomato -> tomatoes.

If a singular noun ends with f or fe, the plural form ends with ves. For example, leaf -> leaves, knife -> knives. Pay attention to the letter f becoming v.

Nouns ending with y change the ending to ies in plural. For example, family -> families.

In all other cases plural is formed by adding s. For example, book -> books.


Input
The first line of input contains a single positive integer n (1 ≤ n ≤ 10) — the number of words to be processed. The following n lines contain one word each. A word consists from 2 to 25 lowercase Latin letters. It is not guaranteed that the given words are real English words from vocabulary.

Output
Print n given words in their plural forms on separate lines. Keep the words in the same order as they are given in the input.

Example(s)
sample input
sample output
3
contest
hero
lady
contests
heroes
ladies

=================
