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>
using namespace std;
string G(string s) {
	for (int a=1; a<26; ++a) {
		for (int b=0; b<26; ++b) {
			string t = s;
			for (int i=0; i<t.size(); ++i) {
				if (islower(t[i])) {
					t[i] = 'a' + (a * (s[i] - 'a' + b)) % 26;
				}
			}
			if (t.find("this") != -1 || t.find("that") != -1) {
				return t;
			}
		}
	}
}
int main() {
	int n;
	cin >> n;
	cin.ignore();
	string s;
	while (n--, getline(cin, s)) {
		cout << G(s) << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

/*
   this 19 7 8 18
   that 19 7 0 19

 */

int main(){
    char str[256][256];
    char inp[256];
    int len,n, a,b,l;
    int This[4] = {19, 7, 8, 18}, That[4] = {19, 7, 0, 19};
    while(cin >> n){
        rep(i,n){
            len = 0;
            while(cin >> inp){
                strcpy(str[len], inp);
                len++;
                if(strlen(inp) == 4){
                    bool thisc, thatc;
                    l = 0;
                    rep(j,100){
                        rep(k,100){
                            thisc = thatc = false;
                            if((j * This[l] + k) % 26 == inp[l] - 'a'){
                                for(l = 1; l < 4; l++){
                                    if((j * This[l] + k) % 26 == inp[l] - 'a'){
                                        thisc =true;
                                    }else{
                                        thisc = false;
                                        break;
                                    }
                                }
                            }
                            if(thisc){
                                a = j;
                                b = k;
                            }
                            if((j * That[l] + k) % 26 == inp[l] - 'a'){
                                for(l = 1; l < 4; l++){
                                    if((j * That[l] + k) % 26 == inp[l] - 'a'){
                                        thatc =true;
                                    }else{
                                        thatc = false;
                                        break;
                                    }
                                }
                            }
                            if(thatc){
                                a = j;
                                b = k;
                            }
                        }
                    }
                }
            }
        }
        rep(j,len){
            rep(k, strlen(str[j])){
                rep(l,26){
                    if((a * l + b) % 26 == str[j][k] - 'a'){
                        printf("%c",'a' + l);
                    }
                }
            }
            cout << ' ';
        }
        cout << endl;
    }
}

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

using namespace std;

int main(void){

	string sthat[26][26],sthis[26][26];
	for(int a=0;a<25;a++){
		for(int b=0;b<25;b++){
			sthat[a][b]=(char)((a*('t'-'a')+b)%26+'a');
			sthat[a][b]+=(char)((a*('h'-'a')+b)%26+'a');
			sthat[a][b]+=(char)((a*('a'-'a')+b)%26+'a');
			sthat[a][b]+=(char)((a*('t'-'a')+b)%26+'a');
			sthis[a][b]=(char)((a*('t'-'a')+b)%26+'a');
			sthis[a][b]+=(char)((a*('h'-'a')+b)%26+'a');
			sthis[a][b]+=(char)((a*('i'-'a')+b)%26+'a');
			sthis[a][b]+=(char)((a*('s'-'a')+b)%26+'a');
		}
	}

	int n;
	string in,inp;
	int mm;

	cin>>n;
	getchar();
	for(int i=0;i<n;i++){
		inp=("");
		while(1){
			in=getchar();
			if(in=="\n") break;
			else inp+=in;
		}
		for(int a=0;a<25;a++){
			for(int b=0;b<25;b++){
				if(inp.find(sthat[a][b])!=-1||inp.find(sthis[a][b])!=-1){
					for(int j=0;j<inp.length();j++){
						if(inp[j]!=' '){
							for(int k=26;;k+=26){
								if(((inp[j]-'a')+k-b)%a==0){
									mm=((inp[j]-'a')+k-b)/a;
									while(mm>=26) mm-=26;
									inp[j]=(char)(mm+'a');
									break;
								}
							}
						}
					}
				}
			}
		}
		cout<<inp<<endl;
	}

	return 0;
}

C++: #include <iostream>
#include <string>
#define rep(i) for(I64 i=0;;++i)
#define repn(i,n) for(I64 i=0;i<(n);++(i))
using namespace std;

bool coprime(int a, int b){
	int r, temp;
	if(a < b){
		temp = a;
		a = b;
		b = temp;
	}
	do{
		r = a % b;
		a = b;
		b = r;
	}while(r);
	if(a == 1) return true;
	else return false;
}

int main(){
	char t[26];

	int n;
	cin >> n;

	scanf("%*c");

	repn(i, n){
		string input;
		getline(cin, input);
		int len = input.size();

		bool flag = false;
		rep(a){
			if(coprime(26, a+1)){
				repn(b, 26){
					string res = "";
					repn(r, 26){
						t[r] = ((a+1) * r + b) % 26 + 'a';
					}
					repn(j, len){
						if(input[j] == ' ') res += ' ';
						else{
							repn(k, 26){
								if(input[j] == t[k]){
									res += k + 'a';
									break;
								}
							}
						}
					}
					if(res.find("this") != string::npos || res.find("that") != string::npos){
						cout << res << endl;
						flag = true;
						break;
					}
				}
				if(flag) break;
			}
			if(flag) break;
		}
	}
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

//const int alpha[]={3,4,5,6,7,8,9,10,11,12,14,15,16,17,18,19,20,21,22,23,24,25,27,28,29,30,31,32,33,34};

int main(){
	int n;
	int beta;
	string s;
	cin >> n;
	cin.ignore();
	for(int i=0;i<n;++i){
		beta=0;
		string org(256,'@');
		getline(cin , s);
		while(org.find("this" ,0)==string::npos && org.find("that" , 0)==string::npos){
				for(int j=0;j<1000;++j){
						for(int k=0;k<26;++k){ 
							if((int)(s[0]-'a')==(int)((j*k+beta) % 26)){
								for(int l=0;l<s.size();++l){
									for(int m=0;m<26;++m){
										if(s[l]==' ') {org[l]=' ';  continue;}
										if((s[l]-'a')==((j*m+beta)%26)){
											org[l]=m+'a';
											break;
										}
									}
								}
							}
						}
				}
			beta++;
		}
		int index=org.find_first_of('@');
		org.erase(index);
		cout << org << endl;
	}
	return 0; 
}