Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		var result string
		line := scanner.Text()
		key := make(map[string]string)

		var i int32
		for ; i < 52; i++ {
			makeKey(key, i)
			result = decode(key, line)

			if strings.Contains(result, "the") {
				break
			} else if strings.Contains(result, "this") {
				break
			} else if strings.Contains(result, "that") {
				break
			}
		}

		fmt.Println(result)
	}
}

func makeKey(key map[string]string, shift int32) {
	for i := 'a'; i <= 'z'; i++ {
		cipher := (i + shift)
		if cipher > 'z' {
			cipher = cipher%'z' + 'a' - 1
		} else if cipher < 'a' {
			cipher = cipher + ('z' - 'a') + 1
		}
		key[string(i)] = string(cipher)
	}
}

func decode(key map[string]string, cipher string) string {
	var result string
	for _, v := range cipher {
		if key[string(v)] != "" {
			result += key[string(v)]
		} else {
			result += string(v)
		}
	}
	return result
}

C++: #include <iostream>
#include <string>
#include <stdio.h>

#define NUM_OF_ALPHABET ('z' - 'a' + 1)

bool isValidResult(const std::string str);
bool decodeStr(const std::string srcStr, std::string& dstStr, int decodeNum);

int main(void)
{
	std::string inputStr;
	std::string outputStr;

	char line[100];
	fgets(line, sizeof(line), stdin);
	inputStr = line;

	for (int i = 0; i < NUM_OF_ALPHABET; i++) {
		if (decodeStr(inputStr, outputStr, i)) {
			std::cout << outputStr;
			break;
		}
		outputStr.clear();
	}
	return 0;
}

bool isValidResult(const std::string str)
{
	if (str.find(" the") != std::string::npos || str.find(" this") != std::string::npos || str.find(" that") != std::string::npos ||
		str.find("the ") != std::string::npos || str.find("this ") != std::string::npos || str.find("that ") != std::string::npos) {
		return true;
	}
	else {
		return false;
	}
}

bool decodeStr(const std::string srcStr, std::string& dstStr, int decodeNum)
{
	for (int i = 0; i < srcStr.size(); i++) {
		if (srcStr.at(i) >= 'a' && srcStr.at(i) <= 'z') {
			unsigned char tmpChar;
			tmpChar = srcStr.at(i) + decodeNum;
			if (tmpChar > 'z') {
				tmpChar -= NUM_OF_ALPHABET;
			}
			dstStr.push_back(tmpChar);
		}
		else {
			dstStr.push_back(srcStr.at(i));
		}
	}
	if (isValidResult(dstStr)) {
		return true;
	}
	else {
		return false;
	}
}

C++: #include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>

using namespace std;


