Problem:


Caesar Cipher

In cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, 'a' would be replaced by 'b', 'b' would become 'c', 'y' would become 'z', 'z' would become 'a', and so on. In that case, a text:

this is a pen

is would become:

uijt jt b qfo

Write a program which reads a text encrypted by Caesar Chipher and prints the corresponding decoded text. The number of shift is secret and it depends on datasets, but you can assume that the decoded text includes any of the following words: "the", "this", or "that".

Input

Input consists of several datasets. Each dataset consists of texts in a line. Input ends with EOF. The text consists of lower-case letters, periods, space, and end-of-lines. Only the letters have been encrypted. A line consists of at most 80 characters.

You may assume that you can create one decoded text which includes any of "the", "this", or "that" from the given input text.

The number of datasets is less than or equal to 20.

Output

Print decoded texts in a line.

Sample Input

xlmw mw xli tmgxyvi xlex m xsso mr xli xvmt.

Output for the Sample Input

this is the picture that i took in the trip.



Sample input:
xlmw mw xli tmgxyvi xlex m xsso mr xli xvmt.


Sample output:
this is the picture that i took in the trip.

Submission status: Accepted

Solution code:
# Aizu Problem 0017: Caesar Cipher
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

def caesar_decrypt(N, cipher):
    text = ""
    for char in cipher:
        if 'a' <= char <= 'z':
            k = (ord(char) - 97 - N) % 26
            text += chr(97 + k)
        else:
            text += char
    return text


for cipher in sys.stdin:
    cipher = cipher.strip()
    for k in range(26):
        decrypted = caesar_decrypt(k, cipher)
        if "this" in decrypted or "the" in decrypted or "that" in decrypted:
            print(decrypted)
            break

Submission status: Accepted

Solution code:

import string
import sys

def CaesarCipher():
    
    low=string.ascii_lowercase
    
    for cry in sys.stdin: 
        for i in range(1,27):
            
            dec=cry.translate(str.maketrans(low,low[i:]+low[:i]))
    
            if 'this' in dec or 'that' in dec or 'the' in dec:
                print(dec[:-1])
            
                
    
CaesarCipher()

Submission status: Accepted

Solution code:
import sys
for s in map(lambda l: list(l.rstrip()), sys.stdin.readlines()):
    while True:
        for i, c in enumerate(s):
            char_code = ord(c)
            if 97 <= char_code <= 122:
                char_code = char_code+1 if char_code < 122 else 97
                s[i] = chr(char_code)

        _s = "".join(s)
        if "this" in _s or "the" in _s or "that" in _s:
            print(_s)
            break

Submission status: Accepted

Solution code:
#!/usr/bin/env python2
# coding: utf-8

def caesar(s, n):
    d = {}
    for c in (65, 97):
        for i in range(26):
            d[chr(i+c)] = chr((i+n) % 26 + c)

    return "".join([d.get(c, c) for c in s])


while True:
    try:
        encrypt_txt = raw_input()
    except EOFError:
        break

    for i in range(26):
        t = caesar(encrypt_txt, i)
        if  "the" in t or "this" in t or "that" in t:
            print t
            break

Submission status: Accepted

Solution code:
t = ord("t")
z = ord("z")
a = ord("a")
 
def _decode(tv, v):
    spam = ord(v)
    if not (a <= spam <= z):
        return v
 
    x = t - ord(tv)
    y = spam + x
 
    if y > z:
        y = a + (y % z) - 1
    elif y < a:
        y = z - (a - y - 1)
 
    return chr(y)
 
while 1:
    try:
        txt = input()
        for s in [x for x in txt.split() if 3 <= len(x) <= 4]:
            tv = s[0]
            dec_val = ''.join(list(map(lambda x:_decode(tv,x),s)))
 
            if (dec_val in ('this', 'the', 'that')):
                print(''.join(list(map(lambda x:_decode(tv,x),txt))))
                break
    except:
        break

Submission status: Accepted

Solution code:
import sys
a = 'abcdefghijklmnopqrstuvwxyz'
 
