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:
while True:
    try:
        strings=input()

        for i in range(26):
            _strings=""
            for s in strings:
                if ord('a')<=ord(s) and ord(s)<=ord('z'):
                    _strings+=chr((ord(s)-ord('a')+1)%26+ord('a'))
                else:
                    _strings+=s
            strings=_strings
            if "the" in strings or "this" in strings or "that" in strings:
                print(strings)
                break
    except EOFError:
        break

Submission status: Accepted

Solution code:
letters = ['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']
while True:
  try:
    s = input()
  except:
    break
    
  l = len(s)
  for i in range(26):
    t = ""
    for j in range(len(s)):
      c = s[j]
      if 'a' <= c and c <= 'z':
        x = letters.index(c)
        cc = letters[(x + i) % 26]
        t += cc
      else:
         t += c
    if ("the" in t) or ("this" in t) or ("that" in t):
      print(t)

Submission status: Accepted

Solution code:
while True:
  try:
    caesar = input()
  except EOFError:
    break
  for i in range(26):
    raw_letters = []
    for j in range(len(caesar)):
      if caesar[j] == " " or caesar[j] == ".":
        raw_letters.append(caesar[j])
      else:
        letter = ord(caesar[j])+(i+1)
        # 122 is ASCII 'z'
        if letter > 122:
          raw_letters.append(chr(letter-26))
        else:
          raw_letters.append(chr(letter))
    raw_strings = "".join(raw_letters)
    if ('the' in raw_strings) or ('this' in raw_strings) or ('that' in raw_strings):
      print(raw_strings)
      break

Submission status: Accepted

Solution code:
import sys

def caesar(c, n):
	cint = ord(c)
	return chr((cint+n-97)%26+97)

keyword = ['the', 'this', 'that']

for line in sys.stdin:
	slist = line.split()
	indx = 1
	while True:
		decodelist = []
		for i in range(0, len(slist)):
			word = ''
			for j in range(0, len(slist[i])):
				if slist[i][j] == '.': word = word+'.'
				else: word = word+caesar(slist[i][j], indx)
			decodelist.append(word)
		anotherlist = []
		for i in range(0, len(decodelist)):
			word = ''
			for j in range(0, len(decodelist[i])):
				if slist[i][j] == '.':
					anotherlist.append(word)
					word = ''
				else: word = word + decodelist[i][j]
			anotherlist.append(word)
		flag = False
		for i in range(0, 3):
			if keyword[i] in decodelist or keyword[i] in anotherlist:
				ans = decodelist[0]
				for j in range(1, len(decodelist)):
					ans = ans + ' ' + decodelist[j]
				print ans
				flag = True
				break
		if flag: break
		indx += 1

Submission status: Accepted

Solution code:
import sys
  
def get_shifted_char(shift_count, ch):
    if ord(ch) >= ord('a') and ord(ch) <= ord('z'):
        return chr(((ord(ch)-71-shift_count) %26 + 97))
    else:
        return ch


for enc_text in sys.stdin:
    text_list = list(filter(lambda s:len(s)==3 or len(s)==4,enc_text.strip().split()))

    shift_count = 1

    while(shift_count < 27):
        flg = False
        for text in text_list:
            decoded = ''.join(list(map(lambda c:get_shifted_char(shift_count,c),text)))
            if decoded == "the" or decoded == "this" or decoded == "that":
                flg = True
        if flg:
            break
        shift_count += 1

    print(''.join(list(map(lambda c:get_shifted_char(shift_count,c),enc_text.strip()))))

Submission status: Accepted

Solution code:
import string
while(1):
    try:
        text = input()
        words = text.split()
        stop = 0
        for i in range(26):
            if stop == 1:
                break
            a = []
            b = []
            for j in words:
                a.append("".join([chr((ord(k) + i - ord("a")) % 26 + ord("a")) if ord(k) >= ord("a") else k for k in j]))
                b.append("".join([chr((ord(k) + i - ord("a")) % 26 + ord("a")) for k in j if ord(k) >= ord("a")]))
            for j in b:
                if j in ["this","that","the"]:
                    print(" ".join(a))
                    stop = 1
                    break
    except EOFError:
        break

Submission status: Accepted

Solution code:
import re

caesar_trans = str.maketrans("abcdefghijklmnopqrstuvwxyz", "zabcdefghijklmnopqrstuvwxy")

