Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		scanner.Scan()
		s := scanner.Text()
		rs := []rune(s)
		flag := false
		for b := 0; b <= 26; b++ {
			for a := 0; a <= 26; a++ {
				ans := rs
				if a%2 != 0 && a%13 != 0 {
					for j := 0; j < len(ans); j++ {
						if ans[j] >= 'a' && ans[j] <= 'z' {
							ans[j] = 'a' + ('a'*(ans[j]-'a')+'b')%26
						}
					}
					sans := runeSlice2String(ans)
					if strings.Contains(sans, "that") || strings.Contains(sans, "this") {
						fmt.Println(sans)
						flag = true
						break
					}
				}
			}
			if flag {
				break
			}
		}
	}
}

func runeSlice2String(input []rune) string {
	tmp := make([]string, len(input))
	for i := 0; i < len(input); i++ {
		tmp[i] = string(input[i])
	}
	return strings.Join(tmp, "")
}

C++: #include<iostream>
#include<string>
#include<sstream>
#include<vector>
#include<map>
#include<cctype>
#include<cstdlib>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
const int N = 26;

int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

map<char, char> makeMap(int a, int b){
    map<char, char> ret;
    REP(i, N){
        char bef = 'a' + i;
        char aft = 'a' + ((a * i + b) % N);
        ret[bef] = aft;
    }
    return ret;
}

bool isAns(string str){
    vector<string> v;
    stringstream ss(str);
    string tmp;
    while(getline(ss, tmp, ' ')) v.push_back(tmp);
    REP(i, v.size()) if(v[i] == "that" || v[i] == "this") return true;
    return false;
}

string findAns(string str){
    if(isAns(str)) return str;
    FOR(a, 1, N){
        if(gcd(N, a) != 1) continue;
        FOR(b, 1, N){
            map<char, char> m = makeMap(a, b);
            string tmp = str;
            REP(i, tmp.length()) if(isalpha(tmp[i])) tmp[i] = m[tmp[i]];
            if(isAns(tmp)) return tmp;
        }
    }
    return "error";
}


int main(){
    int n; cin >>n;
    string str;
    getline(cin, str);
    REP(z, n){
        getline(cin, str);
        cout <<findAns(str) <<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	int n;
	std::vector<int> alpha_vec;
	std::string buf;

	alpha_vec.push_back(1);
	alpha_vec.push_back(3);
	alpha_vec.push_back(5);
	alpha_vec.push_back(7);
	alpha_vec.push_back(9);
	alpha_vec.push_back(11);
	alpha_vec.push_back(15);
	alpha_vec.push_back(17);
	alpha_vec.push_back(19);
	alpha_vec.push_back(21);
	alpha_vec.push_back(23);
	alpha_vec.push_back(25);

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	std::cin.rdbuf(ifs.rdbuf());
#endif

	std::cin >> n;
	std::getline(std::cin, buf);
	
	for(int i = 0; i < n; i++){
		std::getline(std::cin, buf);
		for(int j = 0; j < alpha_vec.size(); j++){
			int alpha = alpha_vec[j];
			for(int beta = 0; beta < 26; beta++){
				std::map<unsigned char, unsigned char> map;
				std::string decoded_buf = buf;

				for(unsigned char k = 0; k <= 25; k++){
					unsigned char f = (alpha * k + beta) % 26;
					map[f + 'a'] = k + 'a';
				}
				
				for(int k = 0; k < decoded_buf.size(); k++){
					if(decoded_buf[k] >= 'a' && decoded_buf[k] <= 'z'){
						decoded_buf[k] = map[decoded_buf[k]];
					}
				}
				if(decoded_buf.find("that") != std::string::npos ||
					decoded_buf.find("this") != std::string::npos){
					std::cout << decoded_buf << std::endl;
				}
			}
		}

	}


#if INPUT_FROM_FILE
		//fclose(fp);
#endif
	return 0;
}

C++: 
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }


int f(int y, int a, int b)
{	return (a * y + b) % 26;	}

int main()
{
	int n;
	cin >> n;

	rep(i, n)
	{
		string str;
		cin.sync();
		getline(cin, str);
		int len = str.size();

		for(int a = 0; ; a++)
		{
			if(a % 2 != 0 && a % 13 != 0)
			{
				rep(b, 26)
				{
					// Ï·Îe[u
					int v[26];
					rep(y, 26)
						v[f(y, a, b)] = y;
					

					// Ï·
					string con = str;
					rep(in, len)
						if('a' <= con[in] && con[in] <= 'z')
							con[in] = v[con[in] - 'a'] + 'a';

					// Î`FbN
					rep(in, len - 3)
					{
						if(con.substr(in, 4) == "that" || con.substr(in, 4) == "this")
						{
							cout << con << endl;
							goto ng;
						}
					}
				}
			}
		}
ng:
		;
	}
	return 0;
}

C++: #include<cstdio>
#include<cmath>
#include<stdlib.h>
#include<algorithm>
#include<string> 
#include<iostream>

using namespace std;

int main(){
	int n,t=1;
	string num,ans;
	scanf("%d",&n);cin.ignore();
		for(int gv=0;gv<n;gv++){
			getline(cin,num);
			t=1;
   				 	for(int a=0;a<26&&t;a++){
   				 	if((a+1)%2==0&&a!=13){
   				 	for(int b=0;b<26&&t;b++){
   				 		ans.erase(ans.begin(),ans.end());
   				 		for(int i=0;num[i]!='\0';i++){
   				 			if(num[i]>='a'&& num[i]<='z'){
   				 				ans.push_back((a*(num[i]-'a')+b)%26+'a');
							}
							else{
								ans.push_back(num[i]);
							}
						}
   				 		 ans.push_back('\0');
						t=1;
						for(int i=0;ans[i]!='\0';i++){
     			           if(ans[i]=='t' && ans[i+1]=='h'){
                    			if(ans[i+2]=='i'&&ans[i+3]=='s')t=0;
                 				if(ans[i+2]=='a'&&ans[i+3]=='t')t=0;
                 			}
                 		}
					 }}}
   			for(int i=0;ans[i]!='\0';i++){
   				printf("%c",ans[i]);
			}printf("\n");
	}
	return 0;
}

C++: // AOJ q0040
// YAMADA Terushige
// 2013.5.6

#include<iostream>
#include<sstream>
#include<string>
#include<cctype>
 
using namespace std;
const int N = 26;

char decode(const char c,const int a,const int b){
  if(islower(c)){
    //    int t = ((c - 'a') + N - b)%N;
    int t = c - 'a' - b;
    while(t%a != 0){
      t += N;
    }
    return 'a' + ((t/a) % N) ;
  }
  return c;
}

int gcm(int a,int b){
  if (b==0) return a;
  else return gcm(b,a%b);
}
 
int main(){
  string s,wd;
  int n;
  cin >> n;
  getline(cin,s);
  int a,b;

  for(int i=0;i<n;i++){
    getline(cin,s);
    string ans = s;
    istringstream istr;
    istr.str(s);
    while(istr >> wd){
      if(wd.size()==4){
	string dd = wd;
	for(a=1;a<N;a++){
	  if(gcm(a,N) != 1) continue;
	  for(b=0;b<N;b++){
	    for(int j=0;j<4;j++)
	      dd[j] = decode(wd[j],a,b);
	    if(dd == "this" || dd == "that")
	      goto solved;
	  }
	}
      }
    }
  solved:
    //    istr.clear();
    for(int k=0;k<s.size();k++)
      ans[k]=decode(s[k],a,b);
    cout << ans << endl;
  }
}