int main(){

	string line;

	while(getline(cin, line)){

		string str[80], ans[80];
		int count = 0;
		int flag = 0;
		int slide;

		//???????????????????????¨???????´?
		for(int i=0 ; i<line.size()-1 ; i++){
			if(line[i] == ' '){
				count++;
			}else{
				str[count] += line[i];
				ans[count] = str[count];
			}
		}


		for(int i=0 ; i<26 ; i++){
			for(int j=0 ; j<=count ; j++){
				for(int k=0 ; k<str[j].size() ; k++){
					if(str[j][k] != '.'){
						str[j][k]++;
						if(str[j][k] > 'z'){
							str[j][k] = str[j][k] - 'z' + 'a' -1;
						}
					}
				}

				if(str[j] == "this" || str[j] == "the" || str[j] == "that"
						|| str[j] == "this." || str[j] == "the." ||str[j] == "that."){
					flag = 1;
					slide = i+1;
					break;
				}
			}
			if(flag == 1)break;
		}

		for(int i=0 ; i<=count ; i++){
			for(int j=0 ; j<ans[i].size() ; j++){
				if(ans[i][j] != '.'){
					if((ans[i][j] + slide) > 'z' ){
						ans[i][j] = ans[i][j] - 'z' + 'a' -1 + slide;
					}else{
						ans[i][j] += slide;
					}
				}
			}
		}

		for(int i=0 ; i<count ; i++){
			cout << ans[i] << ' ';
		}
		cout << ans[count] << endl;

	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
	string str;
	string in;
	vector<string> s;
	while (cin >> in) s.push_back(in);
	for (int i=0; i<(int)s.size(); i++) {
		str += s[i];
		if (i<(int)s.size()-1) str += " ";
	}
	
	for (int i=0; i<26; i++) {
		if (str.find("the")!=str.npos || str.find("this")!=str.npos || str.find("that")!=str.npos) break;
		for (int j=0; j<(int)str.size(); j++) {
			if (str[j] == '.' || str[j] == ' ') continue;
			str[j] = 'a' + (str[j] - 'a' + 1)%26;
		}
	}
	
	cout << str << endl;
	
	return 0;
}

C++: #include <cstdio>
#include <string>
#include <vector>
#include <map>
using namespace std;
static map<char, int> create_map() {
    map<char, int> m;
    string base = "abcdefghijklmnopqrstuvwxyz";
    for (int i = 0; i < 26; i++) m.insert({base[i], i});
    return m;
}
static map<char, int> m = create_map();
static string base = "abcdefghijklmnopqrstuvwxyz";
string str;
static int t1[4] = {0, 14, 7, 0}; //that
static int t2[4] = {0, 14, 15, 25}; //this
static int t3[3] = {0, 14, 11}; //the
int cdiff;

int main(void){

    char chs[81];
    while(fgets(chs, 81, stdin) != 0){
        str = chs;
        cdiff = 27;
        int sidx;
        for (int i = 0; i < str.size()-2; i++) {
            if (cdiff != 27) break;
            sidx = m[str[i]];
            //if character is a space or a point or distance between current and next character is not that we expected...
            if (str[i+1] == '.' || str[i+1] == ' ' || base[(sidx+t3[1])%26] != str[i+1]) continue;
            if (str[i+2] != '.' && str[i+2] != ' ' && base[(sidx+t3[2])%26] == str[i+2]) { cdiff = sidx - m['t']; break; }
            if (i < str.size()-3) {
                if (str[i+2] == '.' || str[i+3] == '.' || str[i+2] == ' ' || str[i+3] == ' ') continue;
                if (base[(sidx+t1[2])%26] == str[i+2] && base[(sidx+t1[3])%26] == str[i+3]) { cdiff = sidx-m['t']; break; }
                if (base[(sidx+t2[2])%26] == str[i+2] && base[(sidx+t2[3])%26] == str[i+3]) { cdiff = sidx-m['t']; break; }
            }
        }
        map<char, char> m2;
        for (int i = 19; i < 45; i++) m2.insert({base[(cdiff+i)%26], base[i%26]});
        m2.insert({'.', '.'}); m2.insert({' ', ' '});
        string str2 = "";
        for (int i = 0; i < str.size(); i++) {
            str2 += m2[str[i]];
        }
        printf("%s\n", str2.c_str());
    }


    return 0;
}

C++: #include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;

// determine whether it is "the","this" or "that"
char get_shift(string w) {
	char sh = 't' - w.front();
	for_each(w.begin(),w.end(),[sh](char &c) {
		c += sh;
		if (c > 'z') {
			c -= (char)26;
		} else if (c < 'a') {
			c += (char)26;
		}
	});
	if (w != "the" && w != "this" && w != "that") {
		sh = '\0';
	}
	return sh;
}

int main() {
	string s;
	while (getline(cin,s)) {
		istringstream stream(s);
		string w;
		char sh;
		while (stream >> w) {
			while (!w.empty() && w.front() == '.') {
				w.erase(0,1);
			}
			while (!w.empty() && w.back() == '.') {
				w.pop_back();
			}
			if (!w.empty()) {
				if ((sh = get_shift(w)) != '\0') {
					break;
				}
			}
		}
		for_each(s.begin(),s.end(),[sh](char &c) {
			if (c >= 'a' && c <= 'z') {
				c += sh;
				if (c > 'z') {
					c -= (char)26;
				} else if (c < 'a') {
					c += (char)26;
				}
			}
		});
		cout << s << endl;
	}
}