while True:
    try:
        i = input()
        while True:
            if re.search("(^| )(the|this|that)(\.| |$)", i) is not None:
                print(i)
                break
            i = i.translate(caesar_trans)
    except EOFError:
        break

Submission status: Accepted

Solution code:
while(1):
    try:
        slist = list(map(str, input().split()))
    except:
        break

    rot = 0
    for i in range(26):
        for s in slist:
            ch = ""
            for c in s:
                if "a" <= c <= "z":
                    g = chr((ord(c) - ord("a") + i) % 26 + ord("a"))
                else:
                    g = c
                ch += g
            if ch == "this" or ch == "that" or ch == "the":
                rot = i
                break
        if rot != 0:
            break

    for i, s in enumerate(slist):
        ch = ""
        for c in s:
            if "a" <= c <= "z":
                g = chr((ord(c) - ord("a") + rot) % 26 + ord("a"))
            else:
                g = c
            ch += g
        if i == len(slist) - 1:
            print(ch)
        else:
            print(ch + " ", end="")

Submission status: Accepted

Solution code:
A = 'abcdefghijklmnopqrstuvwxyz'
 
while True:
    try: s = input()
    except: exit()
 
    for x in range(1, 27):
        ans = s[:-1].translate(str.maketrans(A, A[x:] + A[:x]))
        if 'the' in ans or 'this' in ans or 'that' in ans:
            print(ans + '.')
            break

Submission status: Accepted

Solution code:
import re


def code_shift(c, n_shift):
    return ord('a') + (ord(c) + n_shift - ord('a')) % 26


def get_candidate_plain(cipher, sym_ids, n_shift):
    plain = []
    for i, c in enumerate(cipher):
        if i not in sym_ids:
            plain.append(chr(code_shift(c, n_shift)))
        else:
            plain.append(c)
    plain = ''.join(plain)
    return plain


def decrypt(cipher):
    sym_ids = [m.start() for m in re.finditer(r'[\.\n\s]', cipher)]
    keyword = ['the', 'this', 'that']

    n_shift = 0
    while True:
        plain = get_candidate_plain(cipher, sym_ids, n_shift)
        for k in keyword:
            if plain.find(k) != -1:
                return plain
        n_shift += 1


if __name__ == '__main__':
    while True:
        try:
            cipher = input()
            print(decrypt(cipher))
        except:
            break

Submission status: Accepted

Solution code:
def rot_n(c, n):
    if 'a' <= c and c <= 'z':
        return chr((ord(c) - ord('a') + int(n)) % 26 + ord('a'))
    
    if 'A' <= c and c <= 'Z':
        return chr((ord(c) - ord('A') + int(n)) % 26 + ord('A'))
    
    return c

def rot(s, n):
    c = (rot_n(c, n) for c in s)
    return "".join(c)

while(True):
    try:
        s = input()
        for i in range(1,28):
            d = rot(s,i)
            if "this" in d.split() or "the" in d.split() or "that" in d.split():
                print(d)
    except:
        break

Submission status: Accepted

Solution code:
import sys

idx2alpha = {idx:s for idx,s in enumerate('abcdefghijklmnopqrstuvwxyz .\n')}
alpha2idx = {s:idx for idx,s in enumerate('abcdefghijklmnopqrstuvwxyz .\n')}

def rotate(s):
    idx = [next_w(alpha2idx.get(w)) for w in s]
    new_s = [idx2alpha.get(i) for i in idx]
    return ''.join(new_s)

def next_w(w_idx):
    if 25 < w_idx:
        return w_idx
    w_idx += 1
    return w_idx % 26

def decrypt(s):
    for _ in range(26):
        if 'the' in s or 'this' in s or 'that' in s:
            return s
        else:
            s = rotate(s)
    return 'Failed to decript!'

def run():
    for line in sys.stdin:
        print(decrypt(line.strip()))

if __name__ == '__main__':
    run()

Submission status: Accepted

Solution code:
# Caesar Cipher
s = input()
while 1:
    for diff in range(0,26):
        dec = []
        for c in s:
            chn = ord(c)
            if 97 <= chn < 97+26:
                chn -= 97 + diff
                chn = (chn % 26) + 97
                dec.append(chr(chn))
            else: dec.append(c)
        ss = ''.join(dec)
        if 'the' in ss or 'that' in ss or 'this' in ss:
            print(ss)
            break
    try: s = input()
    except EOFError: break

Submission status: Runtime Error

