Problem:


博士の暗号

博  士 : ?D-C'KOPUA

ピーター : どうしたんですか、デビッド博士? わけのわからないことを叫ぶのにはもう慣れましたが、
        今日は文章にすらなっていませんよ。

博  士 : ほれ。

ピーター : なんですか? この表は......ああ、予選の問題にこんなのがありました。表を使って文字を置き換え
       ると文字数が減るんですよね。まさか予選と本選で同じ問題を出して手を抜こうって気じゃないでし
       ょうね。

博  士 : 逆じゃよ。

ピーター : 逆? なるほど、今度は短くした文字列を元に戻そうって問題ですか。ということは「?D-C'KOPUA」の
      文字を、この表を使って「文字」から「符号」に置きかえるんですね......できましたよ。

11111 00011 11101 00010 11110 01010 01110 01111 10100 00000

博  士 : うむ。次はこれじゃ。

ピーター : そうそう、こんな表もありましたね。これを逆に使うんだから「符号」から「文字」に置き換えればいい
          んですね。でも、最初は「11111」ですが表にありませんよ?

博     士 : そういうときは、もっと短くするか、後ろとつなげるかしてみるのだよ。

ピ ー タ ー : じゃあ短くして......あ、 「111」ならあります。じゃあ最初は「P」ですね。そうすると残りは「11」ですが、
            これはぴったり合うのがないから次の「00011」から 1 文字借りて「110」にすればいいんですね。

博     士 : そうそう。つまり「E」だね。

ピ ー タ ー : それで残るのが「0011」なので、これも次から借りて「00111」にして「T」と......。全部できました。最
          後の「0000」は捨てちゃえばいいんですよね?

博     士 : そうじゃ、よろしい。次はこれじゃ。

?D-C'?-C'-LMGZN?FNJKN- WEYN?P'QMRWLPZLKKTPOVRGDI

博     士 : さらにこれじゃ。

?P'QNPY?IXX?IXXK.BI -G?R'RPP'RPOVWDMW?SWUVG'-LCMGQ

博     士 : 仕上げにこうじゃ。

?P'QMDUEQ GADKOQ ?SWUVG'-LCMG?X?IGX,PUL.?UL.VNQQI

ピ ー タ ー : しっかし面倒だなあ。博士、今度は自分でプログラムを作って下さいよ。

  ということで、博士のかわりに、上の文章を置き換えるプログラムを作成してください。

Input

複数のデータセットが与えられます。各データセットとして、１つの文字列（表に含まれる文字からなる 200 文字以下の文字列）が１行に与えられます。入力の終わりまで処理してください。データセットの数は 200 を超えません。

Output

各データセットごとに、変換後の文字列を１行に出力してください。

Sample Input

?D-C'KOPUA

Output for the Sample Input

PETER POTTER



Sample input:
?D-C'KOPUA


Sample output:
PETER POTTER

Submission status: Wrong Answer

Solution code:
while(True):
    try:
        s = input()
    except:
        break
    ec = dict([t,i] for i,t in enumerate("ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?"))
    c = 0
    for i,e in enumerate(s[::-1]):
        c |= ec[e]<<i*5
    c = str(bin(c))[2:]
    dc = {"101":" ","000000":"'","000011":",","10010001":"-","010001":".","000001":"?",
    "100101":"A","10011010":"B","0101":"C","0001":"D","110":"E","01001":"F",
    "10011011":"G","010000":"H","0111":"I","10011000":"J","0110":"K","00100":"L",
    "10011001":"M","10011110":"N","00101":"O","111":"P","10011111":"Q","1000":"R",
    "00110":"S","00111":"T","10011100":"U","10011101":"V","000010":"W","10010010":"X",
    "10010011":"Y","10010000":"Z"}
    ans = ""
    i=0
    while(i<len(c)):
        for j in range(3,9):
            try: ans += dc[c[i:i+j]]; i+=j; break
            except: continue
        else:
            break
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys

def f1(s): return "".join([d0[c] for c in s])

d0={"M":"10010","N":"10011"}
a="ABCD";
for i in range(4): d0[a[i]]=format(i,"02b")
a="EFGHIJKL"
for i in range(8): d0[a[i]]=format(i,"03b")
L0="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
L1=" ',-.?"
L2=" .,-'?"

d={}
a="J,EE,EH,MF,GF,EF,IJ,NG,BB,AB,K,BF,NH,GE,BD,NE,BC,"\
  "AI,NF,NK,AJ,L,NL,CA,AK,AL,NI,NJ,EG,MG,MH,ME".split(",")
