Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func cipher(text string, direction int, int_shift int) string {
	shift, offset := rune(int_shift), rune(26)
	runes := []rune(text)
	for index, char := range runes {
		switch direction {
		case 1:
			if char >= 'a' && char <= 'z'-shift || char >= 'A' && char <= 'Z'-shift {
				char = char + shift
			} else if char > 'z'-shift && char <= 'z' || char > 'Z'-shift && char <= 'Z' {
				char = char + shift - offset
			}
		case -1:
			if char >= 'a'+shift && char <= 'z' || char >= 'A'+shift && char <= 'Z' {
				char = char - shift
			} else if char >= 'a' && char < 'a'+shift || char >= 'A' && char < 'A'+shift {
				char = char - shift + offset
			}
		}
		runes[index] = char
	}
	return string(runes)
}

func main() {
	for {
		infos := strings.Split(nextString(), " ")
		plain := make([]string, len(infos))
		if len(infos) == 0 {
			break
		}
		// println(infos)
		Decryption:
			for i := 0; i < 26; i++ {
				for j := range infos {
					plain[j] = cipher(infos[j], 1, i)
				}
				for j := range plain {
					if plain[j] == "this" || plain[j] == "that" || plain[j] == "the" {
						break Decryption
					}
				}
			}
			fmt.Println(strings.Join(plain, " "))
	}
}

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

using namespace std;

string
caesar (string str, int n)
{
  const string table = "abcdefghijklmnopqrstuvwxyz";
  string ans (str.length (), ' ');
  for (int i = 0; i < str.length (); i++)
    {
      int buf = table.find (str[i]);
      if (buf == string::npos)
	{
	  ans[i] = str[i];
	}
      else
	{
	  ans[i] = (buf + n < table.length ())? table[buf + n]
	    : table[buf + n - table.length ()];
	}
    }
  return ans;
}

int
main ()
{
  string str;
  getline (cin, str);
  string after;
  for (int i = 0; i <= 25; i++)
    {
      after = caesar (str, i);
      if (after.find ("the") != string::npos)
	break;
      if (after.find ("this") != string::npos)
	break;
      if (after.find ("that") != string::npos)
	break;
    }
  cout << after << endl;
}

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;
}