for s in sys.stdin:
    for n in range(1, 27):
        t = s[:-1].translate(str.maketrans(a, a[n:] + a[:n]))
        if 'the' in t or 'this' in t or 'that' in t: break
    print(t)

Submission status: Accepted

Solution code:
while True:
    try:
        s = input()
    except:
        break

    alphabet = 'abcdefghijklmnopqrstuvwxyz'

    for i in range(26):
        decoded_s = ''
        for j in range(len(s)):
            if s[j] not in alphabet:
                decoded_s += s[j]
                continue

            decoded_s += alphabet[alphabet.index(s[j]) - i]

        if 'the' in decoded_s or 'this' in decoded_s or 'that' in decoded_s:
            break

    print(decoded_s)

Submission status: Accepted

Solution code:
import sys

for line in sys.stdin:
  if line == '\r' or line == '\n':
    break
  slist = list(line)
  slist.pop()
  while True:
    for i in range(len(slist)):
      if slist[i] == ' ' or slist[i] == '.' or slist[i] == ',':
        continue
      elif slist[i] == 'z':
        slist[i] = 'a'
      else:
        slist[i] = chr(ord(slist[i]) + 1)
    s = ''.join(slist)
    if "the" in s or "this" in s or "that" in s:
      print(s)
      break

Submission status: Accepted

Solution code:
while True:
    try:
        s = input()
        for i in range(27):
            ans = ""
            for j in range(len(s)):
                ch = s[j]
                if "a" <= ch <= "z":
                    ans += chr((ord(ch) - ord("a") + i)%26 + ord("a"))
                else:
                    ans += ch
            if "this" in ans or "that" in ans or"the" in ans:
                print(ans)
                break
    except:
        break

Submission status: Accepted

Solution code:
def ShiftCharacter(str):
    plaintext=""

    for ch in list(str):
        if 'a' <= ch <= 'z':
            plaintext += chr((ord(ch)-ord('a') + 1) % 26 + ord('a'))
        else:
            plaintext +=ch
    return plaintext

def Match(str):
    fg = 0
    if (str=="the") or (str=="this") or (str=="that"):
        fg = 1
    return fg


while True:
    try:
        flag =0
        word=raw_input().split()
        if len(word)==0:
            break
        while (flag==0):
    #try:
        #print "aaaaa"
            for i in range(0,len(word)):
                word[i]=ShiftCharacter(word[i])
                #print word[i]
            for j in range(0,len(word)):
                if Match(word[j]) == 1:
                    flag = 1
                    break
                else:
                    continue
            if flag==1:
                for k in range(0,len(word)-1):
                    print word[k],
                print word[len(word)-1]
    except:
        break

Submission status: Accepted

Solution code:
import math
import re

def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
for l in range(len(N)):
    S = list(N[l])
    ans = ""
    for d in range(26):
        for i in range(len(S)):
            if ord('a') <= ord(S[i]) and ord(S[i]) < ord('z'):
                S[i] = chr(ord(S[i])+1)
            elif ord(S[i]) == ord('z'):
                S[i] = 'a'
        s = "".join(S)
        s = s.replace('.','')
        test = s.split()
        for i in range(len(test)):
            if test[i] == "the" or test[i] == "that" or test[i] == "this":
                ans = "".join(S)
        if ans != "":
            break
    print(ans)

Submission status: Accepted

Solution code:
import string
strings = string.ascii_lowercase
clues = [(19, 7, 8, 18), (19, 7, 0, 19), (19, 7, 4)]
while True:
    try:
        data = input()
    except:
        break
    for word in data.split():
        if len(word) == 4 or 3:
            dif = 19 - (ord(word[0]) - 97)
            enc = ["" for _ in range(26)]
            for k, v in zip([i for i in range(dif, dif+26)], strings):
                enc[k%26] = v
            candidate = tuple(enc.index(c) for c in word)
            try:
                clues.index(candidate)
            except:
                continue
            break
    ans = ""
    for c in data:
        try:
            ans += strings[enc.index(c)]
        except:
            ans = ans + "." if c == "." else ans + " "
    print(ans)

