For this Question: Aniket considers a string happy if at least one pair of characters exist at positions i and j (i < j) such that character at position i is lexographically smaller than character at position j. 
For example strings "aab", "aba", "zxy" are happy, while strings "aaa", "zyx", "ccb" are not happy.

You are given N strings, you need to find the number of pairs (k, l) such that s<sub>k</sub>+s<sub>l</sub> is a happy string. (Consider all N*N pairs)The first line of the input contains a single integer N.
Next N lines contain N strings consisting of only lowercase letters of the english alphabet.

Constraints
1 <= N <= 100000
1 <= length of string <= 5Output the number of pairs (k, l) such that the concatenation of strings s<sub>k</sub> and s<sub>l</sub> is happy.Sample Input
5
a
a
b
d
c

Sample Output
9

The happy strings are the concatenation of the following pairs (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5), (3, 4), (3, 5), (5, 4)

Sample Input
3
cbcb
fffee
d

Sample Output
7

Explanation: Concatenation of all pairs except (2, 3) and (3, 3) form happy strings., I have written this Solution Code: #include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(int i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define ld long double
#define int long long
#define double long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
const int MOD = 1e9+7;
const int INF = 1LL<<60;


const int N = 2e5+5;

// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


void solve(){
    int n; cin>>n;
    string s;
    int ct = 0;
    vector<int> mnv, mxv;
    For(i, 0, n){
        cin>>s;
        int mx = -1;
        int mn = 100;
        bool fl = false;
        for(char c: s){
            int x = c-'a';
            if(x > mn){
                fl = true;
                break;
            }
            mn = min(mn, x);
            mx = max(mx, x);
        }
        if(fl)
            ct++;
        else{
            mnv.pb(mn);
            mxv.pb(mx);
        }
    }
    int ans = n*ct;
    sort(all(mxv));
    for(int i: mnv){
        int p = upper_bound(all(mxv), i)-mxv.begin();
        ans += (n-p);
    }
    cout<<ans;
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}

, In this Programming Language: C++, Now tell me if this Code is compilable or not?