Go: package main

import (
	"bufio"
	"os"
	"strings"
	"fmt"
)

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 len(infos) == 0 {
			break
		}
		// 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 <cctype>

using namespace std;

int main() { 
  string input_str;

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

  return 0;
}

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

using namespace std;

int main(){
	string ciph;

	while(getline(cin,ciph)){
		int len=ciph.length();
		bool match=false;
		for(int i=0;i<26;i++){
			for(int j=0;j<len;j++){
				if(islower(ciph[j])){
					ciph[j]++;
					if(ciph[j]>'z')	ciph[j]-=26;
				}
			}

			for(int j=0;j<len-2;j++){
				if(ciph.substr(j,3)=="the"
				&& !islower(ciph[j+3])
				&& (j==0 || !islower(ciph[j-1]))){
					match=true;
				}
			}
			if(match)	break;

			for(int j=0;j<len-3;j++){
				if(ciph.substr(j,4)=="this"
				&& !islower(ciph[j+4])
				&& (j==0 || !islower(ciph[j-1]))){
					match=true;
				}
			}
			if(match)	break;

			for(int j=0;j<len-3;j++){
				if(ciph.substr(j,4)=="that"
				&& !islower(ciph[j+4])
				&& (j==0 || !islower(ciph[j-1]))){
					match=true;
				}
			}
			if(match)	break;
		}
		cout<<ciph<<endl;
	}

	return 0;
}

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

using namespace std;
 int key;

int dist(char s1,char s2){
 
  if(s1==s2){
    return 0;
  }else if(s1<s2){

    return s2-s1;
  }else{
    return 'z'-s1+s2-'a'+1;
  }
}

bool checkThe(char s[]){
  if(strlen(s)!=3){
    return false;
  }else{
    if(dist('t',s[0])==dist('h',s[1]) && dist('h',s[1])==dist('e',s[2])){
      key=dist('t',s[0]);
      return true;
    }
  }
  return false;
}
bool checkThis(char s[]){
  if(strlen(s)!=4){
    return false;
  }else{
    if(dist('t',s[0])==dist('h',s[1]) && dist('h',s[1])==dist('i',s[2]) && dist('i',s[2])==dist('s',s[3])){
      key=dist('t',s[0]);
      return true;
    }
  }
  return false;
}
bool checkThat(char s[]){
  if(strlen(s)!=4){
    return false;
  }else{
    if(dist('t',s[0])==dist('h',s[1]) && dist('h',s[1])==dist('a',s[2]) && dist('a',s[2])==dist('t',s[3])){
      key=dist('t',s[0]);
      return true;
    }
  }
  return false;

}
int main(){
 
  char str[100];
  char temp[100];
 
  char *tok;
  bool f=false;
  while(fgets(str,sizeof(str),stdin)!=NULL){
    key=0;
    for(int i=0;i<strlen(str);i++)
      temp[i]=str[i];
    temp[strlen(str)]='\0';

    str[strlen(str)]='\0';
    str[strlen(str)-1]='\0';
    tok=strtok(str," ");
 
    if(strlen(tok)==3){
      if(checkThe(tok)==true){
	f=true;
      }
    }else if(strlen(tok)==4){
      if(checkThat(tok)==true){
	f=true;
      }else if(checkThis(tok)==true){
	f=true;
      }
    }
    while(f==false && tok!=NULL){
      tok=strtok(NULL," ");
      if(tok!=NULL){
	if(strlen(tok)==3){
	  if(checkThe(tok)==true){
	    f=true;
	  }
	}else if(strlen(tok)==4){
	  if(checkThat(tok)==true){
	    f=true;
	  }else if(checkThis(tok)==true){
	    f=true;
	  }
	}
      }
    }
 
   
    for(int i=0;i<strlen(temp);i++){
      if('a'<=temp[i] && temp[i]<='z'){
	if(temp[i]-key>'z'){
	  printf("%c",(temp[i]-key));
	}else if(temp[i]-key<'a'){
	  printf("%c",(temp[i]-key)+26);
	}else{
	  printf("%c",(temp[i]-key));
	}
      }else{
	printf("%c",temp[i]);
      }
    }

  }

  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<25; 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 <iostream>
#include <string>
using namespace std;
int main(){
	string a;
	while(getline(cin,a)){
	int k=0;
	int check=0;
	while(true){
		if(k>52)
			break;
		for(int j=0;j<a.size();j++){
			if(isalpha(a[j])!=0)
				if(a[j]=='z')
					a[j]='a';
				else
				    a[j]++;
		}
		for(int i=0;i<a.size()-2;i++){
			if(a[i]=='t'&&a[i+1]=='h'&&a[i+2]=='e'&&check==0){
				for(int i=0;i<a.size();i++)
		            cout<<a[i];
	            cout<<endl;
				check=1;
			}
			if(a[i]=='t'&&a[i+1]=='h'&&a[i+2]=='i'&&a[i+3]=='s'&&check==0){
				for(int i=0;i<a.size();i++)
		            cout<<a[i];
	            cout<<endl;
				check=1;
			}
			if(a[i]=='t'&&a[i+1]=='h'&&a[i+2]=='a'&&a[i+3]=='t'&&check==0){
				for(int i=0;i<a.size();i++)
		            cout<<a[i];
	            cout<<endl;
				check=1;
			}
		}
		k++;
	}
	}
	return 0;
}

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

using namespace std;

string rot(string);

int main(void){
	string str;

	while(getline(cin,str)){
		while(str.find("the")==string::npos && str.find("that")==string::npos && str.find("this")==string::npos)
			str=rot(str);
		cout << str << endl;
	}
}

string rot(string str){
	for(int i=0;i<str.size();i++)
		if(str[i]>='a'&&str[i]<='z')
			str[i]=str[i]=='z'?'a':str[i]+1;

	return str;
}

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

int main(){
	char input[81],str[50][81];
	const char cmp[3][5]={"that","this","the"};
	int pos=0,last_pos=0,i,j,k,diff,n;
	bool flag;

	while(fgets(input,81,stdin)!=NULL){;
		last_pos=0;
		pos=0;
		for(i=0;input[i]!='\0';i++){
			if(input[i]==' ' || input[i]=='.' || input[i]=='\n'){
				for(j=last_pos;j<i;j++){
					str[pos][j-last_pos]=input[j];
				}
				str[pos][j-last_pos]='\0';
				pos++;
				last_pos=i+1;
			}
		}

		n=0;
		flag=false;
		while(++n){
			for(i=0;i<pos;i++){
				for(j=0;str[i][j]!='\0';j++){
					str[i][j]+=1;
					if('a'>str[i][j]){
						str[i][j]+='z'-'a'+1;
					}else if('z'<str[i][j]){
						str[i][j]+='a'-'z'-1;
					}
				}
			}

			for(i=0;i<pos;i++){
				for(j=0;j<3;j++){
					if(strcmp(str[i],cmp[j])==0){
						flag=true;
                        j=3;i=pos;
					}
				}
			}
			if(flag) break;
		}

		int temp;
		for(i=0;input[i]!='\n';i++){
			if(input[i]!='.' && input[i]!=' '){
				temp=input[i]+n;
				if('a'>temp){
					input[i]=temp+'z'-'a'+1;
				}else if('z'<temp){
					input[i]=temp+'a'-'z'-1;
				}
			}
		}
		printf("%s",input);
	}

	return 0;
}