Submission status: Accepted

Solution code:
import sys
a='abcdefghijklmnopqrstuvwxyz'
for b in sys.stdin:
 b=b.strip()
 for i in range(26):
  c=''.join(a[ord(e)-97-i]if e in a else e for e in b)
  if any(('the'in c,'this'in c,'that'in c)):print(c)

Submission status: Accepted

Solution code:
import sys
a='abcdefghijklmnopqrstuvwxyz'
for b in sys.stdin:
 for i in range(26):
  c=''.join(a[ord(e)-97-i]if e in a else e for e in b)
  if any(('the'in c,'this'in c,'that'in c)):print(c.strip())

Submission status: Accepted

Solution code:
import sys
for b in sys.stdin:
 for i in range(26):
  c=''.join([e,chr((ord(e)-96+i)%26+97)][96<ord(e)<123]for e in b)
  if any(('the'in c,'this'in c,'that'in c)):print(c.strip())

Submission status: Accepted

Solution code:
import sys
for b in sys.stdin:
 for i in range(26):
  c=''.join([e,chr((ord(e)-96+i)%26+97)][96<ord(e)<123]for e in b)
  if any(('the'in c,'this'in c,'that'in c)):print(c.strip());break

Submission status: Accepted

Solution code:
l = 'abcdefghijklmnopqrstuvwxyz'

while True:
    try:
        s = input()
    except:
        exit()
    for d in range(1,27):
        t = s[:-1].translate(str.maketrans(l,l[d:] + l[:d]))
        if 'that' in t or 'this' in t or 'the' in t:
            print(t + '.')
            break

Submission status: Accepted

Solution code:
def dec(text,d):
    r=[]
    for i in text:
        c=ord(i)
        if c<65:r.append(i)
        elif c<91:r.append(chr((c-65+d)%26+65))
        else:r.append(chr((c-97+d)%26+97))
    return "".join(r)

while True:
    try:raw=input()
    except:break
    if raw=="":break
    for i in range(26):
        d=dec(raw,i)
        if sum([1 for i in ["the","this","that"] if i in d])>0:break
    print(d)

Submission status: Accepted

Solution code:
import sys
a = "abcdefghijklmnopqrstuvwxyz"
x = str.maketrans(a, a[1:] + a[:1])
for s in sys.stdin:
    while True:
        s = s.translate(x)
        if "the" in s or "that" in s or "this " in s:
            print(s, end = "")
            break

Submission status: Accepted

Solution code:
basea = ord("a")
basez = ord("z")

def slide(c):
  ordc = ord(c)  
  diff = ordc - basea
  diff += 1
  diff %= 26
  return chr(basea + diff)

while True:
  try:
    s = input()
    while True:
      if "the" in s or "this" in s or "that" in s:
        print(s)
        break
      s = "".join([slide(c) if basea <= ord(c) <= basez else c for c in s])
  except EOFError:
    break

Submission status: Accepted

Solution code:
import sys
def l(s,n):
    o=ord(s.lower())
    if not 97<=o<=122:
        return s
    if 97<=o+n<=122:
        if 97<=ord(s)<=122:
            return chr(o+n)
        else:
            return chr(o+n).upper()
    elif o+n>122:
        if 97<=ord(s)<=122:
            return chr(o+n-26)
        else:
            return chr(o+n-26).upper()
    else:
        if 97<=ord(s)<=122:
            return chr(o+n+26)
        else:
            return chr(o+n+26).upper()

for t in sys.stdin:
    s=t[:-1]
    u=s.lower()
    for i in range(0,26):
        cv=lambda y:"".join(map(lambda x:l(x,i),y))
        if cv("this") in u or cv("that") in u or cv("the") in u:
            break
    print("".join(map(lambda x:l(x,-i),s)))

Submission status: Accepted

Solution code:
# AOJ 0017 Caesar Cipher
# Python3 2018.6.21 bal4u

ch = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"