Solution code:
b = raw_input()
import string
t = string.maketrans("abcdefghijklmnopqrstuvwxyz","bcdefghijklmnopqrstuvwxyza")
while not ('the' in s or 'this' in s or 'that' in s):
    b = b.translate(t)
print b

Submission status: Runtime Error

Solution code:
b = ""
try:
    b += raw_input()
except:
    break
import string
t = string.maketrans("abcdefghijklmnopqrstuvwxyz","bcdefghijklmnopqrstuvwxyza")
while not ('the' in b or 'this' in b or 'that' in b):
    b = b.translate(t)
print b

Submission status: Runtime Error

Solution code:
import sys

while True:
    input = raw_input()
    for i in range(0, 26):
        str = ""
        for c in input:
            if c.isalpha():
                c = chr(ord(c) + i)
                if ord(c) > ord('z'):
                    c = chr(ord('a') - ord('z') + ord(c) - 1)
            str += c
        for word in ["this", "that", "the"]:
            if (str.find(word) != -1):
                print str
                break

Submission status: Runtime Error

Solution code:
  d = {}
    for c in (65, 97):
        for i in range(26):
            d[chr(i+c)] = chr((i+6) % 26 + c)
    print "".join([d.get(c, c) for c in text])

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
def convert_alphabets_to_numlist(word_string):
    "wordを受け取り番号リストに変換する"
    temp=[]
    for char in word_string:
        for num in range(26):
            if char==string[num]:
                temp.append(num)
    return temp
    
def plus1_to_num_list(ls):
    "数字化した各単語に1を足す"
    for n in range(len(ls)):
        if ls[n]!=25:
            ls[n] +=1
        elif ls[n]==25:
            ls[n]=0
    return ls
    
def decipher(word_nums):
    "[19, 7, 4]などを受け取る"
    temp=""
    for k in word_nums:
        temp += string[int(k)]
    return temp

string = 'abcdefghijklmnopqrstuvwxyz'                        
hint=['the','this','that']
hint_num=[[19, 7, 4],[19, 7, 8, 18],[19, 7, 0, 19]]

while True:
    cryp=raw_input().split()
    for word in cryp:
        word_nums= convert_alphabets_to_numlist(str(word))
        n=0
        while word_nums not in hint_num and n<26:
            plus1_to_num_list(word_nums)
            n+=1    
    # すべてをn回ずらす
    temp = []
    for word in cryp:
        word_nums=convert_alphabets_to_numlist(str(word))
        for k in range(n):
            plus1_to_num_list(word_nums)
        temp.append(decipher(word_nums))
    if '.' not in cryp[-1]:
        print " ".join(temp)
    else:
        temp[-1] += '.'
        print " ".join(temp)

Submission status: Runtime Error

Solution code:
def convert_alphabets_to_numlist(word_string):
    temp=[]
    for char in word_string:
        for num in range(26):
            if char==string[num]:
                temp.append(num)
    return temp
    
def plus1_to_num_list(ls):
    "plus 1 each item in ls"
    for n in range(len(ls)):
        if ls[n]!=25:
            ls[n] +=1
        elif ls[n]==25:
            ls[n]=0
    return ls
    
def decipher(word_nums):
    "[19, 7, 4]"
    temp=""
    for k in word_nums:
        temp += string[int(k)]
    return temp

string = 'abcdefghijklmnopqrstuvwxyz'                        
hint=['the','this','that']
hint_num=[[19, 7, 4],[19, 7, 8, 18],[19, 7, 0, 19]]

while True:
    cryp=raw_input().split()
    for word in cryp:
        word_nums= convert_alphabets_to_numlist(str(word))
        n=0
        while word_nums not in hint_num and n<26:
            plus1_to_num_list(word_nums)
            n+=1    

    temp = []
    for word in cryp:
        word_nums=convert_alphabets_to_numlist(str(word))
        for k in range(n):
            plus1_to_num_list(word_nums)
        temp.append(decipher(word_nums))
    if '.' not in cryp[-1]:
        print " ".join(temp)
    else:
        temp[-1] += '.'
        print " ".join(temp)

Submission status: Runtime Error

Solution code:
xlmw mw xli tmgxyvi xlex m xsso mr xli xvmt.

Submission status: Runtime Error

Solution code:
import sys

def this(word):
    i=0
    t=[]
    for c in word:
        t.append(ord(c)-ord('this'[i]))
        i+=1
    if(t[0]==t[1] and t[1]==t[2] and t[2]==t[3]):
        return t[0]
    return 30

