#include #include using namespace std; int main(){ string msg; cin >> msg; int mid = msg.size() /2 ; string first = msg.substr(0, mid); string second = msg.substr(mid, mid); int rotation_first = 0; int rotation_second = 0; for(int i = 0; i < first.size(); i++){ rotation_first += (first[i] - 'A'); rotation_second += (second[i] - 'A'); } rotation_first = rotation_first % 26; rotation_second = rotation_second % 26; for(int i = 0; i < first.size(); i++){ first[i] = first[i] + rotation_first; if(first[i] > 'Z') first[i] = first[i] - 26; second[i] = second[i] + rotation_second; if(second[i] > 'Z') second[i] = second[i] - 26; } // cout << "Decrypted first: " << first << endl; // cout << "Decrypted second: " << second << endl; string result; for(int i = 0; i < first.size(); i++){ char c = first[i] + (second[i]-'A'); if (c > 'Z') c = c - 26; result = result + c; } cout << result << endl; return 0; }