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<map>
#include<string>
using namespace std;

typedef pair<string, string> P;

P next_word(string sentence) {
  if (sentence.empty()) return make_pair(string(""), string(""));
  if (sentence[0] == ' ' || sentence[0] == '.') {
    return make_pair("", sentence.substr(1));
  } else {
    P recur = next_word(sentence.substr(1));
    return make_pair(sentence[0] + recur.first, recur.second);
  }
}

bool acceptable(string sentence) {
  P p = next_word(sentence);

  while (! p.first.empty() ) {
    if (p.first == "this" || p.first == "the" || p.first == "that")
      return true;

    p = next_word(p.second);
  }
  return false;
}

char slip(char c) {
  if (c < 'a' || 'z' < c) return c;
  
  string alphabet = "abcdefghijklmnopqrstuvwxyza";
  int index = (int)(c - 'a');
  return alphabet[index + 1];
}

char slip(char c, int n) {
  for (int i = 0; i < n; i++)
    c = slip(c);

  return c;
}

string slip(string code, int n) {
  string val;
  for (int i = 0, len = code.length(); i < len; i++)
    val += slip(code[i], n);

  return val;
}

string decode(string code) {
  for (int i = 1; i < 27; i++) {
    string sentence = slip(code, i);
    if (acceptable(sentence))
      return sentence;
  }

  return "";
}

int main() {
  string code;
  while ( getline(cin, code) )
    cout << decode(code) << endl;
}

C++: #include <bits/stdc++.h>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

string key[3]={"the","this","that"};

string s,s2;

int main(){
	while(getline(cin,s)){
		bool flg=false;
		REP(c,'z'-'a'+1){
			s2=s;
			REP(i,s2.length()){
				if (s2[i]!=' ' && s2[i]!='.'){
					if ((int)s2[i]+c>'z'){
						s2[i]+='a'-'z'-1;
					}
					s2[i]+=c;
				}
			}
			REP(i,3){
				if (s2.find(key[i])!=string::npos){
					cout<<s2<<endl;
					flg=true;
					break;
				}
			}
			if (flg) break;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

struct inc{
  void operator() (char &c){
    if(isalpha(c)){
      if(islower(c))
	c = (((c - 'a') + 1) % ('z'-'a'+1)) + 'a';
      else
	c = (((c - 'A') + 1) % ('Z'-'A'+1)) + 'A';
    }
  }
};

int main(){
  string str;
  while(getline(cin, str)){
    bool f = true;
    while(f){
      for_each(str.begin(), str.end(), inc());
      stringstream ss(str);
      string tmp;
      while(ss>>tmp)
	if(tmp == "the" || tmp == "this" || tmp == "that" ||
	   tmp == "THE" || tmp == "THIS" || tmp == "THAT"){
	  cout << str << endl;
	  f = false;
	  break;
      }
    }
  }
  return 0;
}

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

int is_contain_keywords(string str,vector<string>& keywords) {
  int cnt = 0;
  vector<string>::iterator key_itr = keywords.begin();
  while(key_itr != keywords.end()) {
    if(str.find(*key_itr) != string::npos) {
      cnt++;
    }
    key_itr++;
  }
  return cnt;
}

string decode(string cipher) {
  vector<string> keywords;
  keywords.push_back("the");
  keywords.push_back("this");
  keywords.push_back("that");

  int remind_shift = -1;
  int max_cnt = 0;
  int str_len = cipher.length();
  for(int shift = 0;shift < 'z' - 'a';shift++) {
    string str = cipher;
    for(int i=0;i<str_len;i++) {
      if('a' < cipher[i] && cipher[i] < 'z') {
        str[i] = (cipher[i] - 'a' + shift) % ('z' - 'a') + 'a';
      }
    }
    if(is_contain_keywords(str,keywords) > max_cnt) {
      max_cnt = is_contain_keywords(str,keywords);
      remind_shift = shift;
    }
  }
  string ans = cipher;
  for(int i=0;i<str_len;i++) {
    if('a' < cipher[i] && cipher[i] < 'z') {
      ans[i] = (cipher[i] - 'a' + remind_shift) % ('z' - 'a') + 'a';
    }
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  string cipher;
  getline(cin,cipher);
  cout << decode(cipher) << endl;
}

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

const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main()
{
  string s;
  while (getline(cin, s)) {

    for (int i = 0; i < 26; ++i) {
      for (unsigned int j = 0; j < s.size(); ++j) {
	if (isalpha(s[j]))
	  s[j] = alpha[(s[j]-'a'+1)%alpha.size()];
      }
      if (s.find("the", 0) != string::npos ||
	  s.find("this", 0) != string::npos ||
	  s.find("that", 0) != string::npos)
	break;
    }

    cout << s << endl;

  }
  return 0;
}

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

int main(){
	string s, strCopy;
	while (getline(cin, s)) {
		for(int j=0 ; j<26 ; j++){
			for(int i=0 ; i<s.size() ; i++){
				if(s[i]>='a' && s[i]<='z'){
					s[i] = (s[i]=='z')? 'a' : s[i] + 1;
				}
			}
			if( s.find( "the" ) != string::npos || s.find( "this" ) != string::npos || s.find( "that" ) != string::npos){
				cout << s << 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(cin.getline(a, 81, '\n')){
		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;
}