Problem:


博士が愛した符号

博士 : ピーター君、ついにやったよ。

ピーター : どうしました、デビッド博士？またくだらない発明ですか？

博士 : この表だよ、この表。

文字符号

（空白）101

'000000

,000011

-10010001

.010001

?000001

A100101

B10011010

文字符号

 C 0101

 D 0001

 E 110

 F 01001

 G 10011011

 H 010000

 I 0111

 J 10011000

文字符号

 K 0110

 L 00100

 M 10011001

 N 10011110

 O 00101

 P 111

 Q 10011111

 R 1000

文字符号

 S 00110

 T 00111

 U 10011100

 V 10011101

 W 000010

 X 10010010

 Y 10010011

 Z 10010000

ピーター : なんですか? この表は。

博士 : いいから、言う通りにしてみなさい。まず、お前の名前を紙に書いてごらん。

ピーター : はい"PETER POTTER" っと。

博士 : そうしたら、１文字ずつ、この表の「符号」に置き換えるのだよ。

ピーター : えーと"P" を「111」にして"E" を「110」して…結構面倒ですね。

111 110 00111 110 1000 101 111 00101 00111 00111 110 1000

           になりました。なんだか、バーコードみたいですね。

博士 : よろしい。そうしたら、置き換えた文字列を全部つなげて、５文字ごとに区切ってみなさい。

ピーター : はいはい、つなげて区切ると。

11111 00011 11101 00010 11110 01010 01110 01111 10100 0

           こんな感じになりました。けど、最後の「0」だけのやつはどうしますか?

博士 : ０を付け加えて５文字にしておいてくれ。

ピーター : えーと最後が０が1個だけだから０をあと４つ加えてやればいいんですね。できました。

11111 00011 11101 00010 11110 01010 01110 01111 10100 00000

博士 : 次はこの表を使うのだ。

符号文字

 00000 A

 00001 B

 00010 C

 00011 D

 00100 E

 00101 F

 00110 G

 00111 H

符号文字

 01000 I

 01001 J

 01010 K

 01011 L

 01100 M

 01101 N

 01110 O

 01111 P

符号文字

 10000 Q

 10001 R

 10010 S

 10011 T

 10100 U

 10101 V

 10110 W

 10111 X

符号文字

 11000 Y

 11001 Z

 11010 （空白）

 11011 .

 11100 ,

 11101 -

 11110 '

 11111 ?

ピーター : これをどう使うんですか…そうか!今度は符号から文字に置き換えるのか!

博士 : そうそう。「11111」だったら「?」に、「00011」だったら「D」にとやってゆけばいいんだよ。

ピーター : これは単純ですね……えーと「?D-C'KOPUA」になりました。でも意味不明ですよ。

博士 : 文字数を数えてごらん。

ピーター : １０文字ですよ。あっ、「PETER POTTER」は１２文字だったのに２文字減っています。

博士 : そう、この表を使えば文字を減らすことができるのだよ。じゃあ今度はこの文章で同じことをやっ
       てごらん。

PETER PIPER PICKED A PECK OF PICKLED PEPPERS. A PECK OF PICKLED PEPPERS
PETER PIPER PICKED. IF PETER PIPER PICKED A PECK OF PICKLED PEPPERS, WHERE'S
THE PECK OF PICKLED PEPPERS PETER PIPER PICKED?

ピーター : ぎょぎょ、行が分かれていますが、どうするんですか?

博士 : 紙の都合で３行になってしまったが、改行文字のかわりに空白がある長い１行だと思っておくれ。

ピーター : はいはい。行と行の間にあるのは空白だと。しかし面倒だな……。

博士 : だったらプログラムにやらせればいいではないか。

ということで、ピーターの代わりに、読み込んだ文字列を符号に変換し出力するプログラムを作成してください。

入力

複数のデータセットが与えられます。各データセットに文字列１行（表に含まれる文字からなる）が与えられます。文字列に含まれる文字の数は 1 文字以上 100 文字以下です。

データセットの数は 200 を超えません。

出力

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

Sample Input

PETER POTTER

Output for the Sample Input

?D-C'KOPUA



Sample input:
PETER POTTER


Sample output:
?D-C'KOPUA

Submission status: Wrong Answer

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

import sys
import os
import math

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

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

S = ''
for s in sys.stdin:
    s = s.replace('\n', ' ')
    S += s

