Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		var result string
		line := scanner.Text()
		key := make(map[string]string)

		var i int32
		for ; i < 52; i++ {
			makeKey(key, i)
			result = decode(key, line)

			if strings.Contains(result, "the") {
				break
			} else if strings.Contains(result, "this") {
				break
			} else if strings.Contains(result, "that") {
				break
			}
		}

		fmt.Println(result)
	}
}

func makeKey(key map[string]string, shift int32) {
	for i := 'a'; i <= 'z'; i++ {
		cipher := (i + shift)
		if cipher > 'z' {
			cipher = cipher%'z' + 'a' - 1
		} else if cipher < 'a' {
			cipher = cipher + ('z' - 'a') + 1
		}
		key[string(i)] = string(cipher)
	}
}

func decode(key map[string]string, cipher string) string {
	var result string
	for _, v := range cipher {
		if key[string(v)] != "" {
			result += key[string(v)]
		} else {
			result += string(v)
		}
	}
	return result
}

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

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