while 1:
	try: s = list(input())
	except: break
	n = len(s)
	for i in range(26):
		t = ['']*n
		for j in range(n):
			if s[j] >= 'a' and s[j] <= 'z':
				t[j] = ch[ord(s[j])-ord('a')+i]
			else: t[j] = s[j]
		tt = ''.join(t)
		t = list(tt.split());
		if ("the" in t) or ("this" in t) or ("that" in t):
			print(tt)
			break

Submission status: Accepted

Solution code:
import sys

def ceaser_decode(text):
    d={}
    line=""
    for n in range(26):
        for c in (65,97):
            for i in range(26):
                d[chr(i+c)] = chr((i+n)%26+c)

        line = "".join([d.get(c,c) for c in text])
        if line.find("the")!=-1 or line.find("this")!=-1 or line.find("that")!=-1:
            break
    return line

for i in sys.stdin.readlines():
    print ceaser_decode(i),

Submission status: Accepted

Solution code:
#! /usr/bin/python

import sys
from string import ascii_lowercase, whitespace

def datasets():
    for line in sys.stdin:
        yield line.strip()

hints = ('the', 'this', 'that')

inclement_chars = lambda cs, n: ''.join(
    [succ_char(c, n) 
    if all([c not in case for case in (whitespace, '.', '\n')]) 
    else c 
    for c in cs])

make_picklist = lambda s: [inclement_chars(s, n) for n in range(1, 27)]

def main():
    for problem in datasets():
        picklist = make_picklist(problem)
        for n, candidate in enumerate(picklist, 1):
            if any([case in candidate for case in hints]):
                break
        print picklist[n-1]


def succ_char(c, n):
    succ_ord = ord(c)+n
    z = ord('z')
    if succ_ord > z:
        succ_ord = ord('a') + (succ_ord - z - 1)
    return chr(succ_ord)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def cipher(char):
    if ord(char) <= ord('y') and ord(char) >= ord('a'):
        return str(chr(ord(char) + 1))
    elif char == 'z':
        return 'a'
    else:
        return char
while True:
    try:
        sent = raw_input()
    except EOFError:
        break
    while((sent.find('the') == -1) and (sent.find('this') == -1) and (sent.find('that') == -1)):
        sent = ''.join(map(cipher, sent))
    print sent

Submission status: Accepted

Solution code:
def trans(s):
    s1=""
    for c in s:
        if c.isalpha():
            s1+=chr(ord(c)+1)
        else:
            s1+=c
    return s1.replace("{","a")

while True:
    try:
        s=raw_input()
    except EOFError:
        break
    cnt=0
    the,this,that="the","this","that"

    while True:
        if (the in s) or (this in s) or (that in s):
            print s
            break
        else:
            s=trans(s)

Submission status: Accepted

Solution code:
import sys
def decode(s):
    result=""
    for c in s:
        if not (c==" " or c=="."):
            result+=chr(ord(c)+1)
        else:
            result+=c
    return result.replace(chr(ord("z")+1),"a")
for line in sys.stdin.readlines():
    s=line.strip()
    for i in xrange(ord("z")-ord("a")+1):
        if "the" in s or "that" in s or "this" in s:
            print s
            break
        s=decode(s)

Submission status: Accepted

Solution code:
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
from sys import stdin
from string import ascii_lowercase as letters, maketrans

table = maketrans(letters, letters[1:] + letters[:1])
for line in stdin:
    line = line.strip()
    while True:
        line = line.translate(table)
        if 'the ' in line or 'this ' in line or 'that ' in line:
            break
    print(line)

Submission status: Accepted

Solution code:
'''
Created on Mar 22, 2013

@author: wukc
'''

from sys import stdin 

def shift(s):
    return ["".join([chr(97+(ord(x)-97+t)%26) if x.islower() else x for x in s]) for t in range(26)]

target=["this","the","that"]

for s in stdin:
    for x in shift(s):
        if sum(map(x.count,target))>0:
            print(x[:-1])

Submission status: Accepted

