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++: #define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

inline char _rotate(char c, char df) {
    int x = c + (26 - df - 'a');
    return x % 26 + 'a';
}
inline char rotate(char c, char df){
    if(isalpha(c)){
        c = _rotate(c, df);
    }
    return c;
}

inline char decode_from_t(char t, char tgt){
    int df = ('t' - t);
    return _rotate(tgt, df);
}

char buf[82];

inline bool is_sep(char *c){
    return *c == ' ' || *c == '.' || *c == '\n';
}

inline int df(char *l, int next){
    return *(l+next) - *(l + 1 + next);
}

inline int df(char l, char r){
    return l - r;
}

// return rot.
int findTheThatThis(){
    char *f_sep, *b_sep = buf - 1;
    char d_the[][2] = { {-14, 3},{12, -23},{12, 3} }; // the
    char d_this_that[][3] = {
        {-14, -1, -10}, {-14, -1, 16}, {-14, 25, -10}, {12, -1, -10}, // this
        {-14, 7, 7}, {12, -19, 7}, {12, 7, -19}, // that
    };
    bool found = false;

    do {
        f_sep = b_sep;
        while (!is_sep(++b_sep));
        //for_each(f_sep, b_sep, [](char x){ putchar(x); }); putchar('\n');
        if(b_sep - f_sep - 1== 3){
            int buf[2] = { df(f_sep,1), df(f_sep,2) };
            for (int i = 0; i < sizeof(d_the); i++) {
                if(d_the[i][0] == buf[0] && d_the[i][1] == buf[1]){
                    found = true;
                    break;
                }
            }
        }else if(b_sep - f_sep - 1 == 4){
            int buf[3] = { df(f_sep,1), df(f_sep,2), df(f_sep,3)};
            for (int i = 0; i < sizeof(d_this_that); i++) {
                if(d_this_that[i][0] == buf[0] && d_this_that[i][1] == buf[1] && 
                        d_this_that[i][2] == buf[2]){
                    found = true;
                    break;
                }
            }
        }
        if(found) return *(f_sep+1) - 't';
    } while (*b_sep != '\n');

    // not found
    return 0;
}

int main(int argc, char const* argv[])
{
    int dif;

    while (nullptr != fgets(buf, 82, stdin)) {
        dif = findTheThatThis();
        for (int i = 0; ; i++) {
            if(buf[i] == '\n'){
                buf[i] = '\0';
                puts(buf);
                break;
            }
            buf[i] = rotate(buf[i], dif);
        }
    }

        return 0;
}

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

using namespace std;

int main() {
	string str;
	string in;
	while (cin >> in) {
		str += in;
		str += " ";
	}
	
	int n = (int)str.size(); n--;
	str = str.substr(0, n);
	
	for (int i=1; i<=26; i++) {
		for (int j=0; j<n; j++) {
			if (str[j] == '.') continue;
			str[j] = str[j] + i;
			if (str[j] > 'z') str[j] = 'a' + str[j] - 'z';
		}
		if (str.find("the")!=str.npos || str.find("this")!=str.npos || str.find("that")!=str.npos) break;
	}
	
	cout << str << endl;
	
	return 0;
}

C++: import java.io.*;

public class main{
	public static void main(String[] args) throws IOException{
		try{
	        InputStreamReader isr = new InputStreamReader(System.in);
	        BufferedReader br = new BufferedReader(isr);
	        String str;
	        String target[];
	        int  checkResult = 99;
	        int caesar;
	        
	        while( (str = br.readLine()) != null){
	        	caesar = 0;
	        	target =  str.split(" ");
		        for(int i = 0; i < target.length; i++){    		
	        		checkResult = checkPattern(target[i]);
	        		if(checkResult != 99){
	        			caesar = checkResult;
	        			break;
	        		}
	        	}
	        
	            StringBuilder result = new StringBuilder();
	            for(int i = 0; i < target.length; i++){
	        	    result.append(makeCaeserString(target[i],caesar));
	        	    result.append(" ");
	            }        
	            System.out.println(result);	        	
	        }	        
		}catch(Exception e){
			System.out.println(e);
		}
	}

	private static int checkPattern(String str){
		
		String target[];
		target = str.split("\\.");
		int result  = 99;
		
		for(int i = 0; i < target.length; i++){
			result = isThe(target[i]);
			if(result != 99) break;
			result = isThis(target[i]);
			if(result != 99) break;
			result = isThat(target[i]);
			if(result != 99) break;
		}
		return result;
	}
	
	private static int isThe(String str){
		
		String newStr;
		String  target = "the";
		int result = 99;
		
		if(str.length() != target.length()) return result;
		
		for(int i = -26; i < 27; i++){
			//str.charAt(j)???str???j????????????????????????
			newStr =  String.valueOf((char)(str.charAt(0)+i))
					 + String.valueOf((char)(str.charAt(1)+i))
				     + String.valueOf((char)(str.charAt(2)+i));
			
			if( newStr.equals(target) ){
				result = i;
				break;
			}
		}
		return result;
	}
	
	private static int isThis(String str){
		
		String newStr;
		String  target = "this";
		int result = 99;;
		
		if(str.length() != target.length()) return result;
		
		for(int i = -26; i < 27; i++){
			//str.charAt(j)???str???j????????????????????????
			newStr =  String.valueOf((char)(str.charAt(0)+i))
					 + String.valueOf((char)(str.charAt(1)+i))
				     + String.valueOf((char)(str.charAt(2)+i))
			         + String.valueOf((char)(str.charAt(3)+i));
			
			if( newStr.equals(target) ){
				result = i;
				break;
			}
		}
		return result;
	}	
  private static int isThat(String str){
	
	String newStr;
	String  target = "that";
	int result = 99;;
		
	if(str.length() != target.length()) return result;
	
	for(int i = -26; i < 27; i++){
		//str.charAt(j)???str???j????????????????????????
		newStr =  String.valueOf((char)(str.charAt(0)+i))
				 + String.valueOf((char)(str.charAt(1)+i))
			     + String.valueOf((char)(str.charAt(2)+i))
			     + String.valueOf((char)(str.charAt(3)+i));
		
		if( newStr.equals(target) ){
			result = i;
			break;
		}
	}
	return result;
  }
  
  private static String makeCaeserString(String str,int n){
	  
	  int intA = 'a';
	  int intZ = 'z';
	  int zure = 0;
	  String result = "";
	  	  
	  for(int i = 0; i < str.length(); i++){
		  if(str.charAt(i)<intA || str.charAt(i) > intZ){
			  return str;
		  }else if( (str.charAt(i)) == ".".charAt(0)){
			  zure = -n;
		  }else if( str.charAt(i) + n < intA ){
			  zure = 26;
		  }else if(str.charAt(i) + n > intZ){
			  zure = -26;
		  }
		  result += String.valueOf((char)(str.charAt(i)+n+zure));
	      zure = 0;
	  }
	  return result;
  }
}