Buggy python submission (verdict: Runtime Error):
#encoding=utf-8
import sys

def inp():
    for line in sys.stdin:
        word = line.split()
        je(word[0])

def je(word):
    ans, i = 0, 0
    while True:
        print word[i], ans
        if word[i] == "M":
            ans += 1000
        elif word[i] == "D":
            ans += 500
        elif word[i] == "C":
            ans += 100
            try:
                if word[i + 1] == "D":
                    ans += 300
                    i += 1
                elif word[i + 1] == "M":
                    ans += 800
                    i += 1
            except:pass
        elif word[i] == "L":
            ans += 50
            try:
                if word[i - 1] == "X":
                    ans -= 10
                    i += 1
            except: pass
        elif word[i] == "X":
            ans += 10
            try:
                if word[i + 1] == "I" and word[i + 2] == "X":
                    ans += 9
                    i += 2
                elif word[i + 1] == "C":
                    ans += 80
                    i += 1

            except: pass
        elif word[i] == "V":
            ans += 5
        elif word[i] == "I":
            ans += 1
            try:
                if word[i + 1] == "V":
                    ans += 4
                    i += 1
                if word[i + 1] == "X":
                    ans += 8
                    i += 1
            except: pass
        i += 1
        if i == len(word):
            print ans
            break

if __name__ == "__main__":
    inp()

Fixed submission:
#encoding=utf-8
import sys

def inp():
    for line in sys.stdin:
        word = line.split()
        je(word[0])

def je(word):
    ans, i = 0, 0
    while True:
        if word[i] == "M":
            ans += 1000
        elif word[i] == "D":
            ans += 500
        elif word[i] == "C":
            ans += 100
            try:
                if word[i + 1] == "M":
                    ans += 800
                    i += 1
                elif word[i + 1] == "D":
                    ans += 300
                    i += 1
            except: pass

        elif word[i] == "L":
            ans += 50
        elif word[i] == "X":
            ans += 10
            try:
                if word[i + 1] == "C":
                    ans += 80
                    i += 1
                elif word[i + 1] == "L":
                    ans += 30
                    i += 1
            except: pass

        elif word[i] == "V":
            ans += 5
        elif word[i] == "I":
            ans += 1
            try:
                if word[i + 1] == "X":
                    ans += 8
                    i += 1
                elif word[i + 1] == "V":
                    ans += 3
                    i += 1
            except: pass

        i += 1
        if i == len(word):
            print ans
            break

if __name__ == "__main__":
    inp()

Buggy python submission (verdict: Runtime Error):
import sys

def inp():
    for line in sys.stdin:
        word = line.split()
        je(word[0])

def je(word):
    ans, i = 0, 0
    while True:
        if word[i] == "M":
            ans += 1000
        elif word[i] == "D":
            ans += 500
        elif word[i] == "C":
            ans += 100
            try:
                if word[i + 1] == "D":
                    ans += 300
                    i += 1
                elif word[i + 1] == "M":
                    ans += 800
                    i += 1
            except:pass
        elif word[i] == "L":
            ans += 50
            try:
                if word[i - 1] == "X":
                    ans -= 10
                    i += 1
            except: pass
        elif word[i] == "X":
            ans += 10
            try:
                if word[i + 1] == "I" and word[i + 2] == "X":
                    ans += 9
                    i += 2
                elif word[i + 1] == "C":
                    ans += 80
                    i += 1

            except: pass
        elif word[i] == "V":
            ans += 5
        elif word[i] == "I":
            ans += 1
            try:
                if word[i + 1] == "V":
                    ans += 4
                    i += 1
                if word[i + 1] == "X":
                    ans += 8
                    i += 1
            except: pass
        i += 1
        if i == len(word):
            print ans
            break

if __name__ == "__main__":
    inp()

Fixed submission:
#encoding=utf-8
import sys

def inp():
    for line in sys.stdin:
        word = line.split()
        je(word[0])

def je(word):
    ans, i = 0, 0
    while True:
        if word[i] == "M":
            ans += 1000
        elif word[i] == "D":
            ans += 500
        elif word[i] == "C":
            ans += 100
            try:
                if word[i + 1] == "M":
                    ans += 800
                    i += 1
                elif word[i + 1] == "D":
                    ans += 300
                    i += 1
            except: pass

        elif word[i] == "L":
            ans += 50
        elif word[i] == "X":
            ans += 10
            try:
                if word[i + 1] == "C":
                    ans += 80
                    i += 1
                elif word[i + 1] == "L":
                    ans += 30
                    i += 1
            except: pass

        elif word[i] == "V":
            ans += 5
        elif word[i] == "I":
            ans += 1
            try:
                if word[i + 1] == "X":
                    ans += 8
                    i += 1
                elif word[i + 1] == "V":
                    ans += 3
                    i += 1
            except: pass

        i += 1
        if i == len(word):
            print ans
            break

if __name__ == "__main__":
    inp()