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 <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
using namespace std;
#define M_PI 3.141592
#define toRad 2.0*M_PI/360.0
#define inin(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" "<<x<<endl;
int euclid(int a, int b)
{
	if (a < b)swap(a, b);
	if (b == 0)return a;
	else return euclid(b, a%b);
}
char hoge(int a)
{
	return 'a' + a;
}
bool check(string a)
{
	if (a.find("that", 0) != string::npos||a.find("this",0)!=string::npos)
	{
		return true;
	}
	return false;
}
int main()
{
	int n;
	cin >> n;
	cin.ignore();
	while (n--)
	{
		string a;
		bool ok = true;
		getline(cin, a); cin.ignore();
		cout << a << endl;
		for (int i = 0;ok; i++)
		{
			if (euclid(i, 26) != 1)continue;
			for (int l = 0; l <= 25&&ok; l++)
			{
				for (int k = 0; k <= 25&&ok; k++)
				{
					int j = (i*l + k)%26;
					if (hoge(j) == a[0])
					{
						string ans = "";
						for (int o = 0; o < a.size(); o++)
						{
							if ('a' <= a[o] && a[o] <= 'z')
							{
								for (int u = 0; u <= 25; u++)
								{
									int h = i*u + k;
									h %= 26;
									if (hoge(h) == a[o])
									{
										ans += hoge(u);
										break;
									}
								}
							}
							else
							{
								ans += " ";
							}
						}
						if (check(ans))
						{
							cout << ans << endl;
							ok = false;
						}
					}
				}
			}
		}

	}
}

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

#define rep(a, b, i) for(int i = a; i < b; i++)

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

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

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

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

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

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 << tmp << ((v+1)==s.end() ? "\n" : " ");
    }
    //    cout << "\b" << endl;
  }

  return 0;
}

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

char dec(int a, int b, char c)
{
	if(c==' ')
		return ' ';

	int tmp = c - 'a';
	return 'a'+((a*tmp+b)%26);
}

int main(void)
{
	int i, j, n;
	cin >> n;
	string str;
	string ans = "";

	for(i=0; i<n; i++)
	{
		getline(cin,str);
		int a = 0, b = 0;
		for(a=0; a<26; a++){
			for(b=0; b<26; b++){
				for(j=0; j<str.size(); j++)
				{
					ans += dec(a,b,str[j]);
				}

				string::size_type index;
				index = ans.find("this");
				if(index != string::npos)
				{
					cout << ans << endl;
					ans = "";
					continue;
				}

				index = ans.find("that");
				if(index != string::npos)
				{
					cout << ans << endl;
					ans = "";
					continue;
				}
				ans = "";
			}
		}
	}
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<string.h>


#define MAX_STR 257
#define ALFA_NUM 26

using namespace std;

int gcd(int);

int main(){

	int n;
	char str[MAX_STR],fstr[MAX_STR];
	bool flag;
	
	scanf("%d",&n);
	
	for(int m=0;m<n;m++){
		flag=true;
		//fgetsの入力がsizeof(str)を超えたら捨てる
		fflush(stdin);
				
		fgets(str,sizeof(str),stdin);
		
		
		for(int i=0;i<100;i++){
			if(gcd(i)==1){
				for(int j=0;j<26;j++){
				
					memset(fstr,'\0',sizeof(fstr));
					
					for(int k=0;str[k]!='\0' && k<sizeof(str);k++){
						
						if(str[k]!='\n' && str[k]!=' '){
							fstr[k]=((i*(str[k]-'a')+j)%ALFA_NUM)+'a';
						}
						else if(str[k]!='\n'){
							fstr[k]=str[k];
						}					
					}
					
					if(strstr(fstr,"that")!=NULL||strstr(fstr,"this")!=NULL){
						printf("%s\n",fstr);
						flag=false;
					}
				}
			}
		}
	}
}

int gcd(int n){
	int temp,m;
	m=ALFA_NUM;
	if(n>m){
		temp=n;
		n=m;
		m=temp;
	}
	while(1){
		if(n==0){
			return m;
		}
		temp=n;
		n=m%n;
		m=temp;
	}
}