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 <string>

using namespace std;

void forward(string& data)
{
	for(auto& c : data)
	{
		if(c < 'a' || 'z' < c)
			continue;

		c++;
		if('z' < c)
			c -= 26;
	}
}

bool test(const string& data)
{
	if(data.find("the") != string::npos)
		return true;
	if(data.find("this") != string::npos)
		return true;
	if(data.find("that") != string::npos)
		return true;

	return false;
}

int main()
{
	while(!cin.eof())
	{
		char buffer[1024];
		cin.getline(buffer, 1024);
		string line(buffer);

		for(int i = 0; i < 26; i++)
		{
			if(test(line))
				break;
			forward(line);
		}

		cout << line << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<iterator>
#include<sstream>
#include<vector>
#include<cstdio>
const int A_SIZE=26;
using namespace std;
bool is_the(string str){
  if(str.size()!=3){return false;}
  if((str[0]-str[1]+A_SIZE)%A_SIZE!=('t'-'h'+A_SIZE)%A_SIZE){return false;}
  if((str[1]-str[2]+A_SIZE)%A_SIZE!=('h'-'e'+A_SIZE)%A_SIZE){return false;}
  return true;
}
bool is_that(string str){
  if(str.size()!=4){return false;}
  if((str[0]-str[1]+A_SIZE)%A_SIZE!=('t'-'h'+A_SIZE)%A_SIZE){return false;}
  if((str[1]-str[2]+A_SIZE)%A_SIZE!=('h'-'a'+A_SIZE)%A_SIZE){return false;}
  if((str[2]-str[3]+A_SIZE)%A_SIZE!=('a'-'t'+A_SIZE)%A_SIZE){return false;}
  return true;
}
bool is_this(string str){
  if(str.size()!=4){return false;}
  if((str[0]-str[1]+A_SIZE)%A_SIZE!=('t'-'h'+A_SIZE)%A_SIZE){return false;}
  if((str[1]-str[2]+A_SIZE)%A_SIZE!=('h'-'i'+A_SIZE)%A_SIZE){return false;}
  if((str[2]-str[3]+A_SIZE)%A_SIZE!=('i'-'s'+A_SIZE)%A_SIZE){return false;}
  return true;
}
bool is_clue(string str){
  return is_the(str) || is_that(str) || is_this(str);
}

int main(){
  char str[80];
  while(cin.getline(str,80)!=0){
    istringstream iss{str};
    vector<string> strs;
    copy(istream_iterator<string>(iss), istream_iterator<string>(), back_inserter(strs));
    int offset=0;
    for(string a : strs){
      if(is_clue(a)){
	offset = 't'-a[0];
	break;
      }
    }
    for(char c : str){
      if(c=='\0'){putchar('\n');break;}
      if(c<'a'||c>'z'){putchar(c);}
      else if(c+offset>'z'){putchar(c+offset-A_SIZE);}
      else if(c+offset<'a'){putchar(c+offset+A_SIZE);}
      else{putchar(c+offset);}
    }
  }
}

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=0; 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++: #include<iostream>
#include<string>
using namespace std;

string change(string s,int num){

	for(int i=0;i<s.size();i++){
		if(s[i]+num>'z')s[i]=(s[i]+num-'z'+'a'-1);
		else s[i]=(s[i]+num);
	}
	return s;
}
char change(char c,int num){
	char re;
	if(c+num>'z')re=c+num-'z'+'a'-1;
	else re=c+num;
	return re;
}

int solve(string s){
	string now;
	
	for(int i=0;i<s.size();i++){
		if(s[i]>='a' && s[i]<='z')now+=s[i];
		else {
			for(int j=0;j<=26;j++){
				string tmp=change(now,j);
				if(tmp=="the" || tmp=="this" || tmp=="that"){
					return j;
				}
			}
			now.clear();
		}
	}
}

string ans(string s){
	int n=solve(s);
	string ans;
	for(int i=0;i<s.size();i++){
		if(s[i]>='a' && s[i]<='z')ans+=change(s[i],n);
		else ans+=s[i];
	}
	return ans;
}

int main(){
	string str;
	
	while(getline(cin,str)){
		cout<<ans(str)<<endl;
	}
}

C++: #include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>=n;i--)
#define INF 999999999
#define INF_M 2147483647
#define pb(a) push_back(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef vector<pii> VP;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main() {
    string s;
    getline(cin,s);
    string t(s.length(),' ');
    rep(j,0,26) {
    	rep(i,0,s.length()) {
			if('a' <= s[i] && s[i] <= 'z') t[i] = (s[i] + j > 'z') ? (s[i] + j - 26) : s[i] + j;
			else t[i] = s[i];
    	}
    	if(t.find("this") != string::npos) break;
    	else if(t.find("the") != string::npos) break;
    	else if(t.find("that") != string::npos) break;
    }
    cout << t << endl;
    return 0;
}

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

bool valid(string line){
  string t[3] = {"the", "this", "that"};
  for ( int i = 0; i < 3; i++ ){
    if ( line.find(t[i]) != string::npos ) return true;
  }
  return false;
}

void move(string &line){
  for ( int i = 0; i < line.size(); i++ ){
    if ( line[i] == 'a' ) line[i] = 'z';
    else if ( 'b' <= line[i] && line[i] <= 'z' ){
      line[i] = (char)(line[i]-1);
    }
  }
}
main(){
  string line;
  while(1){
    getline(cin, line);
    if ( cin.eof() ) break;
    while(1){
      if ( valid(line) ) {
	cout << line << endl;
	break;
      }
      move(line);
    }
  }
}

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

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)

#define EPS 1e-6

using namespace std;

bool f(string a){

	string::size_type p=a.find("the");
	string::size_type q=a.find("this");
	string::size_type r=a.find("that");
	if(p!=string::npos || q!=string::npos || r!=string::npos)
	return true;
	else return false;

	}

int main(){

   string s,s1;

   while(true){

	getline(cin,s);
	if(cin.fail()) break;

	int n=s.size();

	REP(k,1,25){
	s1=s;
	rep(i,n){
	if('a'<=s1[i] && s1[i]<='a'-1+k) s1[i]+=26-k;
	if('a'+k<=s1[i] && s1[i]<='z') s1[i]+=-k;
	}

	if(f(s1)){ cout << s1 << endl; break; }

	}


	}


    return 0;
}