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 <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
#include <complex>
#include <cstring>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

char change(int a,int b, char c){
  if(c == ' ')return c;
  return 'a' + (a * (c - 'a') + b) % 26;
}
int main(void){
  int a[] = {1,3,5,7,9,11,17,19,21,23,25,0};
  int n; cin>>n; cin.ignore();
  string str,str_cp,sp = " ";
  
  while(getline(cin,str)){
    str = str_cp = sp + str + sp;
    bool f = false;
    for(int i = 0 ; !f && a[i] ; i ++){
      for(int b = 0 ; !f && b < 26 ; b ++){
	for(int j = 0 ; j < str.length() ; j ++){
	  str[j] = change(a[i],b,str[j]);
	}
	if(str.find(" that ") != string::npos
	   || str.find(" this ") != string::npos){
	  f = true;
	  break;
	}

	str = str_cp;
      }
    }
    cout<<str.substr(1,str.length() - 2)<<endl;
  }
}

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;

int a, b;

void check(int A[], char inp[]){
    int k;
    rep(i, 1000){
        rep(j, 1000){
            if((i * A[0] + j) % 26 == inp[0] - 'a'){
                for(k = 1; k < 4; k++){
                    if((i * A[k] + j) % 26 != inp[k] - 'a') break;
                }
            }
            if(k == 4){
                a = i;
                b = j;
                return;
            }
        }
    }
}

int main(){
    char str[356][356];
    char inp[356];
    int n,i;
    int This[4] = {19, 7, 8, 18}, That[4] = {19, 7, 0, 19};
    while(cin >> n){
        rep(i,n){
            len = 0;
            a = b = -1;
            for(i = 0; cin >> inp; i++){
                strcpy(str[i], inp);
                if(strlen(inp) == 4){
                    check(This, inp);
                    if(a == -1)
                        check(That, inp);
                }
            }
            rep(j,i){
                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 <iostream>
#include <string>

using namespace std;

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

int main() {
	int n;
	string abc = "abcdefghijklmnopqrstuvwxyz";
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		getline(cin, s);
		int a, b;
		a = b = 0;
		while (true) {
			string::size_type index = s.find("this");
			string::size_type index2 = s.find("that");
			if (index != string::npos || index2 != string::npos) {
				break;
			}
			for (int i = 0; i < s.size(); i++) {
				for (int j = 0; j < 26; j++) {
					if (s[i] == abc[j]) {
						s[i] = f(a, b, j);
					}
				}
			}
			a++;
			b++;
		}
		cout << s << endl;
	}
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int i,n;
	scanf("%d\n",&n);
	for(i=0;i<n;i++){
		string str;
		char s[300];
		gets(s);
		str=s;
//cout<<str<<endl;
		int a,b;
		for(a=1;a<26;a+=2){
			if(a==13)continue;
			for(b=0;b<26;b++){
				string st="";
				int j;
				for(j=0;j<str.size();j++){
					if(isalpha(str[j])){
						st+=((str[j]-'a')*a+b)%26+'a';
					}else{
						st+=str[j];
					}
				}
//if(st[0]=='i')cout<<st<<endl;
				/*string::size_type index1=st.find("that");
				string::size_type index2=st.find("this");
				if(index1!=string::npos||index2!=string::npos){
					cout<<st<<endl;
					goto end;
				}*/
			}
		}
		end:;
	}
	return 0;
}

C++: #include<iostream>
#include<cstring>
#include<set>
#include<map>
#define MAX 26
#include<algorithm>
#include<string>
using namespace std;
bool check(string s){
	for(int i=0;i<s.size()-3;i++){
		if((s.substr(i,4)=="that"||s.substr(i,4)=="this")&&(i==0||s[i-1]==' ')&&(i+4>=s.size()||s[i+4]==' '))
			return true;
	}
	return false;
}
int main(){
	int n;
	cin>>n;
	while(n>0){
		char S[300];
		n--;
		string s="";
		fgets(S,300,stdin);
		for(int i=0;i<strlen(S)-1;i++){
			s+=S[i];
		}
		for(int i=0;i<MAX;i++){
			for(int j=0;j<MAX;j++){
				if(__gcd(i,j)!=1){
					continue;
				}
				map<char,char> mp;
				set<int> st;
				for(int k=0;k<MAX;k++){
					int x;
					x=(i*k+j)%26;
					st.insert(x);
					mp[x+'a']=k+'a';
				}
				if(st.size()!=26)
					continue;
				string t=s;
				for(int k=0;k<s.size();k++){
					if(s[k]==' '){
						continue;
					}
					t[k]=mp[t[k]];
				}
				if(check(t)){
					cout<<t<<endl;
					goto end;
				}
				mp.clear();
				st.clear();
			}
		}
		end:;
	}
	return 0;
}