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>
using namespace std;

int main(void) {
  string t[3] = {"the", "this", "that"};
  string str;
  
  while(getline(cin, str)) {
    while(1) {
      for(int i=0; i<str.length(); i++) if(str[i] != ' ' && str[i] != '.') str[i] = (str[i]-'a' + 1)%26 + 'a';
      for(int i=0; i<3; i++) if(str.find(t[i])!=string::npos) goto fi;
    }
  fi:
    cout << str << endl;
  }
  return 0;
}

C++: #include <stdio.h>
#include <conio.h>

char* Rest(char *before, char lag);

int main(void)
{
	char before[1000];
	
	scanf("%[^\n]", before);
	
	if (before[0] == 't'){
		printf("%s\n", before);
	}
	else if (before[0] < 't'){
		printf("%s\n", Rest(before, 't' - before[0]));
	}
	else if (before[0] > 't'){
		printf("%s\n", Rest(before, before[0] - 't'));
	}
	
	return (0);
}

char* Rest(char *before, char lag)
{
	int i;
	char ans[1000];
	for (i = 0; before[i] != '\0'; i++){
		
		if (before[i] >= 'a' && before[i] <= 'z' ||
			before[i] >= 'A' && before[i] <= 'Z'){
			
			if (before[i] - lag < 'a'){
				ans[i] = before[i] - lag + 26;
			}
			else if (before[i] - lag > 'z'){
				ans[i] = before[i] - lag - 26;
			}
			else {
				ans[i] = before[i] - lag;
			}
		}
		else {
			ans[i] = before[i];
		}
	}
	ans[i] = '\0';
	
	return (ans);
}

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

int suggest_cipher_num(std::string str)
{
  std::vector<std::string> token;
  int i = 0, j = str.find(" ", 0);
  while (j != std::string::npos) {
    token.push_back(str.substr(i, j - i));
    i = j + 1;
    j = str.find(" ", i);
  }
  token.push_back(str.substr(i, str.length() - i));
  
  for (auto it = token.begin(); it != token.end(); ++it) {
    std::string& tok = *it;
    if (tok.length() == 3) {
      // check if this token is ciphered "the"
      int diff[] = {tok[0] - tok[1], tok[1] - tok[2]};
      for (int i = 0; i < 2; i++) {
        if (diff[i] < 0) diff[i] += 'z' - 'a';
      }
      
      if (diff[0] == 't' - 'h' && diff[1] == 'h' - 'e') {
        return 't' - tok[0];        
      }
    }
    else if (tok.length() == 4) {
      // check if this token is ciphred "this" or "that"
      int diff[] = {tok[0] - tok[1], tok[1] - tok[2], tok[2] - tok[3]};
      if (diff[0] != 't' - 'h' && diff[0] + ('z' - 'a') != 't' - 'h') break;
      if (diff[1] == 'h' - 'i' || diff[1] - ('z' - 'a') == 'h' - 'i') {
        if (diff[2] == 'i' - 's' || diff[2] - ('z' - 'a') == 'i' - 's') {
          return 't' - tok[0];
        }
      }
      else if (diff[1] == 'h' - 'a' && diff[1] + ('z' - 'a') != 'h' - 'a') {
        if (diff[2] == 'a' - 't' && diff[2] - ('z' - 'a') == 'a' - 't') {
          return 't' - tok[0];
        }
      }
    }
  }
}

int main()
{
  std::string line;
  while (std::getline(std::cin, line)) {
    auto key = suggest_cipher_num(line);
    for (const auto& c: line) {
      if (c == ' ' || c == '.') {
        std::cout << c;
      } else if(c + key < 'a') {
        std::cout << static_cast<char>(c + key + 'z');
      } else {
        std::cout << static_cast<char>(c + key);
      }
    }
    std::cout << std::endl;
  }
  return 0;
}

C++: #include<iostream>
#include<ctype>
#include<string>
using namespace std;
bool find(string s){
	return s.find("the",0)!=string::npos
		|| s.find("this",0)!=string::npos
		|| s.find("that",0)!=string::npos;
}
string rotate(string s,int n){
	for(int i=0;i<s.size();i++){
		if(isalpha(s[i]))s[i] = (s[i]-'a'+n)%26+'a';
	}
	return s;
}
int main(){
	string s;
	while(getline(cin,s)){
		for(int i=0;i<26;i++){
			if(find(rotate(s,i))){
				cout<<rotate(s,i)<<endl;
				break;
			}
		}
	}
	return 0;
}

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

