Go: package main

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

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 reflect.DeepEqual(infos, []string{}) {
			break
		}
		fmt.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<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<cstdlib>
using namespace std;

string resolve(string org,int ch){
	string ret = "";
	for(int x=0;x<org.size();++x){
		if(org[x]==' ' || org[x]=='.'){
			ret += org[x];
		}else if(org[x]+ch<'a'){
			ret += 'z' - ('a'-(org[x]+ch)-1);
		}else if(org[x]+ch>'z'){
			ret += 'a' +(org[x]+ch-'z'-1);
		}else{
			ret += org[x]+ch;
		}	
	}
	return ret;
}

vector<string> tokens(string line){
	vector<string> ret;
	int b=0;
	string tmp= "";
	while(line[b]!=0){
		if(line[b]==' '){	
			if(tmp.size()>0){
				ret.push_back(tmp);
			}
			tmp = "";
		}else{
			tmp += line[b];
		}
		++b;
	}
	if(tmp.size()>0){
		ret.push_back(tmp);
	}
	return ret;
}

string solve(string line){
	vector<string> tok = tokens(line);
	int ch = 0;
	for(int x=0;x<tok.size();++x){
		if(tok[x].size()==3 || tok[x].size()==4){
			int tmp = 't'-tok[x][0];
			if(tmp>0){
				tmp = -7-tok[x][0]+'a';
			}
			string sol = resolve(tok[x],tmp);
			if(sol=="the" || sol =="that" || sol=="this"){ch = tmp;break;}
		}
	}
	return resolve(line,ch);
}

int main(){
	string line;
	while(getline(cin,line)){
		if(line=="")break;
		cout<<solve(line)<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
 
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string str;
	getline(cin, str);
	
	while(1){
		for(size_t i = 0; i < str.size(); ++i){
			if('A' <= str[i] && str[i] <= 'Z'){
				if(str[i] == 'Z'){
					str[i] = 'A';
				}
				else {
					str[i]++;
				}
			}
			if('a' <= str[i] && str[i] <= 'z'){
				if(str[i] == 'z'){
					str[i] = 'a';
				}
				else {
					str[i]++;
				}
			}
		}
		bool check = false;
		for(size_t i = 0; i < str.size(); ++i){
			if(str[i] == 't'){
				if(str.substr(i, 3) == "the" || str.substr(i, 4) == "this" || str.substr(i, 4) == "that"){
					check = true;
					break;
				}
			}
		}
		if(check){
			break;
		}
	}
	cout << str << endl;
	
	return 0;
}

C++: #include <cstdio>
#include <cstring>

int main(){
    char THIS[] = "this";
    char THE[] = "the";
    char THAT[] = "that";
    
    while(feof(stdin) == 0){
        char str[81];
        fgets(str,80,stdin);
        if(str[0] == 0) break;
        
        int str_cnt = 0;
        int z = 0;
        while(str_cnt < strlen(str)){
            char key[10];
            int offset;
            sscanf(&str[str_cnt],"%s ",key);
            str_cnt += strlen(key) + 1;
            
            switch(strlen(key)){
            case 3:
                offset = THE[0] - key[0];
                if(THE[1] - key[1] == offset && THE[2] - key[2] == offset){
                    z = offset;
                    str_cnt = 999999;
                    break;
                }
                break;
            case 4:
                offset = THIS[0] - key[0];
                if(THIS[1] - key[1] == offset && THIS[2] - key[2] == offset && THIS[3] - key[3] == offset){
                    z = offset;
                    str_cnt = 999999;
                    break;
                }
                if(THAT[1] - key[1] == offset && THAT[2] - key[2] == offset && THAT[3] - key[3] == offset){
                    z = offset;
                    str_cnt = 999999;
                    break;
                }
                break;
            }
        }
        //z *= -1;
        for(int i = 0;i < strlen(str);i++){
            if(str[i] != ' ' && str[i] != '.') printf("%c",str[i]+z);
            else                               printf("%c",str[i]); 
        }
        printf("\n");
    }
}

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

// determine whether it is "the","this" or "that"
char is_article(string w) {
	char sh = '\0'; // shift defaults to 0
	if (w.size() == 3) {
		sh = 't' - w.front();
		for_each(w.begin(),w.end(),[sh](char &c) {
			c += sh;
			if (c > 'z') {
				c -= 'z'-'a'+1;
			} else if (c < 'a') {
				c += 'z'-'a'+1;
			}
		});
		if (w != "the") {
			sh = '\0';
		}
	} else if (w.size() == 4) {
		sh = 't' - w.front();
		for_each(w.begin(),w.end(),[sh](char &c) {
			c += sh;
			if (c > 'z') {
				c -= 'z'-'a'+1;
			} else if (c < 'a') {
				c += 'z'-'a'+1;
			}
		});
		if (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) {
			if ((sh = is_article(w)) != '\0') {
				break;
			}
		}
		for_each(s.begin(),s.end(),[sh](char &c) {
			if (c >= 'a' && c <= 'z') {
				c += sh;
				if (c > 'z') {
					c -= 'z'-'a'+1;
				} else if (c < 'a') {
					c += 'z'-'a'+1;
				}
			}
		});
		cout << s << endl;
	}
}

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

int CheckDiff(string);
int ShowSourceString(string,int);
int main(){
	string str;
	while(getline(cin,str)){
		ShowSourceString(str,CheckDiff(str));
	}
	
	return 0;
}

int CheckDiff(string str){
	for( int i=0;i<(int)str.length();i++ ){
		if( (abs(str[i+1]-str[i])==abs('h'-'t'))&& 
		    (abs(str[i+2]-str[i])==abs('a'-'t'))&&
		    (abs(str[i+3]-str[i])==abs('t'-'t'))
		){
			return str[i]-'t';
		}
		if( (abs(str[i+1]-str[i])==abs('h'-'t'))&& 
		    (abs(str[i+2]-str[i])==abs('i'-'t'))&&
		    (abs(str[i+3]-str[i])==abs('s'-'t'))
		){
			return str[i]-'t';
		}
		if( (abs(str[i+1]-str[i])==abs('h'-'t'))&& 
		    (abs(str[i+2]-str[i])==abs('e'-'t'))
		){
			return str[i]-'t';
		}
	}
	return 0;
}
int ShowSourceString(string str,int diff){
	for( int i=0;i<(int)str.length();i++ ){
		if('a'<=str[i]&&str[i]<='z' ){
			if(str[i]-diff>'z'){
				cout<<(char)('a'+str[i]-diff-'z'-1);			
			}else if(str[i]-diff<'a'){
				cout<<(char)('z'-('a'-(str[i]-diff))+1);			
			}else{
				cout<<(char)(str[i]-diff);
			}
		}else{
			cout<<(char)str[i];
		}
	}
	cout<<endl;
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int main() {
	string str;
	while(getline(cin, str)) {
		int n = 't' - str[0];
		for(int i = 0; str[i] != '\0'; i++) {
			if(('a' <= str[i])&&(str[i] <= 'z')) {
				str[i] += n;
				if(str[i] > 'z') {
					str[i] = str[i] - 26;
				} else if(str[i] < 'a') {
					str[i] = str[i] + 26;
				}
			}
		}
		cout << str << endl;
	}
	return 0;
}