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 <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		char str[260];
		char e[260];
		scanf("\n");
		gets(str);
		int leng=strlen(str);
		puts(str);
			for(int i=1;i<26;i++){
				if(i%2!=0 && i%13!=0){
					for(int j=0;j<26;j++){
						string r;
						for(int y=0;y<leng;y++){
							if(str[y]-'a'>=0 && str[y]-'a'<26){
								int o=str[y]-'a';
								o=(o*i+j)%26;
								r.push_back(o+'a');
							}else{
								r.push_back(str[y]);
							}
						}
						int p=r.size();
						for(int i=0;i<p-3;i++){
							if(r[i]=='t' && r[i+1]=='h' && ((r[i+2]=='a' && r[i+3]=='t') || (r[i+2]=='i' && r[i+3]=='s'))){
								cout << r << endl;
								goto ri;
							}
					}
				}
			}
			}
ri:;
}
}

C++: #include <iostream>
#include <cstring>
using namespace std;

int main(){
	int n;
	string str;
	bool output;
	int code;
	int str1[4] = {19, 7, 8, 18};
	int str2[4] = {19, 7, 0, 19};
	
	cin >> n;
	
	getline(cin, str);
	for(int i = 0; i < n; i++){
		getline(cin, str);
		
		output = false;
		
		for(int a = 0; !output && a < 26; a++){
			for(int b = 0; !output && b < 26; b++){
				for(int p = 0; !output && p < str.size() - 4; p++){
					for(int c = 0; !output && c < 4; c++){
						code = (a * (str[p + c]-97) + b) % 26;
						if(code != str1[c]) break;
						else if(c + 1 == 4){
							output = true;
							for(int P = 0; P < str.size(); P++){
								if(str[P] != ' ') cout << (char)((a * (str[P]-97) + b) % 26 + 97);
								else cout << " ";
							}
							cout << endl;
						}
					}
					for(int c = 0; !output && c < 4; c++){
						code = (a * (str[p + c]-97) + b) % 26;
						if(code != str2[c]) break;
						else if(c + 1 == 4){
							output = true;
							for(int P = 0; P < str.size(); P++){
								if(str[P] >= 97 && str[P] <= 122) cout << (char)((a * (str[P]-97) + b) % 26 + 97);
								else if(str[P] == ' ') cout << " ";
							}
							cout << endl;
						}
					}
				}
			}
		}
	}
	
	return 0;
}

C++: #include<iostream>
#include<string>
std::string decipher(std::string src, int alpha, int beta)
{
	for (auto&i : src)
	{
		if ('a' <= i && i <= 'z')
		{
			i = ((i - 'a') * alpha + beta) % 26 + 'a';
		}
	}
	return src;
}
int main()
{
	int n;
	std::cin >> n;
	std::cin.ignore();
	for (int i = 0; i < n; i++)
	{
		std::string origin;
		std::getline(std::cin, origin);
		for (int alpha = 0; alpha < 100; alpha++)
		{
			for (int beta = 0; beta < 26; beta++)
			{
				const std::string deciphered = decipher(origin, alpha, beta);
				if (deciphered.find("this") != std::string::npos || deciphered.find("that") != std::string::npos)
				{
					std::cout << deciphered << std::endl;
					alpha = beta = 100;
				}
			}
		}
	}
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;

// m < n
int gcd(int m, int n) {
    int t;
    while (m > 0) {
        t = m;
        m = n % m;
        n = t;
    }
    return n;
}


string affine(int a, int b, const string& word) {
    string newword;
    newword.resize(word.size());
    for (int i = 0, l = word.size(); i < l; i++) {
        if ('a' <= word[i] && word[i] <= 'z') {
            newword[i] = ((a * (word[i] - 'a') + b) % 26) + 'a';
        }
        else {
            newword[i] = word[i];
        }
    }
    return newword;
}

int main() {
    int n;
    string line;

    cin >> n;
    cin.ignore();
    while (n--) {
        int a, b;
        bool found_param = false;
        char tbl[26];

        getline(cin, line);
        for (a = 1; a < 26; a++) {
            if (gcd(a, 26) != 1) continue;
            for (b = 0; b < 26; b++) {
                string w1 = affine(a, b, "that");
                string w2 = affine(a, b, "this");
                string::size_type p1 = line.find(w1);
                string::size_type p2 = line.find(w2);
                if (p1 != string::npos || p2 != string::npos) {
                    found_param = true;
                    break;
                }
            }
            if (found_param) break;
        }
        if (!found_param) continue;
        for (int i = 0; i < 26; i++) {
            tbl[(a * i + b) % 26] = i + 'a';
        }
        for (int i = 0, l = line.size(); i < l; i++) {
            if ('a' <= line[i] && line[i] <= 'z') {
                cout << tbl[line[i] - 'a'];
            }
            else {
                cout << line[i];
            }
        }
        cout << endl;
    }
    return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>

typedef long long ll;
using namespace std;

int F(int a, int b, int c){
	return (a*c+b) % 26;
}

int main(){
	int n;
	string str1;
	getline(cin,str1);

	n = atoi(str1.c_str());
	for(int i=0;i<n;i++){
		string str2;
		getline(cin,str2);

		for(int a=0;a<100;a++){
			for(int b=0;b<100;b++){
				string tmp = str2;
				for(int i=0;i<str2.size();i++){
					if(tmp[i]=='.') continue;
					if(tmp[i]==' ') continue;
					if(isdigit(tmp[i])) continue;
					tmp[i] = F(a,b,str2[i]-'a') + 'a';
				}

				if(tmp.find("that") != string::npos
					|| tmp.find("this") != string::npos){
						cout << tmp << endl;
						goto found;
				}
			}
		}
found:;
	}
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main() {
	int n; cin >> n;
	getchar();
	while (n--) {
		string s; getline(cin, s);
		rep(a, 26) rep(b, 26) {
			string t = s;
			rep(i, t.size()) if (isalpha(t[i])) t[i] = (a * (t[i] - 'a') + b) % 26 + 'a';
			if(t.find("that") != -1 || t.find("that") != -1) {
				cout << t << endl;
				goto next;
			}
		}
		next:;
	}
	
	return 0;
}

C++: #include<iostream>
using namespace std;int main(){int n,i,j,k;string s,t;cin>>n;getline(cin,s);while(n--){getline(cin,s);t=s;for(i=99;i;i--)for(j=0;j<26;j++){for(k=0;k<s.size();k++)if(t[k]-32)t[k]=97+(i*s[k]+j)%26;if(t.find("this")+1||t.find("that")+1)goto p;}p:cout<<t<<endl;}return 0;}