def that(word):
    i=0
    t=[]
    for c in word:
        t.append(ord(c)-ord("that"[i]))
        i+=1
    if(t[0]==t[1] and t[1]==t[2] and t[2]==t[3]):
        return t[0]
    return 30

def the(word):
    i=0
    t=[]
    for c in word:
        t.append(ord(c)-ord("the"[i]))
        i+=1
    if(t[0]==t[1] and t[1]==t[2]):
        return t[0]
    return 30

for string in sys.stdin:
    for word in string.split(" "):
        if(len(word)==3):
           if the(word) < 30:
               x=the(word)
               break
        if(len(word)==4):
           if this(word) <30:
               x=this(word)
               break
           if that(word) <30:
               x=that(word)
               break
    alpha = 'abcdefghijklmnopqrstuvwx'
    result=""
    for c in string:
        if c in alpha:
            result+=alpha[alpha.find(c)-x]
        else:
            result+=c
    print result

Submission status: Runtime Error

Solution code:
import sys

def this(word):
    i=0
    t=[]
    for c in word:
        t.append(ord(c)-ord('this'[i]))
        i+=1
    if(t[0]==t[1] and t[1]==t[2] and t[2]==t[3]):
        return t[0]
    return 30

def that(word):
    i=0
    t=[]
    for c in word:
        t.append(ord(c)-ord("that"[i]))
        i+=1
    if(t[0]==t[1] and t[1]==t[2] and t[2]==t[3]):
        return t[0]
    return 30

def the(word):
    i=0
    t=[]
    for c in word:
        t.append(ord(c)-ord("the"[i]))
        i+=1
    if(t[0]==t[1] and t[1]==t[2]):
        return t[0]
    return 30

for string in sys.stdin:
    for word in string.split(" "):
        if(len(word)==3):
           if the(word) < 30:
               x=the(word)
               break
        if(len(word)==4):
           if this(word) <30:
               x=this(word)
               break
           if that(word) <30:
               x=that(word)
               break
    alpha = 'abcdefghijklmnopqrstuvwxyz'
    result=""
    for c in string:
        if c in alpha:
            result+=alpha[alpha.find(c)-x]
        else:
            result+=c
    print result[:-1]

Submission status: Runtime Error

Solution code:
s=input()

for _ in range(26):
    if "this " in s or "that " in s or "the " in s:
    print(s)
    break

    s=list(s)
    for i in range(len(s)):
        if ord(s[i]) <= ord("z") and ord(s[i]) >= ord("a"):
            if s[i] != "a":
                s[i] = chr(ord(s[i])-1)
            else:
                s[i] = "z"
    s="".join(s)

Submission status: Runtime Error

Solution code:
s = raw_input()
li = s.split()

for i in li:
	if len(i) == 4 or len(i) == 3:
		a = ord(i[0]) - ord(i[1])
		b = ord(i[1]) - ord(i[2])
		c = ord(i[2]) - ord(i[3])
		
		if a == 12 and b == -1 and c == -10:
			n = ord(i[0]) - ord("t")
			break
		elif a == 12 and b == 3:
			n = ord(i[0]) - ord("t")
			break
		elif a == 12 and b == 7 and c == -19:
			n = ord(i[0]) - ord("t")
			break

o = ""
for c in s:
	if ord(c) >= 97 and ord(c) <= 122:
		o += chr(ord(c) - n)
	else:
		o += c

print(o)

Submission status: Runtime Error

Solution code:
import sys

def check1():
    for string in string_lis:
        char0 = string[0]
        if char0 < 't':
            # +
            length = (alpha.find('t')+1) - (alpha.find(char0)+1)
            plus(string, length)
            # -
            length = (alpha.find(char0)+1) + 6
            minus(string, length)
                
        elif 't' < char0:
            # +
            length = 26 - (alpha.find(char0)+1) + 20
            print alpha.find(char0)+1
            new_str = plus(string, length)
            check(new_str, length, '+')
            # -
            print(1)
            length = (alpha.find(char0)+1) - 20
            new_str = minus(string, length)
            print new_str
            check(new_str, length, '-')
    
def plus(string, length):
    new_str = ''
    for char in string:
        index = alpha.find(char) + length
        if index <= 25:
            new_str += alpha[index]
        else:
            index = index - 26
            new_str += alpha[index]
    
    return new_str
        
