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 <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int const MOD = 1000000007;

int main() {
    int n; cin >> n; cin.ignore();
    rep(i,0,n) {
        string s; getline(cin, s);
        string ans;
        bool findans = false;
        for(int alpha = 3; ; alpha+=2) {
            if(alpha % 13 == 0) continue;
            rep(beta,0,26) {
                ans.clear();
                rep(j,0,s.length()) {
                    if('a' <= s[j] && s[j] <= 'z') {
                        ans += (((int)s[j] - 96) * alpha + beta) % 26 + 96;
                    }
                    else ans += s[j];
                }
                if(ans.find("that") != string::npos || ans.find("this") != string::npos) {
                    findans = true;
                    break;
                }
            }
            if(findans) break;
        }
        cout << ans << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std; 
 
map<char, int> c2i;
map<int, char> i2c;
string str;
 
void init()
{
    for (char ch = 'a'; ch <= 'z'; ch++) {
	c2i[ch] = ch - 'a';
	i2c[ch - 'a'] = ch;
    }
}
 
bool serch(string s)
{
    string str;
    stringstream ss(s);
    while (ss >> str) {
        if (str == "this" || str == "that") {
            return 1;
        }
    }
    return 0;
}
 
char F(char ch, int a, int b)
{
    int num = (a * c2i[ch] + b) % 26; 
    return i2c[num];
}
 
int main()
{
    int n;
    init(); 
    cin >> n;
    cin.ignore();
    while (n--) {
	getline(cin, str);
 
	for (int i = 0; i < 26; i++) {
	    for (int j = 0; j < 26; j++) {
		string next;
		for (int k = 0; k < (int)str.size(); k++) {
		    if (islower(str[k])) {
                        next += F(str[k], i, j);
		    } else {
                        next += str[k];
                    }
                }
		if (serch(next)) {
		    cout << next << endl;
                    return 0;
		}
	    }
	}
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <math.h>
#include <map>
#include <stdio.h>
#include <ctype.h>
#include <algorithm>
#include <stdlib.h>

using namespace std;

int main() {
    string y;
    
    int z[12]={1,3,5,7,9,11,15,17,19,21,23,25};
    
    int affine[12*26][26]={0};
    for(int a=0; a<12; a++){
        for(int b=0; b<26; b++){
            for(int i=0; i<26; i++){
                    affine[a*26+b][(i*z[a]+b)%26]=i;
            }
        }
    }
    
    int temp;
    scanf("%d",&temp);
    
    
    for(int t=0; t<temp+1; t++){
        getline(cin,y);
        string x=y;
        
        
        for(int j=0; j<12*26; j++){
            if(x.find("this")!=-1 || x.find("that")!=-1){
                cout<<x<<endl;
                break;
            }
            for(int i=0; i<(int)y.length(); i++){
                if(y[i]==' '){
                    
                }else{
                    x[i]=affine[j][y[i]-'a']+'a';
                }
            }
        }
    
        
        
    }
    
    
    
    return 0;
}

C++: #include<iostream>
#include<string>
#include<cstring>
#include<cstdio>
#include<cctype>

using namespace std;

typedef unsigned long long ull;
const ull B = 100000007;

bool Rabin_Karp(string a, string b){

  int al = a.length(),bl = b.length();  
  if(al>bl)return false;

  ull t=1;
  for(int i=0; i<al; i++)t*=B;

  ull ah=0,bh=0;
  for(int i=0; i<al; i++)ah=ah*B+a[i];
  for(int i=0; i<al; i++)bh=bh*B+b[i];

  for(int i=0; i+al<=bl; i++){
    if(ah==bh)return true;
    if(i+al<bl)bh=bh*B+b[i+al]-b[i]*t;
  }
  return false;
}

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

char decode(char r, int a, int b)
{
    if ('a'<=r && r<='z') {
        int t = (r-'a') - b;
        while (t%a != 0) t += 26;
        return (t/a) % 26 + 'a';
    } 
    else return r;
}


int main(void){
  int n;
  string str;

  cin >> n;
  cin.ignore();

  while(n--){
    getline(cin,str);
    bool fg=false;
    for(int a=1;a<100;a++){
      if(gcd(a,26)==1){
	for(int b=1;b<100;b++){
	  string res="";
	  for(int k=0;k<str.size();k++)
	    res+=decode(str[k],a,b);
	  
	  if(Rabin_Karp("that",res)||Rabin_Karp("this",res)){
	    cout << res << endl;
	    fg=true;
	    break;
	  }
	}
      }
      if(fg)break;
    }
    
  }

  return 0;
}

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

int trans[26];


void makelist(int a,int b){
	for(int i=0;i<26;i++){
		trans[i]=(a*i+b)%26;
	}
}

string translate(string s){
	for(int i=0;i<s.size();i++){
		if(s[i]>='a' && s[i]<='z'){
			s[i]=trans[s[i]-'a']+'a';
		}
	}
	return s;
}

int main(){
	//a!=2,13 **
	int n;
	cin>>n;
	for(int count=0;count<n;count++){
		string s;
		cin.ignore();
		getline(cin,s);
		string tmp=s;
		int a=0,b=100;
		while(s.find("that")==string::npos && s.find("this")== string::npos){
			b++;
			if(b>=26){
				b=0;
				a++;
			}
			
			while(a%2==0||a%13==0)a++;
			makelist(a,b);
			s=translate(tmp);
			//cout<<s<<endl;
		}
		cout<<s<<endl;
	}
}

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

using namespace std;

int main() {
	string abc = "abcdefghijklmnopqrstuvwxyz";
	string n;
	int nn;
	char c;
	cin >> nn >> c;
	for (int p = 0; p < nn; p++) {
		getline(cin, n);
		if (p == 0) {
			n = c+n;
		}
		vector<int> data(n.size(), -1);
		for (int i = 0; i < n.size(); i++) {
			for (int j = 0; j < abc.size(); j++) {
				if (n[i] == abc[j]) {
					data[i] =j;
					break;
				}
			}
		}
		string b;
		for (int i = 3; ; i++) {
			if (i % 2 != 0 && 1 % 13 != 0) {
				bool hantei = false;
				for (int j = 0; j < 26; j++) {
					string c = "";
					for (int k = 0; k < n.size(); k++) {
						if (data[k] == -1) {
							c += ' ';
						} else {
							c += abc[(i*data[k]+j)%26];
						}
					}
					if (c.find("this") != string::npos || c.find("that") != string::npos) {
						b = c;
						hantei = true;
						break;
					}
				}
				if (hantei) {
					break;
				}
			}
		}
		cout << b << endl;
	}
	return 0;
}