Solution code:
alpha = 'abcdefghijklmnopqrstuvwxyz'
alp_num = dict(zip(alpha,range(26)))
num_alp = dict(zip(range(26),alpha))
alp_num[' ']=' ' ; num_alp[' ']=' ' ; alp_num['.']='.' ; num_alp['.']='.'
while True:
	try:
		cipher = raw_input()
		numcipher = [alp_num[val] for val in cipher]
		while True:
			cipher = ''
			for val in numcipher: cipher += str(num_alp[val])
			if 'the'in cipher or 'this'in cipher or 'that'in cipher:
				print cipher; break
			else: 
				numcipher2 = []
				for val in numcipher:
					if val == ' ': numcipher2.append(' ')
					elif val == '.': numcipher2.append('.')
					elif val == 25: numcipher2.append(0)
					else: numcipher2.append(val+1)
				numcipher = numcipher2
				continue
	except: break

Submission status: Accepted

Solution code:
import sys
a=lambda x: [''.join([chr(97+(ord(i)-97+j)%26) if i.islower() else i for i in x]) for j in range(26)]
value=['this','that','the']
for s in sys.stdin:
    for i in a(s):
        if sum(map(i.count,value))>0:
            print(i[:-1])

Submission status: Accepted

Solution code:

import sys
import re


def shift(lis):
    a = lis.pop()
    lis.insert(0, a)
    return lis


class Caesar:
    def __init__(self, n):
        a = list("abcdefghijklmnopqrstuvwxyz")
        b = list("abcdefghijklmnopqrstuvwxyz")
        for i in range(n):
            b = shift(b)
#        self.table = map((lambda x, y: (x, y)), a, b)
        self.table = zip(a, b)

    def lookup(self, c):
        for p in self.table:
            if c == p[0]:
                c = p[1]
                break
        return c

    def decrypt(self, str):
        result = map(self.lookup, str)
        return "".join(result)



#input_file = open(sys.argv[1], "r")
r = re.compile("the|this|that")

#for line in input_file:
for line in sys.stdin:
    line = line.rstrip("\r\n")
    for n in range(1,27):
        caesar = Caesar(n)
        result = caesar.decrypt(line)
        m = r.findall(result)
        if not len(m) == 0:
#            print m
            break
    print result

Submission status: Accepted

Solution code:
def rot(s):
    x=""
    for c in s:
        tmp = ord(c)-ord("a")
        if "a"<=c<="z":
            x += chr((tmp+1) % 26 + ord("a"))
        else:
            x += c
    return x
    
while True:
    try:
        s = raw_input()
        f = False
        for i in range(26):
            for word in s.split():
                if word=="the" or word=="this" or word=="that":
                    f=True
                    break
            if f: break
            else: s=rot(s)
        print s
    except:
        break

Submission status: Accepted

Solution code:
def rot(s):
    x=""
    for c in s:
        tmp = ord(c)-ord("a")
        if "a"<=c<="z":
            x += chr((tmp+1) % 26 + ord("a"))
        else:
            x += c
    return x
    
def check(s):
    for word in s.split():
        if word=="the" or word=="this" or word=="that":
            return True
    else: return False

while True:
    try:
        s = raw_input()
        f = False
        for i in range(26):
            if check(s):break
            else: s=rot(s)
        print s
    except:
        break

Submission status: Accepted

Solution code:
while True:
    try:
        s = raw_input()
        for i in range(26):
            r = ''
            for c in s:
                if c.islower():
                    n = ord(c) - ord('a') + i
                    n = n % 26
                    r += chr(n + ord('a'))
                else:
                    r += c
            if 'the' in r or 'this' in r or 'that' in r:
                print r
                break
    except EOFError:
        break

Submission status: Accepted

Solution code:
#!/usr/bin/python

import sys

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

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

def main():
	for crypt in sys.stdin:
		for i in xrange(1, 27):
			decrypt = decryptor(crypt.strip(), i)
			if (decrypt.find('the') != -1
				or decrypt.find('this') != -1
				or decrypt.find('that') != -1):
				print decrypt
				break