def minus(string, length):
    new_str = ''
    for char in string:
        index = alpha.find(char) - length
        if index >= 0:
            new_str += alpha[index]
        else:
            index = 25 + index + 1
            new_str += alpha[index]
            
    return new_str

def check(new_str, length, flag):
    result_lis = []
    print new_str
    if new_str == 'the' or new_str == 'this' or new_str == 'that':
        print 1
        if flag == '+':
            for string in string_lis:
                result_lis.append(plus(string, length))
        elif flag == '-':
            for string in string_lis:
                result_lis.append(minus(string, length))
        
    print ' '.join(result_lis)
    sys.exit()

if __name__ == '__main__':    
    for input_line in sys.stdin:
        input_line = raw_input()
        input_line = input_line.rstrip('.\n')
        print input_line
        alpha = 'abcdefghijklmnopqrstuvwxyz'
        string_lis = input_line.split()
        print string_lis
        check1()

Submission status: Runtime Error

Solution code:
strs='abcdefghijklmnopqrstuvwxyz'      #use a string like this, instead of ord()
def shifttext(shift):
    inp=input('')
    data=[]
    for i in inp:                     #iterate over the text not some list
        if i.strip() and i in strs:                 # if the char is not a space ""
            data.append(strs[(strs.index(i) + shift) % 26])
        else:
            data.append(i)           #if space the simply append it to data
    output = ''.join(data)
    return output
print(shifttext(int(input())))

Submission status: Runtime Error

Solution code:
import string
import sys


def check_exists(word_set, rotate_dict, search):
    for word in word_set:
        rotated_word = ''.join(rotate_dict[s] for s in word)
        if rotated_word == search:
            return True
    return False


for line in sys.stdin:
    s0 = line.strip()
    alphabets = string.ascii_lowercase
    frequency = [t[1] for t in sorted([(s0.count(s), ord(s)) for s in alphabets], reverse=True)]
    freq_chr_offset = (4, 0, 19, 8, 14)
    ss = s0.strip('.').split()
    sl3, sl4 = set(s for s in ss if len(s) == 3), set(s for s in ss if len(s) == 4)

    i, rotate_dict = 0, None
    for order in frequency:
        for offset in freq_chr_offset:
            i = 97 + offset - order
            rotate_dict = {a: b for a, b in zip(alphabets, alphabets[i:] + alphabets[:i])}
            if (check_exists(sl3, rotate_dict, 'the')
                    + check_exists(sl4, rotate_dict, 'this')
                    + check_exists(sl4, rotate_dict, 'that')) > 0:
                break
        else:
            continue
        break

    print(''.join(rotate_dict[s] if s.isalpha() else s for s in s0))

Submission status: Runtime Error

Solution code:
while True:
    try:
        b = input()
    except:
        break
    if 'the' in c or 'this' in c or 'that' in b:
        print(c)
    for i in range(1,26):
        c = ''
        for j in b:
            if(j == 'z'):
                c += ('a')
            elif(str.isalpha(j) == 1):
                c += (chr(ord(j) + 1))
            else:
                c += j
        if 'the' in c or 'this' in c or 'that' in c:
            print(c)
            break
        b = c

Submission status: Runtime Error

Solution code:
def ascii_char(c):
	if c<97:
		c+=26
	elif c>122:
		c-=26
	return c#type int

def judge_the(word):
	length=ord('t')-ord(word[0])
	if ord('h')-ord(word[1])==ord('e')-ord(word[2])==length:
		return True
	else:
		return False


def judge_this(word):
	length=ord('t')-ord(word[0])
	if ord('h')-ord(word[1])==ord('i')-ord(word[2])==ord('s')-ord(word[3])==length:
		return True
	else:
		return False

def judge_that(word):
	length=ord('t')-ord(word[0])
	if ord('h')-ord(word[1])==ord('a')-ord(word[2])==ord('t')-ord(word[3])==length:
		return True
	else:
		return False

def change(string,l):
	string1=""
	for i in range(len(string)):
		C=ord(string[i])+l
		if C<97:
			C+=26
		elif C>122:
			C-=26
		string1+=chr(C) if string[i]!='.' 
	return string1



while True:
	try:
		A=list(map(str,input().split()))
		l=int()
		for i in A:
			if len(i)==3:
				if judge_the(i):
					l=ord('e')-ord(i[2])
					break
			elif len(i)==4:
				if judge_this(i):
					l=ord('i')-ord(i[2])
					break
				elif judge_that(i):
					l=ord('a')-ord(i[2])
					break
		else:
			break#while?????????
		Ans=[""]*len(A)
		for i in range(len(A)):
			Ans[i]=change(A[i],l)

		print(" ".join(Ans))
	except EOFError:
		break

