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 <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int n;
ll x,y;
string s;

ll extgcd(ll a,ll b,ll& x, ll& y){
	ll d=a;
	if(b)d=extgcd(b,a%b,y,x),y-=(a/b)*x;
	else x=1,y=0;
	return d;
}

ll mod_inverse(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return ((ll)m+x%m)%m;
}

int main(){
	cin>>n;
	getline(cin,s);
	while(n--){
		getline(cin,s);
		rep(i,26)rep(j,26)if(extgcd(i,26,x,y)==1){
			string t=s;
			rep(k,t.sz)if(t[k]!=' '){
				int x=(t[k]-'a'-j+26)%26;
				t[k]='a'+(x*mod_inverse(i,26))%26;
			}
			if(t.find("this")!=-1||t.find("that")!=-1){
				cout<<t<<endl;
				goto nx;
			}
		}
		nx:;
	}
}

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

int code[26];

int gcd(int x, int y){
  if(y == 0) return x;
  return gcd(y, x % y);
}

int affine(int m, int a, int b){
  return (m * a + b) % 26;
}

int main(void){
  int n;
  string p;
  cin >> n; cin.ignore();
  while(n--){
    getline(cin, p);
    bool finded = false;
    for(int a = 1; a < 26; a++){
      if(finded) break;
      if(gcd(a, 26) != 1) continue;

      for(int b = 1; b < 26; b++){
        for(int i = 0; i < 26; i++){
          code[affine(i, a, b)] = i;
        }

        string c = "";
        for(int i = 0; i < p.size(); i++){
          if(p[i] == ' ') c += " ";
          else c += (char)(code[p[i] - 'a'] + 'a');
        }

        bool tis = c.find("this", 0) != string::npos;
        bool tht = c.find("that", 0) != string::npos;
        if(tis || tht){
          cout << c << endl;
          finded = true;
          break;
        }
      }
    }
  }
  return 0;
}

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

#define F(n, a, b) (((a) * (n) + (b)) % 26 + 'a')
#define N(n) ((n) - 'a')

using namespace std;

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

int main() {
	string str, ans = "";
	string _this = "this", _that = "that";
	string __this = "", __that = "";
	int n, a, b;
	getline(cin, str);
	sscanf(str.c_str(), "%d", &n);
	for (int i = 0; i < n; i++) {
		getline(cin, str);
		for (a = 1; a < 26; a++) {
			if (gcd(a, 26) != 1)
				continue;
			for (b = 0; b < 26; b++) {
				__this = __that = "";
				for (int j = 0; j < 4; j++) {
					__this += (char)F(N(_this[j]), a, b);
					__that += (char)F(N(_that[j]), a, b);
				}
				if (str.find(__this) != string::npos || str.find(__that) != string::npos)
					goto END;
			}
		}
END:
		string alpha = "abcdefghijklmnopqrstuvwxyz";
		map<char, char> decrypt;
		for (int j = 0; j < 26; j++)
			decrypt[(char)F(N(alpha[j]), a, b)] = alpha[j];
		ans = "";
		for (int j = 0; j < str.size(); j++) {
			if (isalpha(str[j]))
				ans += (char)decrypt[str[j]];
			else
				ans += (char)str[j];
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

map<char, char> computeMap(int a, int b) {
	map<char, char> res;
	for (int x = 0; x < 26; x++) {
		int y = (a * x + b) % 26;
		res[y + 'a'] = x + 'a';
	}

	return res;
}

string decode(string str, map<char, char> m) {
	for (auto &c : str) {
		c = isalpha(c) ? m[c] : c;
	}
	return str;
}

string solve(string str) {
	for (int a = 0; a < 25; a++) {
		for (int b = 0; b < 25; b++) {
			if (__gcd(a, 26) != 1) continue;
			map<char, char> m = computeMap(a, b);
			string decoded = decode(str, m);
			if (decoded.find("that") != string::npos || 
				decoded.find("this") != string::npos) {
				return decoded;
			}
		}
	}
	return "hoge";
}

int main(void) {
	int N;
	cin >> N;
	cin.get();

	for (int i = 0; i < N; i++) {
		string str;
		getline(cin, str);
		cout << solve(str) << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <sstream>
#include <math.h>

using namespace std;

string check(string str);
map<char, int> create_table();
int gcd(int a, int b);

int main(){
  char ch = 'a';
  string str;
  int num;
  vector<string> answers;
  map<char,int> table = create_table();
  cin >> num;

  cin.ignore();
  for(int k=0; k<num; k++){
    getline(cin, str);

    char c;
    char list[1];
    bool flag = true;
    int beta;
    int alpha = 1;
    map<char, int>::iterator itr;
    while(flag){
      if(gcd(alpha,26) == 1){ 
        for(beta=1; beta<=26; beta++){
          string result;
          for(int i=0; i<str.size(); i++){
            c = str[i];
            if(c != ' '){
              sprintf(list, "%c", ch+(alpha*table[c]+beta)%26);
              result += list[0];
            }else{
              result += ' ';
            }
          }
          if(result.find("this",0) !=string::npos || result.find("that",0) != string::npos){
            answers.push_back(result);
            flag = false;
            break;
          }
        }
      }
      alpha++;
    }
  }

  for(int j=0; j<answers.size(); j++){
    cout << answers[j] << endl;
  }
  return 0;
}


map<char, int> create_table(){
  map<char, int> table;
  char ch[1];
  char str = 'a';

  for(int i=0; i<26; i++){
    sprintf(ch, "%c", str+i); 
    table.insert(pair<char,int>(ch[0],i));
  }
  return table;
}

int gcd(int a, int b){
  int temp;
  if(a<b){
    temp = a;
    a = b;
    b = temp;
  }
  while(b!=0){
    temp = b;
    b = a%b;
    a = temp;
  }
  return a;
}