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 <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) {
		if (c != '.') {
			c += sh;
			if (c > 'z') {
				c -= (char)26;
			} else if (c < 'a') {
				c += (char)26;
			}
		}
	});
	if (w.find("the") == string::npos && w.find("this") == string::npos && w.find("that") == string::npos) {
		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;
	}
}

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

using namespace std;

int main()
{
  string stro, str;
  while(getline(cin, stro)){
    for(int i = 1; i < 26; i++){
      str = stro;
      for(int j = 0; j < stro.length(); j++){
	if(str[j] != ' ' && str[j] != '.' && str[j] != '\n')
	  if(str[j] + i > 'z')
	    str[j] += i - 26;
	  else
	    str[j] += i;
      }
	if(str.find("the", 0) != string::npos || str.find("this", 0) != string::npos || str.find("that", 0) != string::npos)
	  cout << str << endl;	
    }
  }
}

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

using namespace std;

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

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

using namespace std;

char data[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char trans[100];
char mozi;
int position=0;
int zoom;
int first_check=0,first_position=0;
int now;
char result;
int flag = 0;

int main(){
	while(flag == 0){
		scanf("%c",&mozi);
		if(first_check == 0)

		for(int i=0;i<26 && first_check == 0;i++){
			if(mozi == data[i]){
				first_position = i;
				zoom = first_position - 19;
				first_check = 1;
				break;
			}
		}




		if(mozi == ' ' || mozi == '.' || mozi == '\n'){
			if(mozi == ' ' || mozi == '.'){
				trans[position] = mozi;
				position++;
			}

			if(mozi == '\n'){
				//trans[position] = '\n';
				cout << trans << endl;
				first_check = 0;
				position = 0;
				memset(trans,'\0',sizeof(trans));
				flag = 1;
			}
		}else{
			for(int i=0;i<26;i++){
				if(data[i] == mozi){
					now = i;
					break;
				}
			}

			trans[position] = data[now - zoom];
			position++;

		}
	}
}

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

using namespace std;
int main(){
	string str1;
	int i, j, n = 0;
	while(getline(cin, str1)){
		bool change = false;
		for(i = 0;i < 28;i++){
			for(j = 0;j < str1.size();j++){
				if(str1[j] != ' ' && str1[j] != '.'){
					if(str1[j] == 'a'){
						str1[j] = 'z';
					}
					else str1[j] -= 1;
				}
			}
			for(j = 0;j+3 < str1.size();j++){
				if(str1[j] == 't' && str1[j+1] == 'h'){
					//if(str1[j+2] == 'e' || (str1[j+2] == 'i' && str1[j+3] == 's') || (str1[j+2] == 'a' && str1[j+3] == 't')){
						n = i + 1;
						change = true;
						break;
					//}
				}
			}
			if(change) break;
		}	
		for(i = 0;i < str1.size();i++){
			cout << str1[i];
		}
		cout << endl;
		
	}


	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
      string s;
      while(getline(cin,s)){
            for(int i=0;i<25;i++){
                  if(s.find("the")!=-1||s.find("this")!=-1||s.find("that")!=-1)break;
                  else for(int j=0;j<s.size();j++)if(s[j]>='a'&&s[j]<='z')s[j]!='z'?s[j]++:s[j]='a';
            }
            cout<<s<<endl;
      }
}

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

string inc(string str, int c)
{
    for (int i = 0; i < str.size(); ++i) {
        if (str[i] < 'a' || 'z' < str[i])
            continue;
        int tmp = (str[i] - 'a' + c)%26;
        str[i] = 'a' + tmp;
    }
    return str;
}

int main(void)
{
    bool flag;
    string str;
    getline(cin, str);

    for (int i = 0; i < 26; ++i) {
        flag = false;
        string tmp;
        stringstream ss;
        ss << str;
        while (!ss.eof()) {
            ss >> tmp;
            tmp = inc(tmp, i);
            flag += tmp == "this";
            flag += tmp == "that";
            flag += tmp == "the";
            if (flag)
                break;
        }
        if (flag) {
            cout << inc(str, i) << endl;
            break;
        }
    }
    return 0;
}

C++: #include<stdio.h>
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
int main(){
	
	char s[100];
	while(cin.getline(s,100)){
		for(int i=0;s[i+1]!='\0';i++){
			if((s[i]-s[i+1]=='t'-'h')&&(((s[i+1]-s[i+2]=='h'-'i')&&(s[i+2]-s[i+3]=='i'-'s'))||(s[i+1]-s[i+2]=='h'-'e')||((s[i+1]-s[i+2]=='h'-'a')&&(s[i+2]-s[i+3]=='a'-'t')))){
				for(int j=0;s[j]!='\0';j++){
					if((s[j]!=' ')&&(s[j]!='.')){
						putchar(s[j]+'t'-s[i]);
					}else{
						putchar(s[j]);
					}
				}cout<<endl;
			}
		}
	}
}

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

using namespace std;

int main() { 
  string input_str;

  while (getline(cin, input_str)) {
    for (int shift = 1; shift < 26; shift++) {
      for (int str_i = 0; str_i < input_str.size(); str_i++) {
        if (input_str[str_i] >= 'a' && input_str[str_i] < 'z')
          input_str[str_i] ++;
        else if (input_str[str_i] == 'z')
          input_str[str_i] = 'a';
      }
      if (input_str.find("the") != string::npos || input_str.find("this") != string::npos || input_str.find("that") != string::npos)
        break;
    }
    cout << input_str << endl;
  }

  return 0;
}