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<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<26;a++){
      if(gcd(a,26)==1){
	for(int b=1;b<26;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 <cstdio>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x = (from); x < (to); ++(x))
#define rep(x,to) rep2(x,0,to) 
int c[26];
bool ch(int x) {
	int a = 26, b = x;
	if(b < a) swap(a, b);
	while(a) {
		int t = b / a;
		swap(b -= t * a, a);
	}
	if(b != 1) return false;
	else {
		rep(i,26) {
			c[i] = (x * i) % 26;
		}
		return true;
	}
}
int main() {
	int n;
	char str[260];
	scanf("%d\n", &n);
	while(n--) {
		gets(str);
		string s = str;
		int len = s.length();
		bool f = 0;
		rep2(i,1,10000) {
			if(ch(i)) {
				rep(k,26) {
					char ns[260];
					rep(j,len) {
						if(islower(str[j])) {
							int b = str[j] - 'a';
							ns[j] = (char) ((c[b] + k) % 26 + 'a');
						} else {
							ns[j] = str[j];
						}
					}
					rep(j,len) {
						if(ns[j] == 't' && ns[j+1] == 'h' && ns[j+2] == 'a' && ns[j+3] == 't' ||
							ns[j] == 't' && ns[j+1] == 'h' && ns[j+2] == 'i' && ns[j+3] == 's') {
							f = 1;
							break;
						}
					}
					if(f) {
						rep(j,len) {
							cout << ns[j];
						}
						cout << endl;
						break;
					}
				}
			}
			if(f) break;
		}
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;char st;
    cin>>n;
    string str;
    for(int i=0;i<=n;i++){
        getline(cin,str);
        bool kawa=0;
        for(int j=1;j<50;j++){
            for(int k=1;k<50;k++){
                string strin=str;
                for(int l=0;strin[l]!='\0';l++)if(strin[l]-'a'>=0&&strin[l]-'z'<=0)strin[l]=(j*(strin[l]-'a')+k)%26+'a';
                for(int l=0;strin[l]!='\0';l++){
                    if(strin[l]=='t'&&strin[l+1]=='h'&&(strin[l+2]=='a'&&strin[l+3]=='t'||strin[l+2]=='i'&&strin[l+3]=='s')){
                        cout<<strin<<endl;
                        kawa=1;
                        break;
                    }
                }
                if(kawa)break;
            }
            if(kawa)break;
        }
    }
}

C++: #include<iostream>
#include<string>
using namespace std;
 
int a[12] = {1,3,5,7,9,11,15,17,19,21,23,25};
 
void solve(){
   string str;
   getline(cin,str);
 
   int A,B;
   A = B = 0;
    
   for(int i = 0 ; i < 12 ; i++){
      for(int j = 0 ; j < 26 ; j++){
     string tmp = "this";
     for(int k = 0 ; k < 4 ; k++){
        tmp[k] = (a[i]*(tmp[k]-'a')+j)%26 + 'a';
     }
     if(str.find(tmp) != -1){
        A = a[i]; B = j;
        i = 11;j = 26;
        break;
     }
 
     tmp = "that";
     for(int k = 0 ; k < 4 ; k++){
        tmp[k] = (a[i]*(tmp[k]-'a')+j)%26 + 'a';
     }
     if(str.find(tmp) != -1){
        A = a[i]; B = j;
        i = 11;j = 26;
        break;
     }
 
      }
   }
   for(int i = 0 ; i < str.size() ; i++){
      if(str[i] == ' '){
     cout << ' ';
     continue;
      }
      for(int j = 0 ; j < 26 ; j++){
     if(str[i]-'a' == (A*j + B)%26){
        cout << (char)(j + 'a');
        break;
     }
      }
   }
   cout << endl;
}
 
int main(){
   int n;
   cin >> n;
   string tmp;
   getline(cin,tmp);
   for(int i = 0 ; i < n ; i++){
      solve();
   }
   return 0;
}

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

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

int main() {
    int n;
    cin >> n;
    string s;
    while (n) {
        getline(cin, s);
        if (s.size() == 0) continue;
        n --;
        string ans = "";
        for (int a=1; a<26; ++a) {
            if (a % 2 == 0 || a % 13 == 0) continue;
            for (int b=0; b<26; ++b) {
                string t = G(s, a, b);
                if (t.find("this") != string::npos || t.find("that") != string::npos) {
                    ans = t;
                    break;
                }
            }
            if (ans != "") break;
        }
        cout << ans << endl;
    }
    return 0;
}

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

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

int main(void)
{
	int n;
	string a;
	getline(cin, a);
	
	n = atoi(a.c_str());
	for (int i = 0; i < n; i++){
		// cout << "*" << endl;
		string str;
		getline(cin, str);
		
		for (int a = 0; a < 100; a++){
			for (int b = 0; b < 100; b++){
				string tmp = str;
				for (int j = 0; j < str.size(); j++){
						if (tmp[j] == '.') continue;
						if (tmp[j] == ' ') continue;
						if (isdigit(tmp[j])) continue;
						tmp[j] = func(a, b, str[j] - 'a') + 'a';
				}
				
				if (tmp.find("that") != string::npos || tmp.find("this") != string::npos){
					cout << tmp << endl;
					goto a;
				}
			}
		}
	}
	
	a:;
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	for (int i = 0;i < n;i++) {
		string s;
		if(i==0)getchar();
		getline(cin, s);
		int a = s.size();

		for (int j = 0;j < 26;j++) {
			for (int k = 0;k < 26;k++) {
				string sa = s;
				for (int l = 0;l < a;l++) {
					if (sa[l] >= 'a'&&sa[l] <= 'z') {
						int b = sa[l] - 97;
						b =( b*j + k)%26;
						b += 97;
						sa[l] = b;
					}
				}
				size_t za = sa.find("that");
				size_t zb = sa.find("this");
				if (za != string::npos || zb != string::npos) {
					s = sa;
					goto finloop;
				}
			}
		}
	finloop:
		cout << s << endl;
	}
	return 0;
}