for i,e in enumerate(a): d[f1(e)]=(L1+L0)[i]
for s0 in sys.stdin:
  s1="".join([format((L0+L2).index(c),"05b") for c in s0[:-1]])
  s=""
  x=""
  for c in s1:
    if d.has_key(s): x+=d[s]; s=""
    s+=c
  print x

Submission status: Wrong Answer

Solution code:
import sys

def f1(s): return "".join([d0[c] for c in s])

d0={"M":"10010","N":"10011"}
a="ABCD";
for i in range(4): d0[a[i]]=format(i,"02b")
a="EFGHIJKL"
for i in range(8): d0[a[i]]=format(i,"03b")
L0="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
L1=" ',-.?"
L2=" .,-'?"

d={}
a="J,EE,EH,MF,GF,EF,IJ,NG,BB,AB,K,BF,NH,GE,BD,NE,BC,"\
  "AI,NF,NK,AJ,L,NL,CA,AK,AL,NI,NJ,EG,MG,MH,ME".split(",")
for i,e in enumerate(a): d[f1(e)]=(L1+L0)[i]
for s0 in sys.stdin:
  s1="".join([format((L0+L2).index(c),"05b") for c in s0.strip()])
  s=""
  x=""
  for c in s1:
    try: x+=d[s]; s=""
    except: pass
    s+=c
  print x

Submission status: Wrong Answer

Solution code:
import sys

def f1(s): return "".join([d0[c] for c in s])

d0={"M":"10010","N":"10011"}
a="ABCD";
for i in range(4): d0[a[i]]=format(i,"02b")
a="EFGHIJKL"
for i in range(8): d0[a[i]]=format(i,"03b")
L0="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
L1=" ',-.?"
L2=" .,-'?"

d={}
a="J,EE,EH,MF,GF,EF,IJ,NG,BB,AB,K,BF,NH,GE,BD,NE,BC,"\
  "AI,NF,NK,AJ,L,NL,CA,AK,AL,NI,NJ,EG,MG,MH,ME".split(",")
for i,e in enumerate(a): d[f1(e)]=(L1+L0)[i]
for s0 in sys.stdin:
  s1="".join([format((L0+L2).index(c),"05b") for c in s0.strip()])
  s=""
  x=""
  for c in s1:
    try: x+=d[s]; s=""
    except: pass
    s+=c
  if x!=[]: print x

Submission status: Wrong Answer

Solution code:
import sys

def f1(s): return "".join([d0[c] for c in s])

d0={"M":"10010","N":"10011"}
a="ABCD";
for i in range(4): d0[a[i]]=format(i,"02b")
a="EFGHIJKL"
for i in range(8): d0[a[i]]=format(i,"03b")
L0="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
L1=" ',-.?"
L2=" .,-'?"

d={}
a="J,EE,EH,MF,GF,EF,IJ,NG,BB,AB,K,BF,NH,GE,BD,NE,BC,"\
  "AI,NF,NK,AJ,L,NL,CA,AK,AL,NI,NJ,EG,MG,MH,ME".split(",")
for i,e in enumerate(a): d[f1(e)]=(L1+L0)[i]
for s0 in sys.stdin:
  s1="".join([format((L0+L2).index(c),"05b") for c in s0.strip()])
  s=""
  x=""
  for c in s1:
    try: x+=d[s]; s=""
    except: pass
    s+=c
  if x!="": print x

Submission status: Wrong Answer

Solution code:
table = {
	'A': '00000',
	'B': '00001',
	'C': '00010',
	'D': '00011',
	'E': '00100',
	'F': '00101',
	'G': '00110',
	'H': '00111',
	'I': '01000',
	'J': '01001',
	'K': '01010',
	'L': '01011',
	'M': '01100',
	'N': '01101',
	'O': '01110',
	'P': '01111',
	'Q': '10000',
	'R': '10001',
	'S': '10010',
	'T': '10011',
	'U': '10100',
	'V': '10101',
	'W': '10110',
	'X': '10111',
	'Y': '11000',
	'Z': '11001',
	' ': '11010',
	'.': '11011',
	',': '11100',
	'-': '11101',
	"'": '11110',
	'?': '11111',
	3: {
		'101': ' ',
		'110': 'E',
		'111': 'P',
	},
	4: {
		'0101': 'C',
		'0001': 'D',
		'0111': 'I',
		'0110': 'K',
		'1000': 'R',
	},
	5: {
		'01001': 'F',
		'00100': 'L',
		'00101': 'O',
		'00110': 'S',
		'00111': 'T',
	},
	6: {
		'000000': "'",
		'000011': ',',
		'010001': '.',
		'000001': '?',
		'100101': 'A',
		'010000': 'H',
		'000010': 'W',
	},
	8: {
		'10010001': '-',
		'10011010': 'B',
		'10011011': 'G',
		'10011000': 'J',
		'10011001': 'M',
		'10011110': 'N',
		'10011111': 'Q',
		'10011100': 'U',
		'10011101': 'V',
		'10010010': 'X',
		'10010011': 'Y',
		'10010000': 'Z',
	},
}