def decryptor(crypt, offset):
	global atoi
	global itoa

	decrypt = ''

	for c in crypt:
		if (c == ' ' or c == ',' or c == '.' or c == "\n"):
			decrypt += c
		else:
			code = atoi[c]
			code -= offset
			if (code <= 0 ):
				code = 26 + code

			decrypt += str(itoa[code])

	return decrypt

main()

Submission status: Accepted

Solution code:
b = ["the", "this", "that"]
while 1:
        try:
                a = raw_input()
        except EOFError:
                break
        for y in range(26):
                for x in b:
                        if x in a:
                                print a
                                break
                a = list(a)
                for x in range(len(a)):
                        if a[x] == "z":
                                a[x] = "a"
                        elif "a" <= a[x] < "z":
                                a[x] = chr(ord(a[x])+1)
                a = "".join(a)

Submission status: Accepted

Solution code:
import sys,string
t = string.maketrans('abcdefghijklmnopqrstuvwxyz','bcdefghijklmnopqrstuvwxyza')
for s in sys.stdin:
	s = s.strip()
	while not ('the' in s or 'this' in s or 'that' in s):
		s = s.translate(t)
	print s

Submission status: Accepted

Solution code:
import sys

lineNumber = 0
#for line in [ "xlmw mw xli tmgxyvi xlex m xsso mr xli xvmt." ]:
for line in sys.stdin.readlines():
    lineNumber += 1

    # get data
    # List = map(float, line.strip().split(","))

    s = line.strip()

    for i in xrange(1, 26+1):
        for idx in xrange( len(s) ):
            n = ord(s[idx])
            if n < 97 or n >= 97+26: continue
            n += - 97 + 1
            n %= 26
            s = s[:idx] + chr(n + 97) + s[idx+1:]
        if "this" in s or "that" in s or "the" in s: break

    print s

Submission status: Accepted

Solution code:
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
sign = [" ", ".", "," ,":"]

while True:
    try:
        word = raw_input()
        for key in range(26):
            for i in range(len(word)):
                if not word[i] in sign:
                    ref = alpha.index(word[i])
                    word = word[:i]+alpha[(ref+1)%26]+word[i+1:]
            if word.count("the ")>=1 or word.count("that")>=1 or word.count("this")>=1:
                print word
    except:
        break

Submission status: Accepted

Solution code:
import sys
alphabet = 'abcdefghijklmnopqrstuvwxyz'
def shift(arg):
    tmp = arg.rstrip()
    while True:
        res = ''
        for c in tmp:
            if c in alphabet:
                if c == 'a': res += 'z'
                else: res  += chr(ord(c)-1)
            else: res += c
        if 'the' in res or 'this' in res or 'that' in res:
            return res
        tmp = res
for trg in sys.stdin:
    print shift(trg)

Submission status: Accepted

Solution code:
import sys
def decode(s):
    x=""
    for c in s:
        if not (c==" " or c=="."):
            x+=chr(ord(c)+1)
        else:
            x+=c
    return x.replace(chr(ord("z")+1),"a")
for s in sys.stdin.readlines():
    for i in xrange(ord("z")-ord("a")+1):
        if "the" in s or "that" in s or "this" in s:
            print s[:-1]
            break
        s=decode(s)

Submission status: Accepted

Solution code:
import sys
def decode(s):
    x=""
    for c in s:
        if c in " .":
            x+=c
        else:
            x+=chr(ord(c)+1)
    return x.replace(chr(ord("z")+1),"a")

for s in sys.stdin.readlines():
    for i in xrange(ord("z")-ord("a")+1):
        if "the" in s or "that" in s or "this" in s:
            print s[:-1]
            break
        s=decode(s)

Submission status: Accepted

Solution code:
import sys
def decode(s):
    x=""
    for c in s:
        if c in " .": x+=c
        else: x+=chr(ord(c)+1)
    return x.replace(chr(ord("z")+1),"a")

for s in sys.stdin.readlines():
    for i in range(26):
        if "the" in s or "that" in s or "this" in s:break
        s=decode(s)
    print s[:-1]

