Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

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 scanner.Scan() {
		infos := strings.Split(scanner.Text(), " ")
		plain := make([]string, len(infos))
		// 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 <string>

using namespace std;

int main(int argc, char *argv[]) {
  string str, copy;
  int shif;
  getline(cin, str);

  copy = str;
  shif = -1;
  while (true) {
    if (str.find(" this ") != string::npos ||
        str.find(" that ") != string::npos ||
        str.find(" the ") != string::npos)
      break;
    else
      for (string::iterator itr = str.begin();
           itr != str.end();
           itr++)
        if ('a' <= *itr && *itr <= 'z') {
          *itr += shif;
        } else if (*itr != '.' && *itr != ' ' &&
                   *itr != '\n') {
          str = copy;
          shif = 1;
          break;
        }
  }


  cout << str << endl;
  return 0;
}

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

C++: #include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;

int main()
{
	char str[81];
	while(fgets(str, 81, stdin) != NULL){
		stringstream sstr(str);
		vector<string> words;

		string tmp;
		while(sstr >> tmp)
			words.push_back(tmp);

		rep(i, 26){
			rep(j, words.size()){
				if(words[j] == "the" || words[j] == "this" || words[j] == "that"){
					rep(k, strlen(str))
						putchar(isalpha(str[k]) ? (str[k]-'a'+i)%26+'a' : str[k]);
					//puts("");
					i = 26;
					break;
				}

				rep(k, words[j].size())
					words[j][k] = (words[j][k]-'a'+1)%26 + 'a';
			}
		}
	}

	return 0;
}

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