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 <cctype>
using namespace std;

string tar[] = { "this", "that" };

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

int main()
{
	string in;
	int N;
	cin >> N;
	getline(cin, in);
	while (N--)
	{
		getline(cin, in);
		string ans;
		bool f = false;
		for (int a=1;; a++)
		{
			if (gcd(a, 26) != 1) continue;
			for (int b=0; b<26; b++)
			{
				ans = in;
				for (int i=0; i<in.size(); i++)
					if (islower(ans[i]))
						ans[i] = (char) ((int) 'a' + (a * ((int) ans[i]) + b) % 26);
	

				if (ans.find(tar[0], 0) != string::npos || ans.find(tar[1], 0) != string::npos)
				{
					f = true;
					break;
				}
			}
			if (f)
				break;
		}

		cout << ans << endl;

	}
}

C++: #include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(i=0;i<n;++i)
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second

int main(int argc, char const *argv[]) {
  int i,j,k;

  string a="abcdefghijklmnopqrstuvwxyz";

  int n;
  scanf("%d\n",&n);
  for(int times=0; times<n; ++times){
    string s;
    getline(cin,s);
    //cout << s << endl;

    string ans;
    bool end=false;

    for(i=1; i<=25; ++i){//??¢???????????????
      if(26%i==0) continue;

      rep(j,26){
        //????????£?????§????¨?
        set<int> ch;
        rep(k,a.size()) ch.insert((i*k+j)%26);
        //??????
        if(ch.size()!=a.size()) continue;

        //printf("(%d,%d)\n",i,j);
        //?????????
        ans="";
        int p=0;
        rep(k,s.size()){
          if('a'<=s[k] && s[k]<='z'){
            ans+='a'+(i*(s[k]-'a')+j)%26;
          }
          else{
            ans+=s[k];
            string tmp=ans.substr(p,k-p);
            //cout << tmp << endl;

            if(tmp=="this"||tmp =="that")
              end=true;

            p=k+1;
          }
        }

        if(end) break;
      }
      if(end) break;
    }

    std::cout << ans << std::endl;
  }
  return 0;
}

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("this") != -1) {
				cout << t << endl;
				goto next;
			}
		}
		next:;
	}
	
	return 0;
}

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

string THIS = "this", THAT = "that";
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int main() {
	int a;
	string b;
	cin >> a;
	getline(cin, b);
	for (int c = 0; c < a; c++) {
		getline(cin, b);
		for (int d = 1; d < 26; d++) {
			for (int e = 0; e < 26; e++) {
				if (gcd(d, 26) != 1)continue;
				string s;
				for (int f = 0; f < b.length(); f++) {
					if (b[f] == ' ')s += ' ';
					else {
						for (int g = b[f] - 'a';g<26*26+'a'; g += 26) {
							if ((g - e) % d == 0 && (g - e) / d >= 0 && (g - e) / d < 26) s+=((g - e) / d+'a');
						}
					}
				}
				for (int i = 0; i < s.length() - 4; i++) {
					bool x = true, y = true;
					for (int p = 0; p < 4; p++) {
						if (s[i + p] != THIS[p])x = false;
						if (s[i + p] != THAT[p])y = false;
					}
					if (x | y) { cout << s << endl; break; }
				}
			}
		}
	}
}

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

using namespace std;

string Affine(string S)
{
	vector<int> F(26);

	for (int i = 0; i < 26; i++) // alpha
	{
		for (int j = 0; j < 26; j++) // beta
		{
			for (int k = 0; k < 26; k++) // gamma
			{
				F[k] = (i * k + j) % 26;
			}
			
			string T = S;

			for (int k = 0; k < S.size(); k++)
			{
				if (islower(S[k]))
				{
					T[k] = F[S[k] - 97] + 97;
				}
				else
				{
					T[k] = S[k];
				}
			}

			if (T.find("this") != string::npos || T.find("that") != string::npos)
			{
				return T;
			}
		}
	}

	return "";
}

int main()
{
	int n; string S;

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		while (S == "")
		{
			getline(cin, S);
		}

		cout << Affine(S) << endl;
	}
	
	return 0;
}

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

#define A 12

int main()
{
  int n,i,j;
  int alpha[A]={3,5,7,9,11,13,15,17,19,21,23,25},beta;
  string s,t;
  bool f;
  getline(cin,s);
  while(getline(cin,s)){
    f=true;
    for(i=0;f && i<A;i++){
      for(beta=0;f && beta<26;beta++){
	t=s;
	for(j=0;j<t.size();j++){
	  if(t[j]==' ')continue;
	  t[j]-='a';
	  t[j]=(t[j]*alpha[i]+beta)%26;
	  t[j]+='a';
	}
	if(t.find("this ",0)==4)f=false;
	if(t.find("that ",0)==4)f=false;
	if(t.find(" this",t.size()-5)==t.size()-5)f=false;
	if(t.find(" that",t.size()-5)==t.size()-5)f=false;
	if(t.find(" this ")!=string::npos)f=false;
	if(t.find(" that ")!=string::npos)f=false;
      }
    }
    cout<<t<<endl;
  }
}

C++: //============================================================================
// Name        : aoj0040.cpp
// Author      : afterCmidday
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>

using namespace std;


int gcd(int x,int y){
	if(y == 0){
		return x;
	}
	return gcd(y,x % y);
}
int main(void){
	int a, b, n, i, j;
	string str,ans;
	cin >> n;
	getline(cin,str);
	for(i = 0;i < n;i++){
		ans = "";
		getline(cin,str);
		for(a = 1;;a++){
			if(gcd(a,26) == 1){
				for(b = 0;b < 26;b++){
					string tmp = "";
					for(i = 0;i < str.size();i++){
						if(isalpha(str[i])){
							for(char c = 'a';c <= 'z';c++){
								if((str[i] - 'a') % 26 == (a * (c - 'a') + b) % 26){
									tmp += c;
								}
							}
						}else{
							tmp += str[i];
						}
					}
					if(tmp.find("that") != -1 || tmp.find("this") != -1){
						ans = tmp;
						break;
					}
				}
				if(ans != ""){
					break;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}