Submission status: Runtime Error

Solution code:
def judge_the(word):
	length=ord('t')-ord(word[0])
	if ord('h')-ord(word[1])==ord('e')-ord(word[2])==length:
		return True
	else:
		return False


def judge_this(word):
	length=ord('t')-ord(word[0])
	if ord('h')-ord(word[1])==ord('i')-ord(word[2])==ord('s')-ord(word[3])==length:
		return True
	else:
		return False

def judge_that(word):
	length=ord('t')-ord(word[0])
	if ord('h')-ord(word[1])==ord('a')-ord(word[2])==ord('t')-ord(word[3])==length:
		return True
	else:
		return False

def change(string,l):
	string1=""
	for i in range(len(string)):
		C=ord(string[i])+l
		if C<97:
			C+=26
		elif C>122:
			C-=26
		string1+=chr(C) if string[i]!='.' 
	return string1



while True:
	try:
		A=list(map(str,input().split()))
		l=int()
		for i in A:
			if len(i)==3:
				if judge_the(i):
					l=ord('e')-ord(i[2])
					break
			elif len(i)==4:
				if judge_this(i):
					l=ord('i')-ord(i[2])
					break
				elif judge_that(i):
					l=ord('a')-ord(i[2])
					break
		else:
			break#while?????????
		Ans=[""]*len(A)
		for i in range(len(A)):
			Ans[i]=change(A[i],l)

		print(" ".join(Ans))
	except EOFError:
		break

Submission status: Runtime Error

Solution code:
#encoding=utf-8

def inp(i):
    split_word = i.split()
    return split_word

def rot(split_word):
    for i in xrange(len(split_word)):
        tako = ""
        if len(split_word[i]) == 4 or len(split_word[i]) == 3:
            num = ord(split_word[i][0]) - ord("t")
            for j in xrange(len(split_word[i])):
                tako +=  chr(ord(split_word[i][j]) - num)
            if tako == "that" or tako == "the" or tako == "this":
                return proce(split_word, num)
        else:
            pass
        num = 0

def proce(split_word, num):
    ans = ""
    for i in xrange(len(split_word)):
        for j in xrange(len(split_word[i])):
            if split_word[i][j] < ord("a") or ord("z") < split_word[i][j]:
                ans += split_word[i][j]
            else:
                ans += str(chr(ord(split_word[i][j]) - num))
        ans += " "
    return ans


if __name__ == "__main__":
    import sys
    for i in sys.stdin:
        word = inp(i)
        ans = rot(word)
        print ans[0:(len(ans) - 1)]

Submission status: Runtime Error

Solution code:
while 1:
    try:
        n=float('inf')
        s=raw_input().strip('.').split()
        for i in xrange(26):
            for j in s:
                r=[]
                for k in j:
                    if ord(k)+i<123:
                        r.append(chr(ord(k)+i))
                    else:
                        r.append(chr(97+ord(k)+i-123))
                if "".join(r)=="this" or "".join(r)=="that" or "".join(r)=="the":
                    n=i
            if n!=float('inf'):
                break
        ans=[]
        for i in s:
            splitans=[]
            for j in i:
                if ord(j)+n<123:
                    splitans.append(chr(ord(j)+n))
                else:
                    splitans.append(chr(97+ord(j)+n-122))
            ans.append(''.join(splitans))
        print(' '.join(ans)+'.')

Submission status: Runtime Error

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

def casar(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])
  

try:
  while True:
    encrypttxt = raw_input()
    for i in range(26):
      t = casar(encrypttxt, i)
      if  "the" in t or "this" in t or "that" in t:
        print t

except EOFError:
  break

Submission status: Runtime Error

Solution code:
import sys

def restore(n,text):
    text_list=list(text)
    for i,j in enumerate(text_list):
        if ord(j)!=46 and ord(j)!=32:
            nw=ord(j)-n
            if nw<97:
                nw=ord(j)-n+26
            text_list[i]=chr(nw)
    for i in text_list:
        print(i,end='')
    print('\n')

def textsa(str):
    str_list=list(str)
    n=len(str_list)
    sa=[]
    for i in range(n-1):
        sa.append((ord(str_list[i+1])-ord(str_list[i]))%26)
    sa.append((ord(str_list[0])-ord(str_list[n-1]))%26)
    return sa

