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

vector<string> split(string s) {
  s += " ";
  vector<string> res;
  string str;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == ' ') {
      res.push_back(str);
      str = "";
    } else {
      str += s[i];
    }
  }

  return res;
}

vector<int> convert(int a, int b) {
  vector<int> res(26);
  for (int i = 0; i < 26; ++i) {
    res[i] = (a * i + b) % 26;
  }

  return res;
}

vector<string> calc(const vector<string> &v, const vector<int> &t) {
  vector<string> res;
  for (string s : v) {
    for (int i = 0; i < s.size(); ++i) {
      s[i] = (t[s[i] - 'a'] + 'a');
    }
    res.push_back(s);
  }

  return res;
}

void solver() {
  string s;
  getline(cin, s);
  vector<string> v = split(s);

  for (int i = 1; i < 26; ++i) {
    if (__gcd(i, 26) - 1) continue;
    for (int j = 0; j < 26; ++j) {
      vector<int> table = convert(i, j);
      vector<string> res = calc(v, table);

      bool f = false;
      for (string u : res) {
        if (u == "that" || u == "this") {
          f = true;
        }
      }

      if (f) {
        for (int k = 0; k < res.size(); ++k) {
          cout << res[k] << (k + 1 == res.size() ? "\n" : " ");
        }
        return;
      }
    }
  }
}

int main() {
  int n;
  cin >> n;
  cin.ignore();

  for (int i = 0; i < n; ++i) {
    solver();
  }
}

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

using namespace std;

int a,b;
map<char, char> M;

char Affine(char c){
  return ((a*(c-'a') + b) % 26) + 'a';
}


void make(){
  M.clear();
  for(char c = 'a'; c <= 'z'; c++)
    M[Affine(c)] = c;
}


bool check(string in){
  string now = "";
  for(int i = 0; i < in.length(); i++){
    if(in[i] == ' '){
      //   cout << "now = " << now << endl;
      if(now == "this" || now == "that") return true;
      now = "";
    }
    else now += in[i];
  }
  return false;
}

string solve(string s){
 
  for(int i = 0; i < s.length(); i++)
    if(s[i] != ' ') s[i] = M[s[i]];

  if(check(s)) return s;
  return "-1";

}

void print(){
  for(char c = 'a'; c <= 'z'; c++)
    cout << M[c] << " ";

  cout << endl;

}

int main(){
  
  // print();
  // return 0;
  int n;
  cin >> n;
  cin.ignore();
  while(n--){
    string s;
    bool flg = false;
    getline(cin,s);
    for(int i = 0; i < 100; i++){
      for(int j = 0; j < 100; j++){
	a = i;
	b = j;
	make();
	string ans;

	if((ans = solve(s)) != "-1"){
	  flg = true;
	  cout << ans << endl;
	  break;
	}
      }
      if(flg) break;
    }
    
  }
  return 0;
}

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

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

string into(string s, int a, int b){
  string ret="";
  for(int i=0; i<s.length(); i++){
    if('a'<=s[i] && s[i]<='z')ret+=(a*(s[i]-'a'+b))%26+'a';
    else ret+=s[i];
  }
  return ret;
}

bool conversion(vector<string> v, int a, int b){
  vector<string> t;
  for(int i=0; i<v.size(); i++)
    t.push_back(into(v[i], a, b));
  for(int i=0; i<t.size(); i++){
    if(t[i]=="that" || t[i]=="this"){
      for(int j=0; j<t.size(); j++){
        if(j==t.size()-1)cout<<t[j]<<endl;
        else cout<<t[j]<<' ';
      }
      return true;
    }
  }
  return false;
}

int main(){
  int n;
  scanf("%d\n", &n);
  while(n--){
    string s, tmp;
    getline(cin, s);
    stringstream ss(s);
    vector<string> v;
    while(getline(ss, tmp, ' '))v.push_back(tmp);
    for(int a=2; a<25; a++){
      for(int b=a+1; b<26; b++){
        if(gcd(a, b)==1){
          if(conversion(v, a, b))goto CONTINUE;
          if(conversion(v, b, a))goto CONTINUE;
        }
      }
    }
  CONTINUE:
    ;
  }
  return 0;
}

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

int main(){
	int n;
	string str;
	bool output;
	int code;
	int str1[4] = {19, 7, 8, 18};
	int str2[4] = {19, 7, 0, 19};
	
	cin >> n;
	
	getline(cin, str);
	for(int i = 0; i < n; i++){
		getline(cin, str);
		
		output = false;
		
		for(int a = 0; !output && a < 26; a++){
			for(int b = 0; !output && b < 26; b++){
				for(int p = 0; !output && p < str.size() - 4; p++){
					for(int c = 0; !output && c < 4; c++){
						code = (a * (str[p + c]-97) + b) % 26;
						if(code != str1[c]) break;
						else if(c + 1 == 4){
							output = true;
							for(int P = 0; P < str.size(); P++){
								if(str[P] != ' ') cout << (char)((a * (str[P]-97) + b) % 26 + 97);
								else cout << " ";
							}
							cout << endl;
						}
					}
					for(int c = 0; !output && c < 4; c++){
						code = (a * (str[p + c]-97) + b) % 26;
						if(code != str2[c]) break;
						else if(c + 1 == 4){
							output = true;
							for(int P = 0; P < str.size(); P++){
								if(str[P] >= 97 && str[P] <= 122) cout << (char)((a * (str[P]-97) + b) % 26 + 97);
								else if(str[P] == ' ') cout << " ";
							}
							cout << endl;
						}
					}
				}
			}
		}
	}
	
	return 0;
}

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

#define rep(i,j) for(; i < j; i++)

char ch(int a, int b, int c) {
	return (a * c + b) % 26;
}

int main() {
	int n, a, b, c;
	cin >> n;
	cin.ignore();

	string str, res;
	for (; n > 0; n--) {
		getline(cin, str);

		a = b = 1;
		rep(a, 100) {
			if (a == 2 || a == 13) continue;
			rep(b, 100) {
				res = str;
				c = 0;
				rep(c, str.size()) {
					if (res[c] == ' ') continue;

					res[c] = ch(a, b, res[c] - 'a') + 'a';
				}
				if (res.find("this") != -1 || res.find("that") != -1) {
					cout << res << endl;
					a = 114514;
					b = 114514;
				}
			}
		}
	}
	return 0;
}

C++: 1
y eazqyp pnop pngtg ye obmpngt xmybp mr lygw

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;
    t=s;
    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;
    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;
  }
}