T = ''
for c in S:
    T += d1[c]

# zero padding
T += '0' * (-len(T) % 5)

U = ''
for i in range(0, len(T), 5):
    binary = T[i:i+5]
    U += d2[binary]

print(U)

Submission status: Wrong Answer

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

import sys
import os
import math

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

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

S = ''
for s in sys.stdin:
    s = s.replace('\n', ' ')
    S += s

T = ''
for c in S:
    T += d1[c]

# zero padding
T += '0' * (-len(T) % 5)

U = ''
for i in range(0, len(T), 5):
    binary = T[i:i+5]
    U += d2[binary]

print(U, end='')

Submission status: Wrong Answer

Solution code:
# Aizu Problem 0088: The Code A Doctor Loved
#
import sys, math, os

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


def bin5(k):
    b = bin(k)[2:]
    while len(b) < 5:
        b = '0' + b
    return b


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

CODE2 = {bin5(k): chr(65+k) for k in range(26)}
symbols = [' ', '.', ',', '-', "'", '?']
for k in range(len(symbols)):
    CODE2[bin5(26+k)] = symbols[k]


def encode(string):
    enc = ''.join([CODE1[char] for char in string])
    while len(enc) % 5 != 0:
        enc += '0'
    return ''.join([CODE2[enc[5*k:5*k+5]] for k in range(len(enc) // 5)])


for line in sys.stdin:
    print(encode(line.strip()))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0088

"""
import sys
from sys import stdin
input = stdin.readline


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

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

    for line in sys.stdin:
        txt = line.strip()
        ans = ''
        for c in txt:
            ans += encoder[c]

        if len(ans) % 5 != 0:
            ans += '0'*(5-len(ans)%5)

        result = ''
        while ans:
            temp = ans[:5]
            result += decoder[temp]
            ans = ans[5:]

        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Wrong Answer

Solution code:
import sys
d={' ':'101',"'":'000000',',':'000011','-':'10010001','.':'010001','?':'000001','A':'100101','B':'10011010','C':'0101','D':'0001','E':'110',
'F':'01001','G':'10011011','H':'010000','I':'0111','J':'10011000','K':'0110','L':'00100','M':'10011001','N':'10011110','O':'00101','P':'111',
'Q':'10011111','R':'1000','S':'00110','T':'00111','U':'10011100','V':'10011101','W':'000010','X':'10010010','Y':'10010011','Z':'10010000'}
a=''
for e in sys.stdin:
 a+=''.join(d[c]for c in e.strip())
a+='0'*(-len(a)%5)
print(''.join("ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?"[int(a[i:i+5],2)]for i in range(0,len(a),5)))

Submission status: Wrong Answer

Solution code:
import sys
d={' ':'101',"'":'000000',',':'000011','-':'10010001','.':'010001','?':'000001','A':'100101','B':'10011010','C':'0101','D':'0001','E':'110',
'F':'01001','G':'10011011','H':'010000','I':'0111','J':'10011000','K':'0110','L':'00100','M':'10011001','N':'10011110','O':'00101','P':'111',
'Q':'10011111','R':'1000','S':'00110','T':'00111','U':'10011100','V':'10011101','W':'000010','X':'10010010','Y':'10010011','Z':'10010000'}
a='101'.join(''.join(d[c]for c in e.strip())for e in sys.stdin)
a+='0'*(-len(a)%5)
print(''.join("ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?"[int(a[i:i+5],2)]for i in range(0,len(a),5)))

Submission status: Wrong Answer

Solution code:
import sys
d={' ':'101',"'":'000000',',':'000011','-':'10010001','.':'010001','?':'000001','A':'100101','B':'10011010','C':'0101','D':'0001','E':'110',
'F':'01001','G':'10011011','H':'010000','I':'0111','J':'10011000','K':'0110','L':'00100','M':'10011001','N':'10011110','O':'00101','P':'111',
'Q':'10011111','R':'1000','S':'00110','T':'00111','U':'10011100','V':'10011101','W':'000010','X':'10010010','Y':'10010011','Z':'10010000'}
for e in sys.stdin:
 a=''.join(d[c]for c in e.strip())
 a+='0'*(-len(a)%5)
 print(''.join("ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?"[int(a[i:i+5],2)]for i in range(0,len(a),5)))

Submission status: Wrong Answer

Solution code:
import sys
d={' ':'101',"'":'000000',',':'000011','-':'10010001','.':'010001','?':'000001','A':'100101','B':'10011010','C':'0101','D':'0001','E':'110',
'F':'01001','G':'10011011','H':'010000','I':'0111','J':'10011000','K':'0110','L':'00100','M':'10011001','N':'10011110','O':'00101','P':'111',
'Q':'10011111','R':'1000','S':'00110','T':'00111','U':'10011100','V':'10011101','W':'000010','X':'10010010','Y':'10010011','Z':'10010000'}
for e in sys.stdin:
 a=''.join(d[c]for c in e.strip())
 a+='0'*(-len(a)%5)
# print(''.join("ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?"[int(a[i:i+5],2)]for i in range(0,len(a),5)))
 print(*["ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?"[int(a[i:i+5],2)]for i in range(0,len(a),5)],sep='')

Submission status: Wrong Answer

Solution code:
import sys
d={' ':'101',"'":'000000',',':'000011','-':'10010001','.':'010001','?':'000001','A':'100101','B':'10011010','C':'0101','D':'0001','E':'110',
'F':'01001','G':'10011011','H':'010000','I':'0111','J':'10011000','K':'0110','L':'00100','M':'10011001','N':'10011110','O':'00101','P':'111',
'Q':'10011111','R':'1000','S':'00110','T':'00111','U':'10011100','V':'10011101','W':'000010','X':'10010010','Y':'10010011','Z':'10010000'}
for e in sys.stdin:
 a=''.join(d[c]for c in e.strip())
 a+='0'*(-len(a)%5)
 print(''.join("ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?"[int(a[i:i+5],2)]for i in range(0,len(a),5)))
# print(*["ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?"[int(a[i:i+5],2)]for i in range(0,len(a),5)],sep='')

Submission status: Wrong Answer

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

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

def to_digit(ss):
  ret = ""
  for s in ss:
    ret += dic1[s]
  return ret

def to_alpha(digit):
  ret = ""
  ind = 0
  end = len(digit)

  while ind + 5 < end:
    ret += dic2[digit[ind:ind + 5]]
    ind += 5

  if digit[ind:]:
    ret += dic2[digit[ind:] + "0" * (5 - end + ind)]

  return ret

while True:
  try:
    print(to_alpha(to_digit(input())))
  except EOFError:
    break

Submission status: Wrong Answer

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

s=raw_input()
s1,ans="",""
for w in s:
    s1+=d1[w]
s1+="0"*(5-len(s1)%5)
for i in range(len(s1)/5):
    ans+=d2[s1[:5]]
    s1=s1[5:]
print ans

Submission status: Wrong Answer

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

import sys
s=""
for line in sys.stdin:
    s+=line.rstrip()+" "
s=s.rstrip()
s1,ans="",""
for w in s:
    s1+=d1[w]
s1+="0"*(5-len(s1)%5)
for i in range(len(s1)/5):
    ans+=d2[s1[:5]]
    s1=s1[5:]
print ans

Submission status: Wrong Answer

Solution code:
d1={
" ":"101",
"'":"000000",
",":"000011",
"-":"10010001",
".":"010001",
"?":"000001",
"A":"100101",
"B":"10011010",
"C":"0101",
"D":"0001",
"E":"110",
"F":"01001",
"G":"10011011",
"H":"010000",
"I":"0111",
"J":"10011000",
"K":"0110",
"L":"00100",
"M":"10011001",
"N":"10011110",
"O":"00101",
"P":"111",
"Q":"10011111",
"R":"1000",
"S":"00110",
"T":"00111",
"U":"10011100",
"V":"10011101",
"W":"000010",
"X":"10010010",
"Y":"10010011",
"Z":"10010000"}
d2={
"00000":"A",
"00001":"B",
"00010":"C",
"00011":"D",
"00100":"E",
"00101":"F",
"00110":"G",
"00111":"H",
"01000":"I",
"01001":"J",
"01010":"K",
"01011":"L",
"01100":"M",
"01101":"N",
"01110":"O",
"01111":"P",
"10000":"Q",
"10001":"R",
"10010":"S",
"10011":"T",
"10100":"U",
"10101":"V",
"10110":"W",
"10111":"X",
"11000":"Y",
"11001":"Z",
"11010":" ",
"11011":".",
"11100":",",
"11101":"-",
"11110":"'",
"11111":"?"}
while 1:
    try:
        s=raw_input()
    except EOFError:
        break
    s1,ans="",""
    for w in s:
        s1+=d1[w]
    s1+="0"*(5-len(s1)%5)
    for i in range(len(s1)/5):
        ans+=d2[s1[:5]]
        s1=s1[5:]
    print ans

Submission status: Wrong Answer

Solution code:
enco1={" ":"101", "'":"000000", ",":"000011", "-":"10010001", ".":"010001", "?":"000001", "A":"100101", "B":"10011010", "C":"0101", "D":"0001", "E":"110", "F":"01001", "G":"10011011", "H":"010000", "I":"0111", "J":"10011000", "K":"0110", "L":"00100", "M":"10011001", "N":"10011110", "O":"00101", "P":"111", "Q":"10011111", "R":"1000", "S":"00110", "T":"00111", "U":"10011100", "V":"10011101", "W":"000010", "X":"10010010", "Y":"10010011", "Z":"10010000" }
enco2={"00000":"A", "00001":"B", "00010":"C", "00011":"D", "00100":"E", "00101":"F", "00110":"G", "00111":"H", "01000":"I", "01001":"J", "01010":"K", "01011":"L", "01100":"M", "01101":"N", "01110":"O", "01111":"P", "10000":"Q", "10001":"R", "10010":"S", "10011":"T", "10100":"U", "10101":"V", "10110":"W", "10111":"X", "11000":"Y", "11001":"Z", "11010":" ", "11011":".", "11100":",", "11101":"-", "11110":"'", "11111":"?"}
s="".join([enco1[w] for w in raw_input()])
s=s+"0"*(5-len(s)%5)
print "".join([enco2[s[i:i+5]] for i in xrange(0,len(s),5)])

Submission status: Wrong Answer

Solution code:
enco1={" ":"101","'":"000000",",":"000011","-":"10010001",".":"010001","?":"000001","A":"100101","B":"10011010","C":"0101","D":"0001","E":"110","F":"01001","G":"10011011","H":"010000","I":"0111","J":"10011000","K":"0110","L":"00100","M":"10011001","N":"10011110","O":"00101","P":"111","Q":"10011111","R":"1000","S":"00110","T":"00111","U":"10011100","V":"10011101","W":"000010","X":"10010010","Y":"10010011","Z":"10010000"}
enco2={"00000":"A","00001":"B","00010":"C","00011":"D","00100":"E","00101":"F","00110":"G","00111":"H","01000":"I","01001":"J","01010":"K","01011":"L","01100":"M","01101":"N","01110":"O","01111":"P","10000":"Q","10001":"R","10010":"S","10011":"T","10100":"U","10101":"V","10110":"W","10111":"X","11000":"Y","11001":"Z","11010":" ","11011":".","11100":",","11101":"-","11110":"'","11111":"?"}
s="".join([enco1[w] for w in raw_input()])
s=s+"0"*(5-len(s)%5)
print "".join([enco2[s[i:i+5]] for i in xrange(0,len(s),5)])

Submission status: Wrong Answer

Solution code:
enco1={" ":"101","'":"000000",",":"000011","-":"10010001",".":"010001","?":"000001","A":"100101","B":"10011010","C":"0101","D":"0001","E":"110","F":"01001","G":"10011011","H":"010000","I":"0111","J":"10011000","K":"0110","L":"00100","M":"10011001","N":"10011110","O":"00101","P":"111","Q":"10011111","R":"1000","S":"00110","T":"00111","U":"10011100","V":"10011101","W":"000010","X":"10010010","Y":"10010011","Z":"10010000"}
enco2={"00000":"A","00001":"B","00010":"C","00011":"D","00100":"E","00101":"F","00110":"G","00111":"H","01000":"I","01001":"J","01010":"K","01011":"L","01100":"M","01101":"N","01110":"O","01111":"P","10000":"Q","10001":"R","10010":"S","10011":"T","10100":"U","10101":"V","10110":"W","10111":"X","11000":"Y","11001":"Z","11010":" ","11011":".","11100":",","11101":"-","11110":"'","11111":"?"}
while True:
    try:
        s="".join([enco1[w] for w in raw_input()])
        s=s+"0"*(5-len(s)%5)
        print "".join([enco2[s[i:i+5]] for i in xrange(0,len(s),5)])
    except:
        break

Submission status: Wrong Answer

Solution code:
enc={ " ":"101", "'":"000000", ",":"000011", "-":"10010001", ".":"010001", "?":"000001", "A":"100101", "B":"10011010", "C":"0101", "D":"0001", "E":"110", "F":"01001", "G":"10011011", "H":"010000", "I":"0111", "J":"10011000", "K":"0110", "L":"00100", "M":"10011001", "N":"10011110", "O":"00101", "P":"111", "Q":"10011111", "R":"1000", "S":"00110", "T":"00111", "U":"10011100", "V":"10011101", "W":"000010", "X":"10010010", "Y":"10010011", "Z":"10010000" }
dec={ "00000":"A", "00001":"B", "00010":"C", "00011":"D", "00100":"E", "00101":"F", "00110":"G", "00111":"H", "01000":"I", "01001":"J", "01010":"K", "01011":"L", "01100":"M", "01101":"N", "01110":"O", "01111":"P", "10000":"Q", "10001":"R", "10010":"S", "10011":"T", "10100":"U", "10101":"V", "10110":"W", "10111":"X", "11000":"Y", "11001":"Z", "11010":" ", "11011":".", "11100":",", "11101":"-", "11110":"'", "11111":"?" }
string=raw_input()
encStr=""
for c in string:
    encStr+=enc[c]
mod=len(encStr)%5
encStr+=("0"*(5-mod))
decStr=""
for i in range(0, len(encStr), 5):
    decStr+=dec[encStr[i:i+5]]
print decStr

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
import io

d1 = {
    ' ': '101', "'": '000000', ',': '000011', '-': '10010001',
    '.': '010001', '?': '000001', 'A': '100101', 'B': '10011010',
    'C': '0101', 'D': '0001', 'E': '110', 'F': '01001', 'G': '10011011',
    'H': '010000', 'I': '0111', 'J': '10011000', 'K': '0110', 'L': '00100',
    'M': '10011001', 'N': '10011110', 'O': '00101', 'P': '111',
    'Q': '10011111', 'R': '1000', 'S': '00110', 'T': '00111',
    'U': '10011100', 'V': '10011101', 'W': '000010', 'X': '10010010',
    'Y': '10010011', 'Z': '10010000'
    }
d2 = {'{:05b}'.format(n): chr(n+ord('A')) for n in range(26)}
d2.update({'{:05b}'.format(n): c for n, c in zip(range(26, 32), " .,-'?")})

stream = io.StringIO()
for line in stdin:
    stream.seek(0)
    stream.write(''.join(d1[c] for c in line.rstrip()))
    stream.seek(0)
    for c in iter(lambda: stream.read(5), ''):
        print(d2[c.ljust(5, '0')], end='')
    print()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
import io

d1 = {
    ' ': '101', "'": '000000', ',': '000011', '-': '10010001',
    '.': '010001', '?': '000001', 'A': '100101', 'B': '10011010',
    'C': '0101', 'D': '0001', 'E': '110', 'F': '01001', 'G': '10011011',
    'H': '010000', 'I': '0111', 'J': '10011000', 'K': '0110', 'L': '00100',
    'M': '10011001', 'N': '10011110', 'O': '00101', 'P': '111',
    'Q': '10011111', 'R': '1000', 'S': '00110', 'T': '00111',
    'U': '10011100', 'V': '10011101', 'W': '000010', 'X': '10010010',
    'Y': '10010011', 'Z': '10010000'
    }
d2 = {'{:05b}'.format(n): chr(n+ord('A')) for n in range(26)}
d2.update({'{:05b}'.format(n): c for n, c in zip(range(26, 32), " .,-'?")})

stream = io.StringIO()
for line in stdin:
    stream.seek(0)
    stream.write(''.join(d1[c] for c in line.rstrip('\r\n')))
    stream.seek(0)
    for c in iter(lambda: stream.read(5), ''):
        print(d2[c.ljust(5, '0')], end='')
    print()

Submission status: Wrong Answer

Solution code:
conv1 = {' ':"101","'":"000000",",":"000011","-":"10010001",".":"010001","?":"000001","A":"100101","B":"10011010","C":"0101","D":"0001","E":"110","F":"01001","G":"10011011","H":"010000","I":"0111","J":"10011000","K":"0110","L":"00100","M":"10011001","N":"10011110","O":"00101","P":"111","Q":"10011111","R":"1000","S":"00110","T":"00111","U":"10011100","V":"10011101","W":"000010","X":"10010010","Y":"10010011","Z":"10010000"}
sym = " .,-'?"
s1 = ""; s2 = "";
s = raw_input()
for c in s:
    s1 += conv1[c]
if len(s1)%5>0 :s1 += " "*(5-(len(s1)%5))
for i in xrange(0,len(s1),5):
    code = int(s1[i:i+5],2)
    if code<26:
        s2 += chr(65+code)
    else:
        s2 += sym[code-26]
print s2

Submission status: Wrong Answer

Solution code:
import sys
conv1 = {' ':"101","'":"000000",",":"000011","-":"10010001",".":"010001","?":"000001","A":"100101","B":"10011010","C":"0101","D":"0001","E":"110","F":"01001","G":"10011011","H":"010000","I":"0111","J":"10011000","K":"0110","L":"00100","M":"10011001","N":"10011110","O":"00101","P":"111","Q":"10011111","R":"1000","S":"00110","T":"00111","U":"10011100","V":"10011101","W":"000010","X":"10010010","Y":"10010011","Z":"10010000"}
sym = " .,-'?"
for s in sys.stdin.readlines():
    s1 = ""; s2 = "";
    for c in s.strip():
        s1 += conv1[c]
    if len(s1)%5>0 :s1 += " "*(5-(len(s1)%5))
    for i in xrange(0,len(s1),5):
        code = int(s1[i:i+5],2)
        if code<26:
            s2 += chr(65+code)
        else:
            s2 += sym[code-26]
    print s2

Submission status: Wrong Answer

Solution code:
import sys
conv1 = {' ':"101","'":"000000",",":"000011","-":"10010001",".":"010001","?":"000001","A":"100101","B":"10011010","C":"0101","D":"0001","E":"110","F":"01001","G":"10011011","H":"010000","I":"0111","J":"10011000","K":"0110","L":"00100","M":"10011001","N":"10011110","O":"00101","P":"111","Q":"10011111","R":"1000","S":"00110","T":"00111","U":"10011100","V":"10011101","W":"000010","X":"10010010","Y":"10010011","Z":"10010000"}
sym = " .,-'?"
for s in sys.stdin.readlines():
    s1 = ""; s2 = "";
    for c in s.strip():
        s1 += conv1[c]
    if len(s1)%5>0 :s1 += "0"*(5-(len(s1)%5))
    for i in xrange(0,len(s1),5):
        print s1[i:i+5]
        code = int(s1[i:i+5],2)
        if code<26:
            s2 += chr(65+code)
        else:
            s2 += sym[code-26]
    print s2

Submission status: Wrong Answer

Solution code:
import sys
conv1 = {' ':"101","'":"000000",",":"000011","-":"10010001",".":"010001","?":"000001","A":"100101","B":"10011010","C":"0101","D":"0001","E":"110","F":"01001","G":"10011011","H":"010000","I":"0111","J":"10011000","K":"0110","L":"00100","M":"10011001","N":"10011110","O":"00101","P":"111","Q":"10011111","R":"1000","S":"00110","T":"00111","U":"10011100","V":"10011101","W":"000010","X":"10010010","Y":"10010011","Z":"10010000"}
sym = " .,-'?"
for s in sys.stdin.readlines():
    s1 = ""; s2 = "";
    for c in s.strip():
        s1 += conv1[c]
    if len(s1)%5>0 :s1 += "0"*(5-(len(s1)%5))
    for i in xrange(0,len(s1),5):
        code = int(s1[i:i+5],2)
        if code<26:
            s2 += chr(65+code)
        else:
            s2 += sym[code-26]
    print s2

Submission status: Wrong Answer

Solution code:
import sys
conv1 = {' ':"101","'":"000000",",":"000011","-":"10010001",".":"010001","?":"000001","A":"100101","B":"10011010","C":"0101","D":"0001","E":"110","F":"01001","G":"10011011","H":"010000","I":"0111","J":"10011000","K":"0110","L":"00100","M":"10011001","N":"10011110","O":"00101","P":"111","Q":"10011111","R":"1000","S":"00110","T":"00111","U":"10011100","V":"10011101","W":"000010","X":"10010010","Y":"10010011","Z":"10010000"}
conv2 = {"00000":"A","00001":"B","00010":"C","00011":"D","00100":"E","00101":"F","00110":"G","00111":"H","01000":"I","01001":"J","01010":"K","01011":"L","01100":"M","01101":"N","01110":"O","01111":"P","10000":"Q","10001":"R","10010":"S","10011":"T","10100":"U","10101":"V","10110":"W","10111":"X","11000":"Y","11001":"Z","11010":" ","11011":".","11100":",","11101":"-","11110":"'","11111":"?"}
for s in sys.stdin.readlines():
    s1 = ""; s2 = "";
    for c in s.strip():
        s1 += conv1[c]
    if len(s1)%5>0 :s1 += "0"*(5-(len(s1)%5))
    for i in xrange(0,len(s1),5):
        s2 += conv2[s1[i:i+5]]
    print s2

Submission status: Wrong Answer

Solution code:
import sys
conv1 = {' ':"101","'":"000000",",":"000011","-":"10010001",".":"010001","?":"000001","A":"100101","B":"10011010","C":"0101","D":"0001","E":"110","F":"01001","G":"10011011","H":"010000","I":"0111","J":"10011000","K":"0110","L":"00100","M":"10011001","N":"10011110","O":"00101","P":"111","Q":"10011111","R":"1000","S":"00110","T":"00111","U":"10011100","V":"10011101","W":"000010","X":"10010010","Y":"10010011","Z":"10010000"}
conv2 = {"00000":"A","00001":"B","00010":"C","00011":"D","00100":"E","00101":"F","00110":"G","00111":"H","01000":"I","01001":"J","01010":"K","01011":"L","01100":"M","01101":"N","01110":"O","01111":"P","10000":"Q","10001":"R","10010":"S","10011":"T","10100":"U","10101":"V","10110":"W","10111":"X","11000":"Y","11001":"Z","11010":" ","11011":".","11100":",","11101":"-","11110":"'","11111":"?"}
for s in sys.stdin.readlines():
    s1 = ""; s2 = "";
    for c in s.strip():
        s1 += conv1[c]
    if len(s1)%5>0 :s1 += "0"*(5-(len(s1)%5))
    for i in xrange(0,len(s1)-1,5):
        s2 += conv2[s1[i:i+5]]
    print s2

Submission status: Wrong Answer

Solution code:
conv1 = {' ':"101","'":"000000",",":"000011","-":"10010001",".":"010001","?":"000001","A":"100101","B":"10011010","C":"0101","D":"0001","E":"110","F":"01001","G":"10011011","H":"010000","I":"0111","J":"10011000","K":"0110","L":"00100","M":"10011001","N":"10011110","O":"00101","P":"111","Q":"10011111","R":"1000","S":"00110","T":"00111","U":"10011100","V":"10011101","W":"000010","X":"10010010","Y":"10010011","Z":"10010000"}
conv2 = {"00000":"A","00001":"B","00010":"C","00011":"D","00100":"E","00101":"F","00110":"G","00111":"H","01000":"I","01001":"J","01010":"K","01011":"L","01100":"M","01101":"N","01110":"O","01111":"P","10000":"Q","10001":"R","10010":"S","10011":"T","10100":"U","10101":"V","10110":"W","10111":"X","11000":"Y","11001":"Z","11010":" ","11011":".","11100":",","11101":"-","11110":"'","11111":"?"}
while 1:
    try:
        s = raw_input()
        s1 = ""; s2 = "";
        for c in s.strip():
            s1 += conv1[c]
        if len(s1)%5>0 :s1 += "0"*(5-(len(s1)%5))
        for i in xrange(0,len(s1),5):
            s2 += conv2[s1[i:i+5]]
        print s2
    except EOFError:
        break

Submission status: Wrong Answer

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

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

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

	# encode
	e, ans = "", ""
	for s in string:
		e += encode[s]
	tmp = []
	while len(e) > 4:
		tmp.append(e[0:5])
		e = e[5:]
	if len(e) != 0:
		e += '0' * (5 - len(e))
		tmp.append(e)
	print tmp

	# decode
	for s in tmp:
		ans += decode[s]
	print ans