for text in sys.stdin:
    str=list(map(str,text.split()))
    for i in str:
        if textsa(i)==[14,1,10,1] or textsa(i)==[14,19,19,0]:
            n=ord(list(i)[0])-ord('t')
        if textsa(i)==[14,23,15]:
            n=ord(list(i)[0])-ord('t')
    restore(n,text)

Submission status: Runtime Error

Solution code:
import string
import sys

example = string.ascii_lowercase

def make(x, y, z, a, b, c = True) :
    if x - a < 0 : y = 26 + (x - a)
    else : y = x - a
    if x - b < 0 : z = 26 + (z - b)
    else : z = x - b
    if c != True :
        if x - c < 0 : n = 26 + (x - c)
        else : n = x - c
    if c != 0 : return (example[x] + example[y] + example[z])
    else : return (example[x] + example[y] + example[z])
    
def solve(temp, number) :
    new_temp = []
    if number > 19 : number = number - 19
    else : number = 19 - number
    for _ in temp :
        if _ == ' ' or _ == '.' : new_temp.append(_)
        elif _ - number < 0 : new_temp.append(26 + (_ - number))
        else : new_temp.append(_ - number)
    temp = ''
    for _ in new_temp :
        if _ == ' ' or _ == '.' : temp += _
        else : temp += example[_]
    return temp

for input_string in sys.stdin :
    test = input_string
    temp = []
    for _ in test : 
        if _ == ' ' or _ == '.' : temp.append(_)
        else : temp.append(example.index(_))

    check = 0
    the = []
    for _ in range(26) : the.append(make(_, _, _, 12, 15))
    for number, _ in enumerate(the) :
        if _ in test :
            print(solve(temp, number))
            check = 1
    
    if check == 1 :
        this = []
        for _ in range(26) : this.append(make(_, _, _, 12, 13, 24))
        for number, _ in enumerate(this) :
            if _ in test :
                print(solve(temp, number))
                check = 1
    
    if check == 1 :
        that = []
        for _ in range(26) : this.append(make(_, _, _, 12, 13, 24))
        for number, _ in enumerate(this) :
            if _ in test : print(solve(temp, number))

Submission status: Runtime Error

Solution code:
def main():
    ex =[ord(".")]
    answer = ""
    while True:
        try:
            words = input().split()
        except:
            break
        bl = False
        for i in range(1,26):
            ans = ""
            for word in words:
                s = ""
                for string in word:
                    os = ord(string)
                    if os in ex:
                        s = s + string
                    else:
                        if os - i < 97:
                            s += chr(122 - (97 - (os - i)))
                        else:
                            s += chr(os - i)
                if s in ("the", "this", "that", "the.", "this.", "that."):
                  bl = True
                ans += " " + s
            if bl:
                break
        answer.append(ans[1::])
    print(*answer, sep="\n")

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def ascii2num(ascii):
    return ord(ascii) - 96

def num2ascii(num):
    return chr(num + 96)

def slide(word,num):
    return ''.join([num2ascii((ascii2num(ascii) + num) % 26) if ascii != '.' else '.' for ascii in word])

def includekeyword(words):
    for word in words:
        if word in keywords:
            return True
    return False

keywords = ['the', 'this', 'that']


decode = []
for row in stdin:
    words = row.split()
    for num in range(1,27):
        tmp = [slide(word,num) for word in words]
        if includekeyword(tmp):
            decode = tmp
            print(' '.join(decode))

Submission status: Runtime Error

Solution code:
import string
d = {c:ord(c)-97 for c in string.ascii_lowercase}
b = {v:k for k, v in d.items()}
while True:
    try:
        s = input()
    except:
        break
    t = 0
    for token in list(filter(lambda x: len(x) in [3, 4], s[:-1].split())):
        t = d[token[0]]%26-19
        word = ''.join([b[d[c]%26-t] for c in token])
        if word in ['the', 'that', 'this']:
            break
    ans = [' ' if c == ' ' else b[d[c]%26-t] for c in s[:-1]]+['.']
    print(''.join(ans))

Submission status: Runtime Error

Solution code:

import string
def CaesarCipher():
    
    low=str.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)
            
                
    
CaesarCipher()

Submission status: Runtime Error

Solution code:

import string
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)
            
                
    
CaesarCipher()