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 <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

string change(string s,int a,int b){
	string ret(s);
	rep(i,0,ret.size()){
		int y=ret[i]-'a';
		y=(a*y+b)%26;
		ret[i]='a'+y;
	}
	return ret;
}

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

int main(){
	int n;
	cin>>n;
	cin.ignore();
	string str[2]={"that","this"};
	rep(i,0,n){
		string s;
		bool f=0;
		getline(cin,s);
	//	o(s);
		rep(a,0,26){
			if(gcd(a,26)!=1) continue;
			rep(b,0,26){
				string t;
				t=change(s,a,b);
				//o(t);
				rep(j,0,2){
					if(t.find(str[j]) != string::npos){
						o(t); f=1; break;
					}
				}
				if(f) break;
			}
			if(f) break;
		}

	}
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000007
#define EPS 1E-12

int n;
string tmp;

int main()
{
  cin >> n;

  while(n--){
    int alpha, beta;
    vector<string> s;
    while(cin >> tmp) s.pb(tmp);

    vrep(v, s) if((*v).size() == 4){
      bool ok = false;

      rep(a, 26) rep(b, 26){
        string word = *v;
        rep(i, 4){
          word[i] -= 'a';
          word[i] = (word[i] + 26 - b) % 26;
          word[i] = (word[i] * a) % 26;
          word[i] += 'a';
        }
        if(word == "this" || word == "that"){
          alpha = a;
          beta  = b;
          ok = true;
          break;
        }
      }
      if(ok) break;
    }

    vrep(v, s){
      tmp = *v;
      rep(i, tmp.size()){
        tmp[i] -= 'a';
        tmp[i] = (tmp[i] + 26 - beta) % 26;
        tmp[i] = (tmp[i] * alpha) % 26;
        tmp[i] += 'a';
      }
      cout << tmp << " ";
    }
    cout << "\b" << endl;
  }

  return 0;
}

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

int main(){
	int n;
	char str[257] = {}, str_c[257], len;
	cin >> n;
	getchar();
	for (int m = 0; m < n; m++){
		int flag = false;
		gets(str);
		len = strlen(str);
		//printf("%d\n", len);
		for (int i = 0; i < 26; i++){
			/*if (i % 2 == 0 || i % 13 == 0) continue;*/
			for (int j = 0; j < 26; j++){
				for (int k = 0; k <= len; k++){
					if (isalpha(str[k])){
						str[k] -= 'a';
						str_c[k] = (str[k] * i + j) % 26 + 'a';
						str[k] += 'a';
					}
					else{
						str_c[k] = str[k];
					}
				}
				if (strstr(str_c, "this") || strstr(str_c, "that")){
					printf("%s\n", str_c);
					flag = true;
					break;
				}
			}
			if (flag) break;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
using namespace std;
int inf = 1000000000;

char affine(char c, int a, int b){
  int x = c - 'a';
  int y = ( a * x + b ) % 26;
  char r = 'a' + y;
  return r;
}

int main(){

  int n;
  cin >> n;
  cin.ignore();
  bool f = true;
  for(int l=0; l<n; l++){
    string s;
    getline(cin, s);

    for(int i=1; i<50&&f; i++){
      if( i % 2 == 0 || i % 13 == 0 ) continue;
      for(int j=1; j<50&&f; j++){
        string t = "";
        for(int k=0; k<s.size(); k++){
          if( 'a' <= s[k] && s[k] <= 'z' ) t += affine(s[k], i, j);
          else t += s[k];
        }
        if( t.find("that") != -1 || t.find("this") != -1 ){cout << t << endl; f = false;}
      }
    }

  }


  return 0;
}

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 < 100; 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;
        }

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

        if(p.find("this") + 1 || p.find("that") + 1){
          cout << p << endl;
          finded = true;
          break;
        }
      }
    }
  }
  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[20000];
		n--;
		string s="";
		fgets(S,20000,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;
				//cout<<t<<endl;
				for(int k=0;k<s.size();k++){
					if(s[k]==' '){
						continue;
					}
					t[k]=mp[t[k]];
				}
				//cout<<t<<endl;
				if(check(t)){
					cout<<t<<endl;
					goto end;
				}
				
			}
		}
		end:;
		
	}
	return 0;
}