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 <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	string sent, cp;
	int num;
	cin >> num;
	cin.ignore();
	for(int i = 0; i < num; i++)
	{
		getline(cin, sent);

		for(int j = 0; j < 27; j++)
		{
			for(int k = 0; k < 27; k++)
			{
				cp = sent;

				for(int l = 0; l < sent.size(); l++)
				{
					if(islower(cp[l]))
					{
						cp[l] = (j*(cp[l] - 97)+k) % 26;
						cp[l] += 97;
					}
				}

				if(cp.find("that") != string::npos)
				{
					goto ending;
				}
				else if(cp.find("this") != string::npos)
				{
					goto ending;
				}
			}
		}
ending:;
	   cout << cp << endl;
	}
}

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

int affine(int let,int A,int B) {
  return (A * let + B) % 26;
}

int main() {
  int n;
  string str;
  int x[257],y1;
  char y[257];
  scanf("%d\n",&n);
  for(int i=0;i<n;i++) {
    getline(cin,str);
    for(unsigned int j=0;j<str.size();j++) {
      char x1 = *str.substr(j,1).c_str();
      x[j] = (int)x1 - 97;
    }

    for(int j=1;j<27;j+=2) {
      if(j == 13) continue;
      for(int k=0;k<26;k++) {
        for(unsigned int l=0;l<str.size();l++) {
          if(0 <= x[l] && x[l] <= 25) {
            y1 = affine(x[l],j,k);
          }
          else {
            y1 = x[l];
          }
          y[l] =(char) (y1 + 97);
        }
        y[str.size()] = '\0';

        for(unsigned int l=0;l<str.size()-3;l++) {
          if(y[l] == 't') {
            if(y[l+1] == 'h') {
              if(y[l+2] == 'a') {
                if(y[l+3] == 't') {
                  cout << y << endl;
                  break;
                }
              }
              else if(y[l+2] == 'i'){
                if(y[l+3] == 's') {
                  cout << y << endl;
                  break;
                }
              }
            }
          }
        }

      }
    }

  }
}

C++: #include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef vector<int> vi;
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(c) int((c).size())

vi stovi(const string& s)
{
  vi v;
  tr (s, i) {
    v.pb(*i-'a');
  }
  return v;
}

string vitos(const vi& v)
{
  string s;
  tr (v, i) {
    s.pb('a'+*i);
  }
  return s;
}

void encode(int a, int b, const vi& from, vi& to)
{
  for (int i = 0; i < sz(to); i++) {
    if (0 <= from[i] && from[i] <= 25)
      to[i] = (a * from[i] + b) % 26;
    else
      to[i] = from[i];
  }
}

string code_break(const string& s)
{
  vi v = stovi(s);
  vi tmp = vi(sz(v));
  for (int a = 3; ; a++) {
    if ((a % 2) == 0 || (a % 13) == 0)
      continue;
    for (int b = 0; b < 25; b++) {
      encode(a, b, v, tmp);
      if (v == tmp)
        goto notfound;
      string s = vitos(tmp);
      if ((int)s.find("this ") >= 0
          || (int)s.find("that ") >= 0
          || (int)s.find(" this") >= 0
          || (int)s.find(" that") >= 0) {
        return s;
      }
    }
  }
notfound:
  return string("not found");
}

int main(int argc, char **argv)
{
  int n;
  string s;
  cin >> n;
  getline(cin, s);
  while (n--) {
    getline(cin, s);
    cout << code_break(s) << endl;
  }
  return 0;
}

C++: #include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
char c[257];
char d[257];
bool use[26];
int gcd(int a,int b){
	while(a){
		b%=a;
		int val=b;
		b=a;
		a=val;
	}
	return b;
}
int main(){
	int a;
	scanf("%d ",&a);
	while(a--){
		cin.getline(c,257);
		int t=strlen(c);
		for(int i=1;i<26;i++){
			for(int j=1;j<26;j++){
				bool ok=false;
				if(gcd(i,26)>1)goto dame;
				/*for(int k=0;k<26;k++)use[k]=false;
				for(int k=0;k<26;k++){
					if(use[(i*k+j)%26])goto dame;
					else use[(i*k+j)%26]=true;
				}*/
				for(int k=0;k<t;k++){
					if(c[k]<='z'&&c[k]>='a'){
						d[k]=(i*(c[k]-'a')+j)%26+'a';
					}else{
						d[k]=c[k];
					}
				}
				d[t]=NULL;
				for(int k=0;k<t-3;k++){
					if(d[k]=='t'&&d[k+1]=='h'){
						if(d[k+2]=='a'&&d[k+3]=='t')ok=true;
						if(d[k+2]=='i'&&d[k+3]=='s')ok=true;
					}
				}
				if(ok){
					printf("%s\n",d);
					goto owari;
				}
				dame:;
			}
		}
		owari:;
	}
}

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

using namespace std;

int euclid(int);

int main(void){
	string in,data;
	int i,j,y,line,size,a,b,c,flag=0;

	cin>>line;
	getline(cin,in);
	while(line>0){
		line--;
		getline(cin,in);
		size=in.size();

		data=in;
		for(b=0;b<26;b++){
			for(a=1;a<100;a++){
				c=euclid(a);
				if(c==1){
					for(i=0;i<size;i++){
						if(in[i]!=' '){
								for(j=0;j<26;j++){
									if('a'+j==in[i]){
										y=j;
										data[i]='a'+(a*y+b)%26;
									}
								}
						}
					}
					if(data.find("that")!=-1 || data.find("this")!=-1){
						goto end;
					}
				}
			}
		}
		end:;
		cout<<data<<endl;
		flag=0;
	}

	return 0;
}



int euclid(int x){
	int y=26,n;
	if(x>26){
		while(1){
			n=x%y;
			if(n==0)	return y;
			x=y;
			y=n;
		}
	}
	if(x<26){
		while(1){
			n=y%x;
			if(n==0)	return x;
			y=x;
			x=n;
		}
	}
	if(x==26)	return x;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <random>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

char affinechar(char c, int a, int b) {
    if (islower(c)) {
        return 'a' + (a * (c - 'a') + b) % 26;
    }else {
        return c;
    }
}

void affineconv(string &s, int a, int b) {
    REP(i,s.size()) {
        s[i] =  affinechar(s[i], a, b);
    }
}

bool isEnglish(string s) {
    return s.find("that") != string::npos || s.find("this") != string::npos;
}

random_device rnd;

int rnda() {
    int a = rnd();
    a = abs(a) % 26;
    if (a % 2 == 0 || a % 13 == 0) {
        return rnda();
    }else {
        return a;
    }
}

int rndb() {
    return rnd() % 26;
}

int main() {
    string s;
    while(getline(cin, s)) {
        if (s.size() > 3) {
            while (!isEnglish(s)) {
                affineconv(s, rnda(), rndb());
                //cout << s << endl;
            }
            cout << s << endl;
        }
    }
    return 0;
}