while True:
	try:
		s1 = input()
		s2 = ''
		s3 = ''
		for c1 in s1:
			s2 += table[c1]
		while True:
			for l in (3, 4, 5, 6, 8):
				for c2 in table[l]:
					if s2.startswith(c2):
						s2 = s2[l:]
						s3 += table[l][c2]
			if s2.find('1') < 0:
				print(s3)
				break
	except EOFError:
		break

Submission status: Wrong Answer

Solution code:
table = {
	'A': '00000',
	'B': '00001',
	'C': '00010',
	'D': '00011',
	'E': '00100',
	'F': '00101',
	'G': '00110',
	'H': '00111',
	'I': '01000',
	'J': '01001',
	'K': '01010',
	'L': '01011',
	'M': '01100',
	'N': '01101',
	'O': '01110',
	'P': '01111',
	'Q': '10000',
	'R': '10001',
	'S': '10010',
	'T': '10011',
	'U': '10100',
	'V': '10101',
	'W': '10110',
	'X': '10111',
	'Y': '11000',
	'Z': '11001',
	' ': '11010',
	'.': '11011',
	',': '11100',
	'-': '11101',
	"'": '11110',
	'?': '11111',
	3: {
		'101': ' ',
		'110': 'E',
		'111': 'P',
	},
	4: {
		'0101': 'C',
		'0001': 'D',
		'0111': 'I',
		'0110': 'K',
		'1000': 'R',
	},
	5: {
		'01001': 'F',
		'00100': 'L',
		'00101': 'O',
		'00110': 'S',
		'00111': 'T',
	},
	6: {
		'000000': "'",
		'000011': ',',
		'010001': '.',
		'000001': '?',
		'100101': 'A',
		'010000': 'H',
		'000010': 'W',
	},
	8: {
		'10010001': '-',
		'10011010': 'B',
		'10011011': 'G',
		'10011000': 'J',
		'10011001': 'M',
		'10011110': 'N',
		'10011111': 'Q',
		'10011100': 'U',
		'10011101': 'V',
		'10010010': 'X',
		'10010011': 'Y',
		'10010000': 'Z',
	},
}

while True:
	try:
		s1 = input()
		s2 = ''
		s3 = ''
		for c1 in s1:
			s2 += table[c1]
		while s2.find('1') >= 0:
			for l in (3, 4, 5, 6, 8):
				for c2 in table[l]:
					if s2.startswith(c2):
						s2 = s2[l:]
						s3 += table[l][c2]
		print(s3)
	except EOFError:
		break

Submission status: Wrong Answer

Solution code:
import sys

def two_ten(n):
    ans = ''
    while n:
        if n%2 == 0:
            ans += '0'
        else:
            ans += '1'
        n = n/2
    else:
        lis = list(ans)
        lis.reverse()
        return ''.join(lis).zfill(5)
    
def kawaii(lis):
    ans = []
    s = ''
    for v in lis:
        for c in v:
            s += c
            if s in dic:
                ans.append(dic[s])
                s = ''
    else:
        print ''.join(ans)

dic = {'101':' ', '000000':"'", '000011':"'", '10010001':'-', '010001':'.', '000001':'?', '100101':'A', '10011010':'B', '0101':'C',
       '0001':'D', '110':'E', '01001':'F', '10011011':'G', '010000':'H', '0111':'I', '10011000':'J', '0110':'K',
       '00100':'L', '10011001':'M', '10011110':'N', '00101':'O', '111':'P', '10011111':'Q', '1000':'R',
       '00110':'S', '00111':'T', '10011100':'U', '10011101':'V', '000010':'W', '10010010':'X', '10010011':'Y', '10010000':'Z'}

