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 <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <array>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>
#include <memory.h>
#include <map>
#include <math.h>
#include <utility>
#include <set>

#pragma warning(disable:4996)
using namespace std;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
typedef long long Int;
const double PI = 3.141592653589793238;
const Int INF = 999999999999;
typedef pair<int, int> P;


int main()
{
	string a;

	while (getline(cin, a), cin){
		vector<string> aa;

		auto left = a.begin();

		while (true){
			auto right = left;
			while (right != a.end() && *right != ' ')++right;

			aa.emplace_back(left, right);
			if (right == a.end())
				break;

			left = right + 1;
		}


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

		vector<string> nn;
		vector<string> kk;
		for (auto x : aa){
			auto n = x.length();
			if (n == 3){
				kk.push_back(x);
			}
			if (n == 4){
				nn.push_back(x);
			}
		}

		for (auto x : kk){
			auto n1 = x[0] - c[2][0];
			bool f(true);

			for (int i = 1; i < 3; ++i){
				if (n1 != x[i] - c[2][i])
					f = false;
			}

			if (f){
				int i(0);
				for (auto x : aa){
					for (auto y : x){

						if ('a' > y || 'z' < y){
							std::cout << y;
							continue;
						}

						int q = y - 'a';
						if (q - n1 < 0){
							q = 26 - n1;
						}
						else
							q -= n1;

						std::cout << (char)(q + 'a');
					}
					if (i < aa.size() - 1)
						std::cout << " ";
					++i;
				}
				std::cout << endl;
				goto END;
			}
		}

		for (auto x : nn){
			auto n1 = x[0] - c[0][0];
			auto n2 = x[0] - c[1][0];
			bool f(true);
			bool f2(true);

			for (int i = 1; i < 4; ++i){
				if (n1 != x[i] - c[0][i])
					f = false;
				if (n2 != x[i] - c[1][i])
					f2 = false;
			}

			if (f){
				int i(0);
				for (auto x : aa){
					for (auto y : x){
						if ('a' > y || 'z' < y){
							std::cout << y;
							continue;
						}

						int q = y - 'a';
						if (q - n1 < 0){
							q = 26 - n1;
						}
						else
							q -= n1;

						std::cout << (char)(q + 'a');
					}
					if (i < aa.size() - 1)
						std::cout << " ";
					++i;
				}
				std::cout << endl;
				goto END;
			}
			else if (f2){
				int i(0);
				for (auto x : aa){
					for (auto y : x){
						if ('a' > y || 'z' < y){
							std::cout << y;
							continue;
						}

						int q = y - 'a';
						if (q - n2 < 0){
							q = 26 - n2;
						}
						else
							q -= n2;

						std::cout << (char)(q + 'a');
					}
					if (i < aa.size() - 1)
						std::cout << " ";
					++i;
				}
				std::cout << endl;
				goto END;
			}

		}
	END:;
	}
	return 0;
}

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