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, "")
}

Python: #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)

from sys import stdin
from string import ascii_lowercase
from itertools import count

def gcd(m, n):
    m, n = sorted([m, n])
    while n:
        m, n = n, m % n
    return m

def encode(char, A, B):
    return chr(((A * (ord(char) - 97) + B) % 26) + 97)

def solve(words):
    for a in (i for i in count(0) if gcd(i, 26) == 1):
        for b in range(26):
            for word in words:
                that = ''.join(encode(c, a, b) for c in 'that')
                if word == that:
                    return (a, b)
                this = ''.join(encode(c, a, b) for c in 'this')
                if word == this:
                    return (a, b)

def main():
    for _ in range(int(stdin.readline())):
        line = stdin.readline()
        a, b = solve([s for s in line.split() if len(s) == 4])
        d = {encode(c, a, b): c for c in ascii_lowercase}
        d[b' '] = b' '
        print(''.join(d[c] for c in line))

if __name__ == '__main__':
    main()

Python: z='abcdefghijklmnopqrstuvwxyz'
for _ in[0]*int(input()):
 e=input()
 for i in range(1,26,2):
  for j in range(26):
   a=''.join(z[(z.index(c)*i+j)%26]if c in z else c for c in e)
   if'that'in a or'this'in a:print(a);break

Python: import sys
f = sys.stdin


import string

OFFSET = ord('a')

def to_gamma(c):
    return ord(c) - OFFSET

def from_gamma(gamma, alpha, beta):
    return chr((alpha * gamma + beta) % 26 + OFFSET) 

def affine(c, alpha, beta):
    return from_gamma(to_gamma(c), alpha, beta)


# g[0]==g[3]である前提
def search_that(w):
    b = to_gamma(w[2])
    for a in range(26):
        if w[0] == affine('t',a,b) and w[1] == affine('h',a,b):
            return a, b
    return -1, -1

def search_this(g):
    a = (to_gamma(w[0]) - to_gamma(w[3]) + 26) % 26
    for b in range(26):
        if w[0] == affine('t',a,b) and w[1] == affine('h',a,b) and w[2] == affine('i',a,b) and w[3] == affine('s',a,b):
            return a, b
    return -1, -1

def search(w):
    if w[0] == w[3]:
        return search_that(w)
    else:
        return search_this(w)

n = int(f.readline())
for i in range(n):
    line = f.readline().strip()
    words = [word for word in line.split() if len(word) == 4]
    for word in words:
        a, b = search(word)
        if a != -1:
            print(line.translate(str.maketrans(''.join([affine(c, a, b) for c in string.ascii_lowercase]), string.ascii_lowercase)))
            break

Python: n=int(input())
#最後に97を足せばよい
for i in range(n):
    cty=list(input())
    #αは26と互いに素
    con=[1,3,5,7,9,11,13,15,17,19,21,23,25]
    for alf in con:
        for bet in range(26):
            tmp=0
            voca=[]
            new=[]
            while tmp<len(cty):
                #単語ごとに区切る
                if ord(cty[tmp])<97:
                    new.append(''.join(voca))
                    #print(new)
                    voca=[]
                else:
                    voca.append(chr(((alf*(int(ord(cty[tmp])-97))+bet)%26)+97))
                tmp+=1
            new.append(''.join(voca))
            if 'that'in new or 'this'in new:
                for k in range(len(new)):
                    if k==len(new)-1:
                        print(''.join(new[k]))
                    else:
                        print(''.join(new[k]), end=' ')

Python: # Edit : 2014/11/16
# Lang : Python3
# Time : 00.  s
# judge: not Accepted

# File: pc0021.py

from itertools import product


if __name__ == "__main__":

    mycode0 = "abcdefghijklmnopqrstuvwxyz"
    mycode1 = {
        "a": 0,
        "b": 1,
        "c": 2,
        "d": 3,
        "e": 4,
        "f": 5,
        "g": 6,
        "h": 7,
        "i": 8,
        "j": 9,
        "k": 10,
        "l": 11,
        "m": 12,
        "n": 13,
        "o": 14,
        "p": 15,
        "q": 16,
        "r": 17,
        "s": 18,
        "t": 19,
        "u": 20,
        "v": 21,
        "w": 22,
        "x": 23,
        "y": 24,
        "z": 25,
    }

    nset = int(input())
    for i in range(0, nset):

        inl = input()

        for a, b in product(range(1, 26, 2), range(1, 26)):
            outl = ""
            if a == 13:
                continue
            # print(a, b)

            for i in range(0, len(inl)):
                if inl[i] == " ":
                    # print(" ")
                    outl += " "
                else:
                    # print(inl[i], mycode1[inl[i]], mycode0[mycode1[inl[i]]])
                    decode = (a * mycode1[inl[i]] + b) % 26
                    #print(mycode0[decode])
                    #outl[i] = mycode0[decode]
                    outl += mycode0[decode]
            if "this" in outl or "that" in outl:
                print(outl)
                continue

                #

Python: E = 10**-10
def decy(a):
    return [ord(i)-97 for i in a]
def encr(a):
    return "".join([chr(i+97) for i in a])
def deaffin(j,a,b):
    cont_ = 1
    for i in range(100):
        if cont_ == 0:
            break
        elif ((j-b+26*i)/a)//1 == (j-b+26*i)/a:
            cont_ = 0
            return int((j-b+26*i)/a)%26
n = int(input())
for _ in range(n):
    sen = input()
    words = sen.split()
    wordsl = [len(i) for i in words]
    wordsn = [decy(i) for i in words]
    fourn = []
    for i in range(len(wordsl)):
        if wordsl[i] == 4:
            fourn.append(wordsn[i])
    a_ = 0
    b_ = 0
    cont = 1
    for a in [1,3,5,7,9,11,15,17,19,21,23,25]:
        if cont != 0:
            for b in range(26):
                if cont != 0:
                    for i in fourn:
                        deco = [chr(deaffin(j,a,b)+97) for j in i]
                        if deco == ["t","h","i","s"] or deco == ["t","h","a","t"]:
                            a_ = a
                            b_ = b
                            cont = 0
                            break
    dec_wordsn = [[deaffin(j,a_,b_) for j in i] for i in wordsn]
    dec_words = [encr(i) for i in dec_wordsn]
    print(" ".join(dec_words))

Python: z='abcdefghijklmnopqrstuvwxyz'
e=lambda x,i,j:z[(z.index(x)*i+j)%26]
def f():
 for i in range(1,26,2):
  for j in range(26):
   if''.join(e(c,i,j)for c in'that')in s or''.join(e(c,i,j)for c in'this')in s:return(i,j)
for _ in[0]*int(input()):
 s=input()
 k=f()
 print(s.translate(str.maketrans(''.join(e(c,*k)for c in z),z)))

Python: def affine(word, alpha, beta):
    word = list(word)
    for i in range(len(word)):
        word[i] = albs[(albs.index(word[i]) * alpha + beta) % 26]
    return ''.join(word)
albs = 'abcdefghijklmnopqrstuvwxyz'
alphas = [1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25]
betas = list(range(26))
for _ in range(int(input())):
    words = input().split(' ')
    for alpha in range(26):
        for beta in range(26):
            test = list(map(lambda x: affine(x, alpha, beta), words))
            if 'that' in test or 'this' in test:
                print(*test)
                break
        else:
            continue
        break