Submission status: Accepted

Solution code:
import sys
A="abcdefghijklmnopqrstuvwxyza"
def decode(s):
    x=""
    for c in s:
        if c in A: x+=A[A.index(c)+1]
        else: x+=c
    return x

for s in sys.stdin.readlines():
    for i in range(26):
        if "the" in s or "that" in s or "this" in s:break
        s=decode(s)
    print s[:-1]

Submission status: Accepted

Solution code:
import sys
A="abcdefghijklmnopqrstuvwxyza"
def rot(s):
    x=""
    for c in s:
        if c in A:x+=A[A.index(c)+1]
        else:x+=c
    return x
 
for s in sys.stdin.readlines():
    for i in range(26):
        if "the" in s or "that" in s or "this" in s:break
        s=rot(s)
    print s[:-1]

Submission status: Accepted

Solution code:
import sys,string
A="abcdefghijklmnopqrstuvwxyz"
tbl=string.maketrans(A,A[1:]+A[0])
for s in sys.stdin.readlines():
    while not("the" in s or "that" in s or "this" in s):
        s=s.translate(tbl)
    print s[:-1]

Submission status: Accepted

Solution code:
import sys
A="abcdefghijklmnopqrstuvwxyza"
def rot(s):
    x=""
    for c in s:
        if c in A: x+=A[A.index(c)+1]
        else: x+=c
    return x
  
for s in sys.stdin.readlines():
    while not("the" in s or "that" in s or "this" in s):
        s=rot(s)
    print s[:-1]

Submission status: Accepted

Solution code:
import sys,string
A="abcdefghijklmnopqrstuvwxyza"
tbl=string.maketrans(A[:-1],A[1:])
for s in sys.stdin.readlines():
    while not("the" in s or "that" in s or "this" in s):
        s=s.translate(tbl)
    print s[:-1]

Submission status: Accepted

Solution code:
import sys,string
A="abcdefghijklmnopqrstuvwxyza"
tbl=string.maketrans(A[:-1],A[1:])
for s in sys.stdin:
    while not("the" in s or "that" in s or "this" in s):
        s=s.translate(tbl)
    print s[:-1]

Submission status: Accepted

Solution code:
import string, sys

alpha = 'abcdefghijklmnopqrstuvwxyza'
tbl = string.maketrans(alpha[:-1], alpha[1:])

for s in sys.stdin:
	while not('the' in s or 'that' in s or 'this' in s):
		s = s.translate(tbl)
	print s[:-1]

Submission status: Accepted

Solution code:
import sys,string
A = 'abcdefghijklmnopqrstuvwxyza'
rot = string.maketrans(A[1:], A[:-1])
for line in sys.stdin:
    line = line[:-1]
    while 1:
        if line.count("the") or line.count("this") or line.count("that"):
            print line
            break
        line = line.translate(rot)

Submission status: Accepted

Solution code:
def decode(string, num):
    a, z = ord('a'), ord('z')
    return ''.join([chr(((ord(s) - a) + num) % 26 + a) if a <= ord(s) <= z else s for s in string])


while 1:
    try:
        line = raw_input()
        for i in range(26):
            tmp = decode(line, i)
            for x in tmp.split():
                x = x.strip('.')
                if 'this' in x or 'the' in x or 'that' in x:
                    print tmp
                    break
    except:
        break

Submission status: Accepted

Solution code:
a = [['the'], ['this'], ['that']]
for i in range(25):
    for b in a:
        s = ''
        for c in b[-1]:
            s += chr((ord(c) - ord('a') + 1) % 26 + ord('a'))
        b.append(s)


def f(s):
    for b in a:
        for i in range(26):
            if s.find(b[i]) != -1:
                t = ''
                for c in s:
                    if c.isalpha():
                        t += chr((ord(c) - ord('a') - i + 26) % 26 + ord('a'))
                    else:
                        t += c
                return t
    return None

try:
    while True:
        print f(raw_input())
except:
    pass

