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>
using namespace std;
int main()
{
	int i, j;
	string s, res, tmp;
	while (!cin.eof())
	{
		getline(cin, s);
		res = tmp = s;
		for (i = 0; i < 27; i++)
		{
			res = tmp;
			for (j = 0; j < (int)s.length(); j++)
			{
				if (s[j] != ' ' && s[j] != '.')
				{
					if (s[j] + i > 'z')
						res[j] = 'a' + s[j] + i - 'z' - 1;
					else
						res[j] = s[j] + i;
				}
				else
				{
					res[j] = s[j];
				}
			}
			if (res.find("the") != string::npos || res.find("this") != string::npos || res.find("that") != string::npos)
				break;
		}
		cout << res << endl;
	}
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string str;
	getline(cin, str);
	for (int i = 0; i < str.size(); i++) {
		if (str[i] >= 'E' && str[i] <= 'Z') {
			str[i] += 'A' - 'E';
		}
		else if (str[i] >= 'e' && str[i] <= 'z') {
			str[i] += 'a' - 'e';
		}
		else if (str[i] >= 'A' && str[i] < 'E') {
			str[i] -= 'A' - 'W';
		}
		else if (str[i] >= 'a'&&str[i] < 'e') {
			str[i] -= 'a';
			str[i] += 'w';
		}
		cout << str[i];
	}
	cout << endl;

	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

char convNext(char ch) {
	if('a' <= ch && ch <= 'y') return ch+1;
	if(ch=='z')return 'a';
	return ch;
}
int main() {
	char str[90];
	while(true) {
		if(!fgets(str, 90, stdin))break;
		for(int i = 0; i < 26; i++) {
			if(strstr(str,"this") || strstr(str,"that") || strstr(str,"the"))break;
			for(int j = 0; str[j]; j++) {
				str[j]=convNext(str[j]);
			}
		}
		fputs(str, stdout);
	}
	return 0;
}

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

C++: #include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <map>
#define INF 100000000

using namespace std;
typedef long long ll;

string change(string s){
    int len=s.size();
    for(int i=0;i<len;i++){
        if('b'<=s[i] && s[i]<='z')s[i]--;
        if(s[i]=='a')s[i]='z';
    }
    return s;
}

bool check(string s){
    int len=s.size();
    string tan="";
    for(int i=0;i<len;i++){
        if('a'<=s[i] && s[i]<='z'){
            tan+=s[i];
        }
        else{
            if(tan=="the" || tan=="this" || tan=="that" )return true;
            tan="";
        }
    }
    return false;
}


int main(){
    string s;
    getline(cin,s);
    while(1){
        s=change(s);
        if(check(s)){cout<<s<<endl;return 0;}
    }
    
    return 0;
}

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

int main() {
	std::string str;
	std::getline(std::cin, str);
	
	std::string ans;
	for (auto c : str) {
		char elem = c - 4;
		if (c >= 'a' && c <= 'z') {
			if (elem < 'a') {
				elem = 'z' - 'a' + elem + 1;
			}
			ans.push_back(elem);
		} else {
			ans.push_back(c);
		}
	}
	
	std::cout << ans << std::endl;
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    int in;
    char S[1000];
    
    S[0]=' ';
    
    for(int i=1;;i++){
        
        in = getchar();
        
        if(in==EOF){
            S[i]='\0';
            break;
        }else{
            S[i]=(char)in;
        }
    }
    
    for(int k=0;;k++){
        
        bool f = false;
        
        for(int i=1;S[i]!='\0';i++){
            if('a'<=S[i] && S[i]<='y'){
                S[i]++;
            }else if(S[i]=='z'){
                S[i]='a';
            }
            
            if(i>=3 && (S[i+1]<'a' || 'z'<S[i+1]) && (S[i-3]<'a' || 'z'<S[i-3])){
                if(S[i-2]=='t' && S[i-1]=='h' && S[i]=='e')
                    f=true;
            }
            if(i>=4 && (S[i+1]<'a' || 'z'<S[i+1]) && (S[i-4]<'a' || 'z'<S[i-4])){
                if(S[i-3]=='t' && S[i-2]=='h')
                    if((S[i-1]=='i' && S[i-0]=='s') || (S[i-1]=='a' && S[i-0]=='t'))
                        f=true;
            }
        }
        
        if(f) break;
    }
    
    for(int i=1;S[i]!='\0';i++)
        printf("%c",S[i]);
    
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(i=0;i<n;++i)
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second

int main(int argc, char const *argv[]) {
  string s;
  while(getline(cin,s)){
    //cout << s << endl;
    string a="abcdefghijklmnopqrstuvwxyz";
    a += a;

    string t="";
    bool end=false;
    int i;
    for(int w=1; w<=25; ++w){
      printf("w=%d\n", w);
      t="";
      int p=0;
      rep(i,s.size()){
        if('a'<=s[i] && s[i]<='z'){
          t+=a[s[i]-'a'+w];
        }
        else{
          t+=s[i];
          string tmp=t.substr(p,i-p);
          //cout << tmp << endl;

          if(tmp=="this" || tmp=="the" || tmp =="that") end=true;

          p=i+1;
        }
      }

      if(end) break;
    }

    std::cout << t << std::endl;
  }
  return 0;
}

C++: import Control.Applicative
import Data.Char (readLitChar)
import Data.List
import System.IO

main = do
  eof <- isEOF
  if eof then return ()
         else do
            dataset <- getLine
            mapM_ putStrLn $ decodeCaesar (escape dataset)
            main

shiftChar :: Int -> Char -> Char
shiftChar n c
    | c == '.' = '.'
    | c == ' ' = ' '
    | c == '\n' = '\n'
    | otherwise = toEnum.(+97).(`mod` 26).(+ n).(subtract 97).fromEnum $ c

shiftString :: Int -> String -> String
shiftString n = map (shiftChar n)

decodeCaesar :: String -> [String]
decodeCaesar str = filter (\s -> ("this" `isInfixOf` s) || ("that" `isInfixOf` s) || ("the" `isInfixOf` s))
    $ map shiftString [1..25] <*> [str]

escape :: String -> String
escape [] = []
escape str = x : escape rest
  where [(x,rest)] = readLitChar str