Buggy python submission (verdict: Time Limit Exceeded):
import string
s = {i : "{:05b}".format(c) for i, c in zip(string.ascii_uppercase+" .,-'?", range(32))}
code = {'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'}

while True:
    try:
        data = input()
    except:
        break
    d = ''.join(s[c] for c in data)
    ans = ""
    a, i = 0, 3
    while a+i != len(d):
        i = 3
        while True:
            if code.get(d[a:a+i], None) is not None:
                ans += code[d[a:a+i]]
                a += i
                break
            i += 1
    print(ans)

Fixed submission:
import string
s = {i : "{:05b}".format(c) for i, c in zip(string.ascii_uppercase+" .,-'?", range(32))}
code = {'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'}

while True:
    try:
        data = input()
    except:
        break
    d = ''.join(s[c] for c in data)
    ans=tmp=""
    for c in d:
        tmp += c
        if tmp in code:
            ans += code[tmp]
            tmp = ""
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import string
s = {i : "{:05b}".format(c) for i, c in zip(string.ascii_uppercase+" .,-'?", range(32))}
code = {'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'}

while True:
    try:
        data = input()
    except:
        break
    d = ''.join(s[c] for c in data)
    ans = ""
    a, i = 0, 3
    while a+i != len(d):
        i = 3
        while i<9:
            if code.get(d[a:a+i], None) is not None:
                ans += code[d[a:a+i]]
                a += i
                break
            i += 1
    print(ans)

Fixed submission:
import string
s = {i : "{:05b}".format(c) for i, c in zip(string.ascii_uppercase+" .,-'?", range(32))}
code = {'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'}

while True:
    try:
        data = input()
    except:
        break
    d = ''.join(s[c] for c in data)
    ans=tmp=""
    for c in d:
        tmp += c
        if tmp in code:
            ans += code[tmp]
            tmp = ""
    print(ans)