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;

void Shift(string *str, int shift, int vec) {
  for (int str_i = 0; str_i < str->size(); str_i++)
    if (!isspace((*str)[str_i]) && (*str)[str_i] != '.')
      (*str)[str_i] += vec * shift;
}

bool FindTarget(string str) {
  if (str.find("the") != string::npos ||
      str.find("this") != string::npos ||
      str.find("that") != string::npos)
    return true;
  else
    return false;
}

int main() { 
  string input_str;

  getline(cin, input_str);

  int shift = 1;
  while (1) {
    Shift(&input_str, shift, 1);
    if (FindTarget(input_str))
      break;
    Shift(&input_str, shift, -1);
    Shift(&input_str, shift, -1);
    if (FindTarget(input_str))
      break;
    Shift(&input_str, shift, 1);
    shift++;
  }

  cout << input_str << endl;

  return 0;
}

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


std::vector<std::string> split(const std::string &s, char delim) {
	std::vector<std::string> elems;
	std::stringstream ss(s);
	std::string item;
	while (std::getline(ss, item, delim)) {
		if (!item.empty()) {
			elems.push_back(item);
		}
	}
	return elems;
}

int main() {
	std::string input;
	while (std::getline(std::cin, input)) {
		std::vector<std::string> words;
		bool isPeriod = false, isCipher = false;
		if (*(input.rbegin()) == '.') {
			input.erase(input.end() - 1);
			isPeriod = true;
		}
		words = split(input, ' ');
		for (int i = 0; i < 26; i++) {
			for (std::vector<std::string>::iterator itr = words.begin(); itr != words.end(); itr++) {
				for (std::string::iterator sitr = (*itr).begin(); sitr != (*itr).end(); sitr++) {
					*sitr = ((*sitr - 'a' + 1) % 26) + 'a';
				}
				if (*itr == "the" || *itr == "this" || *itr == "that") {
					isCipher = true;
				}
			}
			if (isCipher) break;
		}
		std::string output = "";
		for (std::vector<std::string>::iterator itr = words.begin(); itr != words.end(); itr++) {
			if (output != "") output += " ";
			output += *itr;
		}
		if (isPeriod) output += ".";
		std::cout << output << std::endl;
	}
}

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

using namespace std;

int main()
{
    vector<string> str;
    string input;
    int num[81];
    int slide = 0;
    const int al_num = 26;
    string s_the[al_num];
    string s_this[al_num];
    string s_that[al_num];    

    for (int i = 0; i < al_num; i++) {
        s_the[i].push_back(('t' + i - 'a') % al_num + 'a');
        s_the[i].push_back(('h' + i - 'a') % al_num + 'a');
        s_the[i].push_back(('e' + i - 'a') % al_num + 'a');
    }

    for (int i = 0; i < al_num; i++) {
        s_this[i].push_back(('t' + i - 'a') % al_num + 'a');
        s_this[i].push_back(('h' + i - 'a') % al_num + 'a');
        s_this[i].push_back(('i' + i - 'a') % al_num + 'a');
        s_this[i].push_back(('s' + i - 'a') % al_num + 'a');
    }
    for (int i = 0; i < al_num; i++) {
        s_that[i].push_back(('t' + i - 'a') % al_num + 'a');
        s_that[i].push_back(('h' + i - 'a') % al_num + 'a');
        s_that[i].push_back(('a' + i - 'a') % al_num + 'a');
        s_that[i].push_back(('t' + i - 'a') % al_num + 'a');
    }

    for (int i = 0; i < al_num; i++)
        num[i] = -1;

    int i = 0;
    while (cin >> input) {
        num[i++] = input.size();
        str.push_back(input);
    }
    str[i - 1].erase(str[i - 1].size() - 1);
    num[i - 1]--;

    bool loop = false;
    for (int i = 0; num[i] != -1; i++) {
         if (num[i] == 3) { // "the"
             for (int j = 0; j < al_num; j++) {
                if (str[i] == s_the[j]) {
                    slide = j;
                    loop = true;
                    break;
                }
            }
        }
        else if (num[i] == 4) { // "this", "that"
            for (int j = 0; j < al_num; j++) {
                if (str[i] == s_this[j] || str[i] == s_that[j]) {
                    slide = j;
                    loop = true;
                    break;
                }
            }
        }
        
        if (loop)
            break;
    }
    
    // output
    for (int i = 0; num[i] != -1; i++) {
        for (int j = 0; j < num[i]; j++) {
            char c;
            if (str[i][j] - slide < 'a')
                c = 'z' - ('a' - 1 - (str[i][j] - slide));
            else
                c = (str[i][j] - slide - 'a') % al_num + 'a';
            cout << c;
        }
        cout << ' ';
    }
    cout << '\b' << '.' << endl;

    return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main()
{
	char str[90];
	
	while( fgets( str, 81, stdin ) != 0 ){
		while( 1 ){
			for( int i = 0; i < strlen( str ); i++ ){
				if( isalpha( str[i] ) ) str[i]++;
				
				if( str[i] > 'z' ){
				 	str[i] = 'a';
				}
			}
			
			if( strstr( str, "the" ) != NULL || strstr( str, "this" ) != NULL || strstr( str, "that" ) != NULL ) break;
		}
		
		std::cout << str << std::endl;
	}

 	return 0;
}

C++: #include<string>
#include<iostream>
#include<algorithm>
using namespace std;
string henkan(string a)
{
	for (unsigned int i = 0; i < a.size(); i++)
	{
		if (a[i] != ' '&&a[i] != '.'&&a[i]!='\n')
		{
			if (a[i] == 'z')a[i] = 'a';
			else 
				a[i] += 1;
		}
	}
	return a;
}
bool check(string a)
{
	string x[3] = { "the", "this", "that" };
	for (int i = 0; i < 3; i++)
	{
		if (a.find(x[i], 0) != string::npos)return false;
	}
	return true;
}
int main()
{
	
	string a, b;
	while (getline(cin, a))
	{
		while (check(a))
		{
			a = henkan(a);
		}
		cout << a << endl;
	}
	
}

C++: import java.util.*;
import static java.lang.System.*;
import java.math.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String s = sc.nextLine();
		
		for (int i=0; i<26; i++) {
			StringBuilder sb = new StringBuilder();
			char c;
			
			for (int j=0; j<s.length(); j++) {
				c = s.charAt(j);
				if (c!='.' && c!=' ') {
					c -= i;
					if (c < 97) {c+=26;}
				}
				sb.append(c);
			}
			
			if (sb.toString().matches(".*(the|this|that).*")) {out.println(sb);}
		}
	}
}