Problem:
Score : 100 points

Problem Statement

You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.

Constraints

The length of S is 2 or 3.

S consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S

Output

If the length of S is 2, print S as is; if the length is 3, print S after reversing it.

Sample Input 1

abc

Sample Output 1

cba

As the length of S is 3, we print it after reversing it.

Sample Input 2

ac

Sample Output 2

ac

As the length of S is 2, we print it as is.

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define int long long
using namespace std;
 
signed main(void){
    int n,mone = 0,mtwo = 0;
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    vector<int> aligns(n);
    rep(i,n) {
        cin >> aligns[i];
    }
    sort(aligns.begin(),aligns.end());
    if(aligns.size() == 2) {
        cout << aligns[1] - aligns[0] << endl;
        return 0;
    }
    rep(i,n) {
        mone += aligns[n-1-i] - aligns[i];
        mtwo += aligns[n-1-i] - aligns[i];
        if(n-1-i-i == 2) {
            mone += aligns[n-1] - aligns[i+1];
            mtwo += aligns[i+1] - aligns[0];
            break;
        } else if(n-1-i-i == 3) {
            mone += aligns[n-2-i] - aligns[i];
            mtwo += aligns[n-1-i] - aligns[i+1];
            mone += aligns[n-1] - aligns[i+1];
            mtwo += aligns[i+2] - aligns[0];
            break;
        } else {
            mone += aligns[n-2-i] - aligns[i];
            mtwo += aligns[n-1-i] - aligns[i+1]; 
        }
    }
    cout << max(mone,mtwo) << endl;
    return 0;
}