Go: package main

import (
	"bufio"
	"os"
	"strings"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	dict := make(map[string]int)
	dict[" "] = 0
	dict["I"] = 1
	dict["V"] = 5
	dict["X"] = 10
	dict["L"] = 50
	dict["C"] = 100
	dict["D"] = 500
	dict["M"] = 1000
	for scanner.Scan() {
		line := strings.Split(scanner.Text(), "")
		line = append(line, " ")
		sum := 0
		for i := 0; i < len(line)-1; i++ {
			if dict[line[i]] < dict[line[i+1]] {
				sum -= dict[line[i]]
			} else {
				sum += dict[line[i]]
			}
		}
		fmt.Println(sum)
	}
}

Python: #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)

from sys import stdin
from re import findall

FIGURE = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}

for line in stdin:
    vs = [FIGURE[s[0]] * len(s) for s in findall('(\w)\1*', line)]
    value = 0
    while vs:
        buf = vs.pop(0)
        if vs and buf < vs[0]:
            value -= buf
        else:
            value += buf
    print(value)

Python: import sys
r={'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000}
for e in sys.stdin:
 a=0
 n=[r[c]for c in e.strip()]
 for i in range(len(n)):
  if i+1<len(n)and n[i]<n[i+1]:a-=n[i]
  else:a+=n[i]
 print(a)

Python: import sys

d = {"I":1, "V":5, "X":10, "L":50, "C":100 ,"D":500,"M":1000}
for line in sys.stdin:
  l = [d[i] for i in line.rstrip()]
  if len(l) == 1:
    print(l[0])
  else:
    s = sum(l)
    for i in range(len(l)-1):
      if l[i] < l[i+1]:
        s -= (2*l[i])
    print(s)

Python: nums={"I":1,"V":5,"X":10,"L":50,"C":100,"D":500,"M":1000}
while True:
    try:
        s=input()
    except:
        break
    ans=nums[s[0]]
    for i in range(len(s)):
        if num[s[i-1]]<num[s[i]]:
            ans+=num[s[i]]-2*num[s[i-1]]
        else:
            ans+=num[s[i]]
    print(ans)

Python: nums={"I":1,"V":5,"X":10,"L":50,"C":100,"D":500,"M":1000}
while True:
    try:
        s=input()
    except:
        break
    ans=nums[s[0]]
    for i in range(1,len(s)):
        if num[s[i-1]]<num[s[i]]:
            ans+=num[s[i]]-2*num[s[i-1]]
        else:
            ans+=num[s[i]]
    print(ans)

Python: dic = {"I":1,"V":5,"X":10,"L":50,"C":100,"D":500,"M":1000}

while(True):
    try:
        lis = list(input())
        ans = [dic[e] for e in lis]
        print(sum([-ans[i] if ans[i]<ans[i+1] else ans[i] for i in range(len(ans)-1)] + [ans[-1]]))
    except:
        break

Python: import sys
r={'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000}
for e in sys.stdin:
 n=[r[c]for c in e.strip()]
 print(sum(n[i]*[1,-1][i+1<len(n)and n[i]<n[i+1]]for i in range(len(n))))

Python: import sys
for line in sys.stdin:
    roman = list(line)
    roman.pop()
    for i in range(len(roman)):
        if roman[i] == 'I':
            roman[i] = 1
        elif roman[i] == 'V':
            roman[i] = 5
        elif roman[i] == 'X':
            roman[i] = 10
        elif roman[i] == 'L':
            roman[i] = 50
        elif roman[i] == 'C':
            roman[i] = 100
        elif roman[i] == 'D':
            roman[i] = 500
        elif roman[i] == 'M':
            roman[i] = 1000
    x = 0
    for i in range(len(roman)):
        if i == len(roman) - 1:
            x += roman[i]
        elif roman[i] < roman[i+1]:
            x -= roman[i]
        else:
            x += roman[i]
        
    print(x)

Python: roman = {'I':1, 'V':5, 'X':10, 'L':50, 'C':100, 'D':500, 'M': 1000}
while(True):
    try:
        x = list(input())
    except:
        break
    
    ans = 0
    i = 0
    
    while i < len(x):
        if i+1 < len(x) and roman[x[i]] < roman[x[i+1]]:
            ans += roman[x[i+1]] - roman[x[i]]
            i += 1
        else: ans += roman[x[i]]
        i += 1
    print(ans)

Python: import sys

d = {
    'I': 1,
    'V': 5,
    'X': 10,
    'L': 50,
    'C': 100,
    'D': 500,
    'M': 1000
}

for s in sys.stdin:
    c = 0
    for i,j in enumerate(list(s)):
        if j == '\n':
            break
        try:
            if j == 'I' and (s[i+1] == 'V' or s[i+1] == 'X'):
                c -= 1
            elif j == 'X' and (s[i+1] == 'L' or s[i+1] == 'C'):
                c -= 10
            elif j == 'C' and (s[i+1] == 'D' or s[i+1] == 'M'):
                c -= 100
            else:
                c += d[j]
        except:
            c += d[j]
    print(c)

Python: while True:
  try:
    n=input()
    count=0
    for i in range(len(n)):
      if i==int(len(n))-1:
        if n[i]=="I":
          count+=1
        elif n[i]=="V":
          count+=5
        elif n[i]=="X":
          count+=10
        elif n[i]=="L":
          count+=50
        elif n[i]=="C":
          count+=100
        elif n[i]=="D":
          count+=500
        elif n[i]=="M":
          count+=1000
      elif n[i]=="I":
        if n[i+1]!="I":
          count-=1
        else:
          count+=1
      elif n[i]=="V":
        if n[i+1]!="I" and n[i+1]!="V":
          count-=5
        else:
          count+=5
      elif n[i]=="X":
        if n[i+1]=="L" or n[i+1]=="C" or n[i+1]=="D" or n[i+1]=="M":
          count-=10
        else:
          count+=10
      elif n[i]=="L":
        if n[i+1]=="C" or n[i+1]=="D" or n[i+1]=="M":
          count-=50
        else:
          count+=50
      elif n[i]=="C":
        if n[i+1]=="D" or n[i+1]=="M":
          count-=100
        else:
          count+=100
      elif n[i]=="D":
        if n[i+1]=="M":
          count-=500
        else:
          count+=500
      elif n[i]=="M":
        count+=1000
    print(count)
  except EOFError:
    break

Python: _input = input()

d = {
    'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000
}


def solve(roma):
    roma_nums = [d[c] for c in roma]
    _sum = 0
    for i, num in enumerate(roma_nums):
        if i == 0 or i == len(roma_nums) - 1:
            _sum += num
            continue
        else:
            try:
                next_num = roma_nums[i + 1]
            except IndexError:
                break

            if next_num <= num:
                _sum += num
            else:
                _sum -= num

    return _sum


if __name__ == '__main__':
    print(solve(_input))

Python: while True:
    try:
        k = input()
        ad = 0

        if ('IV' in k) or ('IX' in k) or ('IL' in k) or ('IC' in k) or ('ID' in k) or ('IM' in k):
            ad += 2

        if ('VX' in k) or ('VL' in k) or ('VC' in k) or ('VD' in k) or ('VM' in k):
            ad += 10

        if ('XL' in k) or ('XC' in k) or ('XD' in k) or ('XM' in k):
            ad += 20

        if ('LC' in k) or ('LD' in k) or ('LM' in k):
            ad += 100

        if ('CD' in k) or ('CM' in k):
            ad += 200

        if 'DM' in k:
            ad += 1000

        s = list(k)

        for i in range(len(s)):
            if s[i] == 'I':
                s[i] = 1
            elif s[i] == 'V':
                s[i] = 5
            elif s[i] == 'X':
                s[i] = 10
            elif s[i] == 'L':
                s[i] = 50
            elif s[i] == 'C':
                s[i] = 100
            elif s[i] == 'D':
                s[i] = 500
            else:
                s[i] = 1000

        print(sum(s) - ad)


    except EOFError:
        break

Python: dic = {"I":1, "V":5, "X":10, "L":50, "C":100 ,"D":500,"M":1000}

while True:
  try:
    line = [dic[i] for i in input()]
    acc = 0

    for i in range(len(line) - 1):
      if line[i] < line[i + 1]:
        acc -= line[i]
      else:
        acc += line[i]

    acc += line[-1]
    print(acc)

  except EOFError:
    break

Python: import sys
r={'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000}
for e in sys.stdin:
 n=[r[c]for c in e[:-1]]
 print(sum(n[i]*[1,-1][i+1<len(n)and n[i]<n[i+1]]for i in range(len(n))))