using namespace std;

char returnc(char c){
  if('a'<=c && c<='z'){
    if(c=='z')return 'a';
    return ++c;
  }
  return c;
}
int main(void){
  vector<string> ss;
  string s,str;
  getline(cin,s);
  s+= " ";
  for(int i = 0 ; i < s.size() ; i ++){
    if(s[i] == ' '){
      ss.push_back(str);
      str="";
    }else{
      str+=s[i];
    }
  }
  bool ok=true;
  string out[] = {"this","that","the"};
  while(ok){
    for(int i = 0 ; i < ss.size(); i ++){
      //cout<<ss[i]<<endl;
      for(int j = 0 ; j < ss[i].size() ; j ++){
	ss[i][j] = returnc(ss[i][j]);
      }
      for(int j = 0 ; j < 3 ; j ++){
	if(ss[i] == out[j])ok=false;
      }
    }
  }
  for(int i = 0 ; i < ss.size()-1 ; i ++){
    cout<<ss[i]<<" ";
  }
  cout<<ss[ss.size() - 1]<<endl;
}

C++: /*AOJ 0017*/

#include<iostream>
#include<string>

using namespace std;

char shiftCaesar(char tmp){
	if(tmp>='a' && tmp<= 'y'){
		return tmp+1;
	}
	else if(tmp == 'z'){
		return 'a';
	}
	else{
		return tmp;
	}
}

int main(){
	char str[100];
	string tmp;

	while(cin.getline(str,100)){

		for(;;){

			tmp = str;

			if( tmp.find("the") != -1 || tmp.find("this") != -1 || 
				tmp.find("that") != -1){
					break;
			}

			for(int i=0;str[i]!='\0';i++){
				str[i] = shiftCaesar(str[i]);
			}


		}

		cout<<tmp<<endl;

	}
	return 0;
}

C++: #define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

int caesar(string s)
{
	string s0 = "this";
	string s1 = "that";
	string s2 = "the";

	for (int i = 0; i < 26; i++)
	{
		if (s == s0 || s == s1 || s == s2 || s == s0 + "." || s == s1 + "." || s == s2 + ".")
		{
			return i;
		}
		for (int j = 0; j < 4; j++)
		{
			s0.at(j)++;
			if (s0.at(j) > 'z')
			{
				s0.at(j) = 'a';
			}
			s1.at(j)++;
			if (s1.at(j) > 'z')
			{
				s1.at(j) = 'a';
			}
		}
		for (int j = 0; j < 3; j++)
		{
			s2.at(j)++;
			if (s2.at(j) > 'z')
			{
				s2.at(j) = 'a';
			}
		}
	}

	return -1;
}

int main()
{
	string str;
	for (; getline(cin, str);)
	{
		stringstream ss;
		ss << str;

		vector<string> w;
		string s;
		int c = -1;
		for (; ss >> s;)
		{
			w.push_back(s);
			
			if (c == -1)
			{
				c = caesar(s);
			}
		}

		for (int i = 0; i < w.size(); i++)
		{
			if (c != -1)
			{
				for (int j = 0; j < w.at(i).size(); j++)
				{
					if (w.at(i).at(j) != '.')
					{
						char sp = w.at(i).at(j) - c;
						if (sp < 'a')
						{
							int p = 'a' - sp - 1;
							w.at(i).at(j) = 'z' - p;
						}
						else
						{
							w.at(i).at(j) = sp;
						}
					}
				}
			}

			cout << w.at(i) << (i == w.size() - 1 ? "" : " ");
		}

		cout << endl;
	}
}

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

int main() {
  string s;
  while(getline(cin, s)) {
    for (int i=0; i<26; i++) {
      string s2(s);
      for (int j=0; j<s.length(); j++) {
        if (isalpha(s[j]))
          s2[j] = (s[j]-'a'+i) % 26 + 'a';
      }
      if (s2.find("the")!=-1||s2.find("this")!=-1||s2.find("that")!=-1) {
        cout << s2 << endl;
        break;
      }
    }
  }
}