Submission status: Accepted

Solution code:
import string, sys

alpha = 'abcdefghijklmnopqrstuvwxyza'
tbl = string.maketrans(alpha[:-1], alpha[1:])

for s in sys.stdin:
  while not('the' in s or 'that' in s or 'this' in s):
    s = s.translate(tbl)
  print s[:-1]

Submission status: Accepted

Solution code:
a = 'abcdefghijklmnopqrstuvwxyz'

while True:
    try:
        s = input()
    except:
        break
    for n in range(1, 27):
        t = s.translate(str.maketrans(a, a[n:] + a[:n]))
        if 'the' in t or 'this' in t or 'that' in t: break
    print(t)

Submission status: Accepted

Solution code:
import sys
a = 'abcdefghijklmnopqrstuvwxyz'

for s in sys.stdin:
    for n in range(1, 27):
        t = s[:-1].translate(str.maketrans(a, a[n:] + a[:n]))
        if 'the' in t or 'this' in t or 'that' in t: break
    print(t)

Submission status: Accepted

Solution code:
while True :
    try :
        string = input()
    except EOFError :
        break
    
    for i in range(26) :
        new_string = []
        for j in range(len(string)) :
            if 97 <= ord(string[j]) <= 122 :
                x = ord(string[j]) + i
                if x > 122 :
                    x -= 26
                new_string.append(chr(x))
            else :
                new_string.append(string[j])
        new_string = ''.join(new_string)
        if 'the' in new_string or 'this' in new_string or 'that' in new_string :
            print(new_string)
            break

Submission status: Accepted

Solution code:
def rot(s, n):
    anslet = ''
    for let in s:
        if let in alp:
            anslet = anslet + chr(ord('a') + (ord(let) - ord('a') + n) % 26)
        else:
            anslet = anslet + let

    return anslet

alp = 'abcdefghijklmnopqrstuvwxyz'

while True:
    try:
        letlst = input()

    except:
        break

    for i in range(27):
        word = rot(letlst, i)
        if ('this' in  word) or('that' in word) or ('the' in word):
            num = i

    letlst = rot(letlst, num)
    print(letlst)

Submission status: Accepted

Solution code:
def slide(c):
    c = ord(c) + 1
    if c > ord('z'):
        c = ord('a')
    return chr(c)
    
while 1:
    try:
        s = input()
        ans = ""
        while 1:
            if "the" in s or "this" in s or "that" in s:
                print(s)
                break
            for i in range(0,len(s)):
                if ord(s[i]) >= ord('a') and ord(s[i]) <= ord('z'):
                    ans += slide(s[i])
                else:
                    ans += s[i]
            s = ans
            ans = ""
    except:
        break

Submission status: Accepted

Solution code:
ca = ord('a')
def convert(s, d):
    res = []
    for c in s:
        if c not in ' .':
            c = chr(((ord(c) - ca + d) % 26) + ca)
        res.append(c)
    return "".join(res)
for line in open(0).readlines():
    s = line.strip()
    for d in range(26):
        s0 = convert(s, d)
        if "the" in s0 or "this" in s0 or "that" in s0:
            print(s0)
            break

Submission status: Accepted

Solution code:

def cipher(s, k):
    l = list(s)
    r = []
    for i in l:
        if i.islower():
            i = chr((ord(i) - ord('a') + k)%26 + ord('a'))
        r.append(i)
    return "".join(r)

while True:
    wordset  = { "this", "that", "the" }
    try:
        s = input()

    except EOFError:
        break

    for i in range(0,26):
        t = cipher(s,i)
        w = set(t.split())
        if len(w & wordset ) > 0:
            print(t)
            break

Submission status: Accepted

Solution code:
if __name__ == '__main__':

	A = "abcdefghijklmnopqrstuvwxyz"

	while True:
		try:
			line = input()

			for d in range(1,27):
				t = line.translate(str.maketrans(A,A[d:] + A[:d]))
				if 'the' in t or 'this' in t or 'that' in t:
					print(t)
					break

		except EOFError:
			break