mathematics = {'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, ' ':26, '.':27, ',':28, '-':29, "'":30, '?':31,}

lis = []
for line in sys.stdin:
    for c in line.rstrip():
        lis.append(two_ten(mathematics[c]))
    else:
        kawaii(lis)

Submission status: Wrong Answer

Solution code:
def two_ten(n):
    ans = ''
    while n:
        if n%2 == 0:
            ans += '0'
        else:
            ans += '1'
        n = n/2
    else:
        lis = list(ans)
        lis.reverse()
        return ''.join(lis).zfill(5)
    
def kawaii(lis):
    ans = []
    s = ''
    for v in lis:
        for c in v:
            s += c
            if s in dic:
                ans.append(dic[s])
                s = ''
    else:
        print ''.join(ans)

dic = {'101':' ', '000000':"'", '000011':"'", '10010001':'-', '010001':'.', '000001':'?', '100101':'A', '10011010':'B', '0101':'C',
       '0001':'D', '110':'E', '01001':'F', '10011011':'G', '010000':'H', '0111':'I', '10011000':'J', '0110':'K',
       '00100':'L', '10011001':'M', '10011110':'N', '00101':'O', '111':'P', '10011111':'Q', '1000':'R',
       '00110':'S', '00111':'T', '10011100':'U', '10011101':'V', '000010':'W', '10010010':'X', '10010011':'Y', '10010000':'Z'}

mathematics = {'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, ' ':26, '.':27, ',':28, '-':29, "'":30, '?':31,}

lis = []
for c in raw_input():
    lis.append(two_ten(mathematics[c]))
else:
    kawaii(lis)

Submission status: Wrong Answer

Solution code:
import sys

def two_ten(n):
    ans = ''
    while n:
        if n%2 == 0:
            ans += '0'
        else:
            ans += '1'
        n = n/2
    else:
        lis = list(ans)
        lis.reverse()
        return ''.join(lis).zfill(5)
    
def kawaii(lis):
    ans = []
    s = ''
    for v in lis:
        for c in v:
            s += c
            if s in dic:
                ans.append(dic[s])
                s = ''
    else:
        print ''.join(ans)

dic = {'101':' ', '000000':"'", '000011':"'", '10010001':'-', '010001':'.', '000001':'?', '100101':'A', '10011010':'B', '0101':'C',
       '0001':'D', '110':'E', '01001':'F', '10011011':'G', '010000':'H', '0111':'I', '10011000':'J', '0110':'K',
       '00100':'L', '10011001':'M', '10011110':'N', '00101':'O', '111':'P', '10011111':'Q', '1000':'R',
       '00110':'S', '00111':'T', '10011100':'U', '10011101':'V', '000010':'W', '10010010':'X', '10010011':'Y', '10010000':'Z'}

mathematics = {'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, ' ':26, '.':27, ',':28, '-':29, "'":30, '?':31,}

for line in sys.stdin:
    lis = []
    for c in line.rstrip():
        lis.append(two_ten(mathematics[c]))
    else:
        kawaii(lis)

Submission status: Wrong Answer

Solution code:
import sys

def two_ten(n):
    ans = ''
    while n:
        if n%2 == 0:
            ans += '0'
        else:
            ans += '1'
        n = n/2
    else:
        lis = list(ans)
        lis.reverse()
        return ''.join(lis).zfill(5)
    
def kawaii(lis):
    ans = []
    s = ''
    for v in lis:
        for c in v:
            s += c
            if s in dic:
                ans.append(dic[s])
                s = ''
    else:
        print ''.join(ans)

dic = {'101':' ', '000000':"'", '000011':',', '10010001':'-', '010001':'.', '000001':'?', '100101':'A', '10011010':'B', '0101':'C',
       '0001':'D', '110':'E', '01001':'F', '10011011':'G', '010000':'H', '0111':'I', '10011000':'J', '0110':'K',
       '00100':'L', '10011001':'M', '10011110':'N', '00101':'O', '111':'P', '10011111':'Q', '1000':'R',
       '00110':'S', '00111':'T', '10011100':'U', '10011101':'V', '000010':'W', '10010010':'X', '10010011':'Y', '10010000':'Z'}

mathematics = {'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, ' ':26, '.':27, ',':28, '-':29, "'":30, '?':31,}

for line in sys.stdin:
    lis = []
    for c in line.rstrip():
        lis.append(two_ten(mathematics[c]))
    else:
        kawaii(lis)

Submission status: Wrong Answer

Solution code:
sig = " .,-'?"
dic = {
    0b1101: " ",
    0b1000000: "'",
    0b1000011: ",",
    0b110010001: "-",
    0b1010001: ".",
    0b1000001: "?",
    0b1100101: "A",
    0b110011010: "B",
    0b10101: "C",
    0b10001: "D",
    0b1110: "E",
    0b101001: "F",
    0b110011011: "G",
    0b1010000: "H",
    0b10111: "I",
    0b110011000: "J",
    0b10110: "K",
    0b100100: "L",
    0b110011001: "M",
    0b110011110: "N",
    0b100101: "O",
    0b1111: "P",
    0b110011111: "Q",
    0b11000: "R",
    0b100110: "S",
    0b100111: "T",
    0b110011100: "U",
    0b110011101: "V",
    0b1000010: "W",
    0b110010010: "X",
    0b110010011: "Y",
    0b110010000: "Z",
}
t = ""
for c in raw_input():
    code = ord(c)
    if 65 <= code <= 90:
        t += format(code - 65, '05b')
    else:
        t += format(sig.index(c) + 26, '05b')
q = 1
ans = ""
for e in t:
    q = (q<<1) + int(e)
    if dic.has_key(q):
        ans += dic[q]
        q = 1
print ans

Submission status: Wrong Answer

Solution code:
def doc_string():
	"""
	I can fly.
	"""

encode = {
        "A":"00000",
        "B":"00001",
        "C":"00010",
        "D":"00011",
        "E":"00100",
        "F":"00101",
        "G":"00110",
        "H":"00111",
        "I":"01000",
        "J":"01001",
        "K":"01010",
        "L":"01011",
        "M":"01100",
        "N":"01101",
        "O":"01110",
        "P":"01111",
        "Q":"10000",
        "R":"10001",
        "S":"10010",
        "T":"10011",
        "U":"10100",
        "V":"10101",
        "W":"10110",
        "X":"10111", 
        "Y":"11000",
        "Z":"11001",
        " ":"11010",
        ".":"11011",
        ",":"11100",
        "-":"11101",
        "'":"11110",
        "?":"11111"}
decode = {
        "101":" ",
        "000000":"'",
        "000011":",",
        "10010001":"-",
        "010001":".",
        "000001":"?",
        "100101":"A",
        "10011010":"B",
        "0101":"C",
        "0001":"D",
        "110":"E",
        "01001":"F",
        "10011011":"G",
        "010000":"H",
        "0111":"I",
        "10011000":"J",
        "0110":"K",
        "00100":"L",
        "10011001":"M",
        "10011110":"N",
        "00101":"O",
        "111":"P",
        "10011111":"Q",
        "1000":"R",
        "00110":"S",
        "00111":"T",
        "10011100":"U",
        "10011101":"V",
        "000010":"W",
        "10010010":"X",
        "10010011":"Y",
        "10010000":"Z"}

code = raw_input()

code0 = ""
for var in code:
	code0 += encode[var]

code = ""
temp = ""
for var in code0:
	temp += var
	if temp in decode:
		code += decode[temp]
		temp = ""
		
print code

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math
import re

tableA = {
        "A":"00000",
        "B":"00001",
        "C":"00010",
        "D":"00011",
        "E":"00100",
        "F":"00101",
        "G":"00110",
        "H":"00111",
        "I":"01000",
        "J":"01001",
        "K":"01010",
        "L":"01011",
        "M":"01100",
        "N":"01101",
        "O":"01110",
        "P":"01111",
        "Q":"10000",
        "R":"10001",
        "S":"10010",
        "T":"10011",
        "U":"10100",
        "V":"10101",
        "W":"10110",
        "X":"10111",
        "Y":"11000",
        "Z":"11001",
        " ":"11010",
        ".":"11011",
        ",":"11100",
        "-":"11101",
        "'":"11110",
        "?":"11111"}

tableB = {
        "101":" ",
        "000000":"'",
        "000011":",",
        "10010001":"-",
        "010001":".",
        "000001":"?",
        "100101":"A",
        "10011010":"B",
        "0101":"C",
        "0001":"D",
        "110":"E",
        "01001":"F",
        "10011011":"G",
        "010000":"H",
        "0111":"I",
        "10011000":"J",
        "0110":"K",
        "00100":"L",
        "10011001":"M",
        "10011110":"N",
        "00101":"O",
        "111":"P",
        "10011111":"Q",
        "1000":"R",
        "00110":"S",
        "00111":"T",
        "10011100":"U",
        "10011101":"V",
        "000010":"W",
        "10010010":"X",
        "10010011":"Y",
        "10010000":"Z"}

s = input().strip()
lst = []
for c in s:
    lst.append(tableA[c])
s = ''.join(lst)
#print('encoded', s)

i = 0
l = 3
lst = []
while True:
    key = s[i:i+l]
    if key in tableB:
        lst.append(tableB[key])
        i += l
        l = 3
    else:
        l += 1
        if l > 8:
            break
print(''.join(lst))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math
import re

tableA = {
        "A":"00000",
        "B":"00001",
        "C":"00010",
        "D":"00011",
        "E":"00100",
        "F":"00101",
        "G":"00110",
        "H":"00111",
        "I":"01000",
        "J":"01001",
        "K":"01010",
        "L":"01011",
        "M":"01100",
        "N":"01101",
        "O":"01110",
        "P":"01111",
        "Q":"10000",
        "R":"10001",
        "S":"10010",
        "T":"10011",
        "U":"10100",
        "V":"10101",
        "W":"10110",
        "X":"10111",
        "Y":"11000",
        "Z":"11001",
        " ":"11010",
        ".":"11011",
        ",":"11100",
        "-":"11101",
        "'":"11110",
        "?":"11111"}

tableB = {
        "101":" ",
        "000000":"'",
        "000011":",",
        "10010001":"-",
        "010001":".",
        "000001":"?",
        "100101":"A",
        "10011010":"B",
        "0101":"C",
        "0001":"D",
        "110":"E",
        "01001":"F",
        "10011011":"G",
        "010000":"H",
        "0111":"I",
        "10011000":"J",
        "0110":"K",
        "00100":"L",
        "10011001":"M",
        "10011110":"N",
        "00101":"O",
        "111":"P",
        "10011111":"Q",
        "1000":"R",
        "00110":"S",
        "00111":"T",
        "10011100":"U",
        "10011101":"V",
        "000010":"W",
        "10010010":"X",
        "10010011":"Y",
        "10010000":"Z"}

s = input().strip()
lst = []
for c in s:
    lst.append(tableA[c])
s = ''.join(lst)
#print('encoded', s)

i = 0
l = 3
lst = []
while True:
    key = s[i:i+l]
    if key in tableB:
        lst.append(tableB[key])
        i += l
        l = 3
    else:
        l += 1
        if l > 8:
            break
print(''.join(lst).strip())

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math
import re

tableA = {
        "A":"00000",
        "B":"00001",
        "C":"00010",
        "D":"00011",
        "E":"00100",
        "F":"00101",
        "G":"00110",
        "H":"00111",
        "I":"01000",
        "J":"01001",
        "K":"01010",
        "L":"01011",
        "M":"01100",
        "N":"01101",
        "O":"01110",
        "P":"01111",
        "Q":"10000",
        "R":"10001",
        "S":"10010",
        "T":"10011",
        "U":"10100",
        "V":"10101",
        "W":"10110",
        "X":"10111",
        "Y":"11000",
        "Z":"11001",
        " ":"11010",
        ".":"11011",
        ",":"11100",
        "-":"11101",
        "'":"11110",
        "?":"11111"}

tableB = {
        "101":" ",
        "000000":"'",
        "000011":",",
        "10010001":"-",
        "010001":".",
        "000001":"?",
        "100101":"A",
        "10011010":"B",
        "0101":"C",
        "0001":"D",
        "110":"E",
        "01001":"F",
        "10011011":"G",
        "010000":"H",
        "0111":"I",
        "10011000":"J",
        "0110":"K",
        "00100":"L",
        "10011001":"M",
        "10011110":"N",
        "00101":"O",
        "111":"P",
        "10011111":"Q",
        "1000":"R",
        "00110":"S",
        "00111":"T",
        "10011100":"U",
        "10011101":"V",
        "000010":"W",
        "10010010":"X",
        "10010011":"Y",
        "10010000":"Z"}

s = input().strip()
lst = []
for c in s:
    lst.append(tableA[c])
s = ''.join(lst)
#print('encoded', s)

i = 0
l = 3
lst = []
while True:
    key = s[i:i+l]
    if key in tableB:
        lst.append(tableB[key])
        i += l
        l = 3
    else:
        l += 1
        if l > 8:
            break
print(''.join(lst), end='')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math
import re

tableA = {
        "A":"00000",
        "B":"00001",
        "C":"00010",
        "D":"00011",
        "E":"00100",
        "F":"00101",
        "G":"00110",
        "H":"00111",
        "I":"01000",
        "J":"01001",
        "K":"01010",
        "L":"01011",
        "M":"01100",
        "N":"01101",
        "O":"01110",
        "P":"01111",
        "Q":"10000",
        "R":"10001",
        "S":"10010",
        "T":"10011",
        "U":"10100",
        "V":"10101",
        "W":"10110",
        "X":"10111",
        "Y":"11000",
        "Z":"11001",
        " ":"11010",
        ".":"11011",
        ",":"11100",
        "-":"11101",
        "'":"11110",
        "?":"11111"}

tableB = {
        "101":" ",
        "000000":"'",
        "000011":",",
        "10010001":"-",
        "010001":".",
        "000001":"?",
        "100101":"A",
        "10011010":"B",
        "0101":"C",
        "0001":"D",
        "110":"E",
        "01001":"F",
        "10011011":"G",
        "010000":"H",
        "0111":"I",
        "10011000":"J",
        "0110":"K",
        "00100":"L",
        "10011001":"M",
        "10011110":"N",
        "00101":"O",
        "111":"P",
        "10011111":"Q",
        "1000":"R",
        "00110":"S",
        "00111":"T",
        "10011100":"U",
        "10011101":"V",
        "000010":"W",
        "10010010":"X",
        "10010011":"Y",
        "10010000":"Z"}

s = input().strip()
lst = []
for c in s:
    lst.append(tableA[c])
s = ''.join(lst)
#print('encoded', s)

tmp, ans = '', ''
for c in s:
    tmp += c
    if tmp in tableB:
        ans += tableB[tmp]
        tmp = ""
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math
import re

tableA = {
        "A":"00000",
        "B":"00001",
        "C":"00010",
        "D":"00011",
        "E":"00100",
        "F":"00101",
        "G":"00110",
        "H":"00111",
        "I":"01000",
        "J":"01001",
        "K":"01010",
        "L":"01011",
        "M":"01100",
        "N":"01101",
        "O":"01110",
        "P":"01111",
        "Q":"10000",
        "R":"10001",
        "S":"10010",
        "T":"10011",
        "U":"10100",
        "V":"10101",
        "W":"10110",
        "X":"10111",
        "Y":"11000",
        "Z":"11001",
        " ":"11010",
        ".":"11011",
        ",":"11100",
        "-":"11101",
        "'":"11110",
        "?":"11111"}

tableB = {
        "101":" ",
        "000000":"'",
        "000011":",",
        "10010001":"-",
        "010001":".",
        "000001":"?",
        "100101":"A",
        "10011010":"B",
        "0101":"C",
        "0001":"D",
        "110":"E",
        "01001":"F",
        "10011011":"G",
        "010000":"H",
        "0111":"I",
        "10011000":"J",
        "0110":"K",
        "00100":"L",
        "10011001":"M",
        "10011110":"N",
        "00101":"O",
        "111":"P",
        "10011111":"Q",
        "1000":"R",
        "00110":"S",
        "00111":"T",
        "10011100":"U",
        "10011101":"V",
        "000010":"W",
        "10010010":"X",
        "10010011":"Y",
        "10010000":"Z"}

s = input()
lst = []
for c in s:
    lst.append(tableA[c])
s = ''.join(lst)
#print('encoded', s)

tmp, ans = '', ''
for c in s:
    tmp += c
    if tmp in tableB:
        ans += tableB[tmp]
        tmp = ''
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math
import re

tableA = {
        "A":"00000",
        "B":"00001",
        "C":"00010",
        "D":"00011",
        "E":"00100",
        "F":"00101",
        "G":"00110",
        "H":"00111",
        "I":"01000",
        "J":"01001",
        "K":"01010",
        "L":"01011",
        "M":"01100",
        "N":"01101",
        "O":"01110",
        "P":"01111",
        "Q":"10000",
        "R":"10001",
        "S":"10010",
        "T":"10011",
        "U":"10100",
        "V":"10101",
        "W":"10110",
        "X":"10111",
        "Y":"11000",
        "Z":"11001",
        " ":"11010",
        ".":"11011",
        ",":"11100",
        "-":"11101",
        "'":"11110",
        "?":"11111"}

tableB = {
        "101":" ",
        "000000":"'",
        "000011":",",
        "10010001":"-",
        "010001":".",
        "000001":"?",
        "100101":"A",
        "10011010":"B",
        "0101":"C",
        "0001":"D",
        "110":"E",
        "01001":"F",
        "10011011":"G",
        "010000":"H",
        "0111":"I",
        "10011000":"J",
        "0110":"K",
        "00100":"L",
        "10011001":"M",
        "10011110":"N",
        "00101":"O",
        "111":"P",
        "10011111":"Q",
        "1000":"R",
        "00110":"S",
        "00111":"T",
        "10011100":"U",
        "10011101":"V",
        "000010":"W",
        "10010010":"X",
        "10010011":"Y",
        "10010000":"Z"}

for s in sys.stdin:
    s = s.strip()
    lst = []
    for c in s:
        lst.append(tableA[c])
    s = ''.join(lst)
    #print('encoded', s)

    tmp, ans = '', ''
    for c in s:
        tmp += c
        if tmp in tableB:
            ans += tableB[tmp]
            tmp = ''
    print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math
import re

tableA = {
        "A":"00000",
        "B":"00001",
        "C":"00010",
        "D":"00011",
        "E":"00100",
        "F":"00101",
        "G":"00110",
        "H":"00111",
        "I":"01000",
        "J":"01001",
        "K":"01010",
        "L":"01011",
        "M":"01100",
        "N":"01101",
        "O":"01110",
        "P":"01111",
        "Q":"10000",
        "R":"10001",
        "S":"10010",
        "T":"10011",
        "U":"10100",
        "V":"10101",
        "W":"10110",
        "X":"10111",
        "Y":"11000",
        "Z":"11001",
        " ":"11010",
        ".":"11011",
        ",":"11100",
        "-":"11101",
        "'":"11110",
        "?":"11111"}

tableB = {
        "101":" ",
        "000000":"'",
        "000011":",",
        "10010001":"-",
        "010001":".",
        "000001":"?",
        "100101":"A",
        "10011010":"B",
        "0101":"C",
        "0001":"D",
        "110":"E",
        "01001":"F",
        "10011011":"G",
        "010000":"H",
        "0111":"I",
        "10011000":"J",
        "0110":"K",
        "00100":"L",
        "10011001":"M",
        "10011110":"N",
        "00101":"O",
        "111":"P",
        "10011111":"Q",
        "1000":"R",
        "00110":"S",
        "00111":"T",
        "10011100":"U",
        "10011101":"V",
        "000010":"W",
        "10010010":"X",
        "10010011":"Y",
        "10010000":"Z"}

for s in sys.stdin:
    s = s.strip()
    s = "".join(map(lambda c: tableA[c], s))

    tmp, ans = '', ''
    for c in s:
        tmp += c
        if tmp in tableB:
            ans += tableB[tmp]
            tmp = ''
    print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math
import re

tableA = {
        "A":"00000",
        "B":"00001",
        "C":"00010",
        "D":"00011",
        "E":"00100",
        "F":"00101",
        "G":"00110",
        "H":"00111",
        "I":"01000",
        "J":"01001",
        "K":"01010",
        "L":"01011",
        "M":"01100",
        "N":"01101",
        "O":"01110",
        "P":"01111",
        "Q":"10000",
        "R":"10001",
        "S":"10010",
        "T":"10011",
        "U":"10100",
        "V":"10101",
        "W":"10110",
        "X":"10111",
        "Y":"11000",
        "Z":"11001",
        " ":"11010",
        ".":"11011",
        ",":"11100",
        "-":"11101",
        "'":"11110",
        "?":"11111"}

tableB = {
        "101":" ",
        "000000":"'",
        "000011":",",
        "10010001":"-",
        "010001":".",
        "000001":"?",
        "100101":"A",
        "10011010":"B",
        "0101":"C",
        "0001":"D",
        "110":"E",
        "01001":"F",
        "10011011":"G",
        "010000":"H",
        "0111":"I",
        "10011000":"J",
        "0110":"K",
        "00100":"L",
        "10011001":"M",
        "10011110":"N",
        "00101":"O",
        "111":"P",
        "10011111":"Q",
        "1000":"R",
        "00110":"S",
        "00111":"T",
        "10011100":"U",
        "10011101":"V",
        "000010":"W",
        "10010010":"X",
        "10010011":"Y",
        "10010000":"Z"}

for s in sys.stdin:
    s = s.strip()
    lst = []
    for c in s:
        lst.append(tableA[c])
    s = ''.join(lst)
    s = s.zfill(5)
    #print('encoded', s)

    tmp, ans = '', ''
    for c in s:
        tmp += c
        if tmp in tableB:
            ans += tableB[tmp]
            tmp = ''
    print(ans)