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 <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];
        }
      }
    }
  }
  return 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 <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

int main() {
  string bstr;

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

  return 0;
}

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

using namespace std;

int main(int argc, char **argv)
{
	char a[82], t;
	int n, p;
	
	while(gets(a)!=NULL){
		n = strlen(a);
		for(int i = 0; i < n; i++){
			p = (int)(a[i++]-'t');
			if(a[i] == ' '){
				continue;
			}
			t = a[i++]-p;
			if(t < 'a'){
				t += 25;
			} else if(t > 'z'){
				t -= 25;
			}
			if(a[i] == ' '){
				continue;
			}
			if(t == 'h'){
				t = a[i++]-p;
				if(t < 'a'){
					t += 25;
				} else if(t > 'z'){
					t -= 25;
				}
				if(t == 'e' && a[i] == ' '){
					break;
				} else if(t == 'i'){
					t = a[i++]-p;
					if(t < 'a'){
						t += 25;
					} else if(t > 'z'){
						t -= 25;
					}
					if(t == 's' && a[i] == ' '){
						break;
					}
				} else if(t == 'a'){
					t = a[i++]-p;
					if(t < 'a'){
						t += 25;
					} else if(t > 'z'){
						t -= 25;
					}
					if(t == 't' && a[i] == ' '){
						break;
					}
				}
			}
		}
		
		for(int i = 0; i < n; i++){
			if(a[i] == ' ' || a[i] == '.' || a[i] == ','){
				printf("%c",a[i]);
			} else {
				t = a[i]-p;
				if(t < 'a'){
					t += 25;
				} else if(t > 'z'){
					t -= 25;
				}
				printf("%c",t);
			}
		}
		cout << endl;
	}
	
	return 0;
}

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

using namespace std;

int main(){

	char buf[81],result[81];
	bool FLG;

	while(fgets(buf,81,stdin)!=0){
		FLG = false;
		for(int i=0;i<=25;i++){ //?????????????????°
			for(int k=0;buf[k]!='\0';k++){
				if(buf[k] >= 97 && buf[k] <= 122){
					if(buf[k]+i<=122){
						result[k]=buf[k]+i;
					}else{
						result[k]=97+(buf[k]+i-123);
					}
				}else{
					result[k]=buf[k];
				}
				result[k+1]='\0';
			}
			for(int k=0;result[k]!='\0';k++){
				// the this that ????????????????????????????????????
				for(int p=4;result[p]!='\0';p++){
					if(result[p]==' ' && result[p-1] == 'e' && result[p-2] == 'h' && result[p-3] == 't' && result[p-4] == ' '){
						FLG = true;
						break;
					}
				}
				if(FLG)break;
				for(int p=5;result[p]!='\0';p++){
					if(result[p]==' ' && result[p-1] == 's' && result[p-2] == 'i' && result[p-3] == 'h' && result[p-4] == 't' && result[p-5] == ' '){
						FLG = true;
						break;
					}
				}
				if(FLG)break;
				for(int p=5;result[p]!='\0';p++){
					if(result[p]==' ' && result[p-1] == 't' && result[p-2] == 'a' && result[p-3] == 'h' && result[p-4] == 't' && result[p-5] == ' '){
						FLG = true;
						break;
					}
				}
				if(FLG)break;
			}
			if(FLG)break;
		}
		printf("%s\n",result);

	}

    return 0;
}