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> // C++の入出力
#include <stdio.h> // C の入出力
#include <algorithm> // sort などのアルゴリズム
#include <string.h> // C の文字列用
#include <ctype.h> // C の文字種用
#include <string> // C++の文字列
#include <math.h>
using namespace std;
int main(void){
    string in;
    string hyou="abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
    string kkk=" .",sen="th",sen1="eisat";
    while(getline(cin,in)){
        for(int s=1;s<=26;s++){
            string out="";
            for(int i=0;i<in.length();i++){
                if(in[i]==kkk[0]||in[i]==kkk[1]){
                    out+=in[i];
                }
                for(int k=0;k<26;k++){
                    if(in[i]==hyou[k]){
                        out+=hyou[k+s];
                        break;
                    }
                }
            }
            bool sw=0;
            for(int i=0;i<out.length();i++){
                if(out[i]==sen[0]&&out[i+1]==sen[1]){
                    if(out[i+2]==sen1[0]){
                        sw=1;
                        cout<<out<<endl;
                        break;
                    }else if(out[i+2]==sen1[1]&&out[i+3]==sen1[2]){
                        sw=1;
                        cout<<out<<endl;
                        break;
                    }else if(out[i+2]==sen1[3]&&out[i+3]==sen1[4]){
                        sw=1;
                        cout<<out<<endl;
                        break;
                    }
                }
            }
            if(sw==1)break;
        }
    }
    return 0;
}

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

int main(){
	string str[1000];
	int k = 0;
	int zure[1000];
	bool flag[1000] = {false};
	while(getline(cin, str[k])){
		for(int j = 0; j < 26; j++){
			for(int i = 0; i < str[k].size()-2; i++){
				if(str[k][i] == 'a'+('t'+j-'a')%26 && str[k][i+1] == 'a'+('h'+j-'a')%26 && str[k][i+2] == 'a'+('e'+j-'a')%26){
					zure[k] = j;
					flag[k] = true;
					break;
				}
			}
			if(flag[k] == true){
				k++;
				break;
			}
			for(int i = 0; i < str[k].size()-3; i++){
				if(str[k][i] == 'a'+('t'+j-'a')%26 && str[k][i+1] == 'a'+('h'+j-'a')%26 && str[k][i+2] == 'a'+('i'+j-'a')%26 && str[k][i+3] == 'a'+('s'+j-'a')%26){
					zure[k] = j;
					flag[k] = true;
					break;
				}
			}
			if(flag[k] == true){
				k++;
				break;
			}
			for(int i = 0; i < str[k].size()-3; i++){
				if(str[k][i] == 'a'+('t'+j-'a')%26 && str[k][i+1] == 'a'+('h'+j-'a')%26 && str[k][i+2] == 'a'+('a'+j-'a')%26 && str[k][i+3] == 'a'+('t'+j-'a')%26){
					zure[k] = j;
					flag[k] = true;
					break;
				}
			}
			if(flag[k] == true){
				k++;
				break;
			}
		}
	}
	for(int j = 0; j < k; j++){
		for(int i = 0; i < str[j].size(); i++){
			if(str[j][i] >= 'a' && str[j][i] <= 'z'){
				str[j][i] = str[j][i]-zure[j];
				if(str[j][i] < 'a'){
					str[j][i] = str[j][i]+26;
				}
			}
		}
		cout << str[j] << endl;
	}
}

C++: #include <cmath>
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <regex>

using namespace std;

string decode(string inp,int n){
    for(int i=0;i<inp.length();i++){
        if('a'<=inp[i]&&inp[i]<='z'){
            if(inp[i]-n<'a'){
                inp[i]='z'-(n-(inp[i]-'a')-1);

            }else{
                inp[i]=inp[i]-n;
            }
        }
    }
    return inp;
}
int main(){
    string input,decoded;
    regex pattern("(the)|(this)|(that)");
        for(int i=0;i<26;i++){
            decoded=decode(input,i);
            if(regex_search(decoded.begin(),decoded.end(),pattern)){
                break;
            }
        }
        cout << decoded << endl;
    return 0;
}

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

using namespace std;

int main(){
	string s;
	while(getline(cin,s)){
		while(1){
			for(int j=0;j<s.size();j++){
				if(s[j]>=97&&s[j]<=122){
					s[j]+=1;
					if(s[j]==123)
					s[j]=97;
				}
			}
			if(s.find("the")!=string::npos)
			break;
			if(s.find("this")!=string::npos)
			break;
			if(s.find("that")!=string::npos)
			break;
		}
			printf("%s\n",s.c_str());
	}
}

C++: #include <stdio.h>
int check(int a,int b,int c,int d)
{
    //printf("[%d][%d][%d][%d]\n",a,b,c,d);
    if(a != 14)return 0;
    else if(b == 23 && c == 0)return 1;
    else if(b == 1 && c == 10 && d == 0)return 1;
    else if(b == 19 && c == 19 && d == 0)return 1;
    else return 0;
}

int main()
{
    int longth,mem;
    while(1)
    {
        char str[90] = {0};
        int mem1[90] = {0},mem2[90] = {0};
        if(scanf("%c",&str[0]) == -1)return 0;
        if(str[0] >= 'a' && 'z' >= str[0])mem1[0] = str[0] - 'a' + 1;
        for(int i = 1; i < 80; i++)
        {
            if(scanf("%c",&str[i]) == -1)break;
            longth = i;
            if(str[i] >= 'a' && 'z' >= str[i])mem1[i] = str[i] - 'a' + 1;
        }
        for(int i = 0; i < longth; i++)
        {
            if(mem1[i] == 0);
            else if(mem1[i + 1] != 0)
            {
                if(mem1[i] <= mem1[i + 1])mem2[i] = mem1[i + 1] - mem1[i];
                else mem2[i] = 26 - mem1[i] + mem1[i + 1];
            }
        }
        /*for(int i = 0; i < longth; i++)
        {
            printf("[%d]",mem2[i]);
        }
        printf("\n");*/
        for(int i = 0; i < longth; i++)
        {
            if(mem2[i] == 0);
            else if(i == 0)if(check(mem2[i],mem2[i + 1],mem2[i + 2],mem2[i + 3]))/*printf("%d\n",i);*/if(mem1[i] <= 20)mem = 20 - mem1[i];else mem = 26 - mem1[i] + 20;
            else if(mem2[i - 1] != 0)if(check(mem2[i],mem2[i + 1],mem2[i + 2],mem2[i + 3]))/*printf("%d\n",i);*/if(mem1[i] <= 20)mem = 19 - mem1[i];else mem = 26 - mem1[i] + 20;
        }
        //printf("{%d}\n",mem);
        for(int i = 0; i < longth; i++)
        {
            if(str[i] >= 'a' && 'z' >= str[i])printf("%c",(str[i] - 'a' + mem) % 26 + 'a');
            else printf("%c",str[i]);
        }
        printf("\n");
    }
}

//14 23 0
//14 1 10 0
//14 19 19 0