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)
	}
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
	for(;;){
		int f=0,row[100] = {0},i;
		for(i=0;;i++){
			char c;
			if(scanf("%c",&c) == EOF){f = 1;break;}
			if(c == '\n'){break;}
			else if(c == 'I'){row[i] = 1;}
			else if(c == 'V'){row[i] = 5;}
			else if(c == 'X'){row[i] = 10;}
			else if(c == 'L'){row[i] = 50;}
			else if(c == 'C'){row[i] = 100;}
			else if(c == 'D'){row[i] = 500;}
			else if(c == 'M'){row[i] = 1000;}
		}
		row[i+1] = 0;
		if(f == 1){break;}
		int sum = 0;
		for(int j=0; j<i; j++){
			if(row[j]>=row[j+1]){sum+=row[j];}
			else if(row[j]<row[j+1]){sum+=row[j+1]-row[j];j++;}
		}
		cout <<sum<<endl;
	}
}

C++: #include <iostream>
#include <cstdio>
#include <string>
using namespace std;
const string ara = "IVXLCDM\0";
const int integer[8] = {1,5,10,50,100,500,1000}; 
int Input(int num[],string in);
void Output(int p,int num[]);
 
int main(void){
  string in;
  int num[1000];

  while( cin >> in ){
    for(int i = 0 ; i < 1000; i++)num[i] = 0;
    int p = Input(num,in);
    Output(p,num);
  }
  return 0;
}

int Input(int num[],string in){

  int p = 0;
  for(int i = 0 ; i < (int)in.size(); i++){
    for(int j = 0 ; ara[j] != '\0'  ; j++ ){
      if(in[i] == ara[j]){
	num[p++] = integer[j];
	break;
      }
    }
  }
  return p;
}

void Output(int p,int num[]){
  int ans  = 0;
  for(int i = 0 ;i < p ; i++){

    if(num[i] < num[i+1]){
      ans += (num[i+1] - num[i]);
      i++;
    } else ans+=num[i];
  }
  cout << ans << endl;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }



int main()
{
	string str;
	map<char, int> p;

	p.insert(map<char, int>::value_type('I', 1));
	p.insert(map<char, int>::value_type('V', 5));
	p.insert(map<char, int>::value_type('X', 10));
	p.insert(map<char, int>::value_type('L', 50));
	p.insert(map<char, int>::value_type('C', 100));
	p.insert(map<char, int>::value_type('D', 500));
	p.insert(map<char, int>::value_type('M', 1000));


	while(cin >> str)
	{
		int len = str.size();
		vint num(len);

		rep(i, len)
			num[i] = p[str[i]];

		int res = num[len-1];
		rep(i, len-1)
		{
			if(num[i+1] <= num[i])
			{
				res += num[i];
			}
			else
			{
				res -= num[i];
				if(i + 1 != len - 1) res += num[i+1];
				i++;
			}
		}

		cout << res << endl;
	}
}

C++: #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    string s;
    map<char, int> rom;
    rom['I'] = 1;
    rom['V'] = 5;
    rom['X'] = 10;
    rom['L'] = 50;
    rom['C'] = 100;
    rom['D'] = 500;
    rom['M'] = 1000;
    while (cin >> s)
    {
        int sum = 0;
        for (int i = 0; i < s.size() - 1; i++)
        {
            if (rom[s[i]] < rom[s[i + 1]])
            {
                sum -= rom[s[i]];
            }
            else
            {
                sum += rom[s[i]];
            }
        }
        OP(sum + rom[s[s.size() - 1]])
    }
    return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;

int c[128];

void init(){
  c['I'] = 1;   c['V'] = 5;   c['X'] = 10;   c['L'] = 50; 
  c['C'] = 100; c['D'] = 500; c['M'] = 1000;
}

int main(){
  string str;

  init();

  while(cin >> str){
    int sum = 0;
   
    for(int i = 0 ; i < str.size()-1 ; i++){
      sum += c[str[i]]*((c[str[i]] < c[str[i+1]]) ? -1 : 1);
    }
    sum += c[str[str.size()-1]];

    cout << sum << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<map>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
main(){
  map<char,int> kioku;
  kioku['I']=1;
  kioku['V']=5;
  kioku['X']=10;
  kioku['L']=50;
  kioku['C']=100;
  kioku['D']=500;
  kioku['M']=1000;
  char tmp[1000];
  char c;
  int num=0;
  int before=0;
  while(cin>>tmp){
    for(int i=0;i<strlen(tmp);i++){
      if(i!=strlen(tmp)-1){
	if(kioku[tmp[i+1]]>kioku[tmp[i]]){
	  num+=abs(kioku[tmp[i]]-kioku[tmp[i+1]]);
	  i++;
	}
	else{
	  num+=kioku[tmp[i]];
	}
      }
      else{
	num+=kioku[tmp[i]];
      }
    }
    cout<<num;
    num=0;
  }
}

C++: #include <stddef.h>
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main() {
  size_t i, r;
  string s;
  map<char, int> m;
  m['I'] = 1;
  m['V'] = 5;
  m['X'] = 10;
  m['L'] = 50;
  m['C'] = 100;
  m['D'] = 500;
  m['M'] = 1000;
  while (cin >> s) {
    for (i = r = 0; i < s.size(); i++)
      r += m[s[i]] * (m[s[i]] < m[s[i + 1]] ? -1 : 1);
    cout << r << endl;
  }
}

C++: #include<iostream>
#include<string>
#include<map>

using namespace std;

int Search(char, map<int, char>);

int main(){
  int i, n, m, Arabic;
  string str;
  map<int, char> Roman;

  Roman[1] = 'I';
  Roman[5] = 'V';
  Roman[10] = 'X';
  Roman[50] = 'L';
  Roman[100] = 'C';
  Roman[500] = 'D';
  Roman[1000] = 'M';

  while(cin >> str){
    Arabic = 0;
    i = 0;
    while(i < str.size()-1){
      n = Search(str[i], Roman);
      m = Search(str[i+1], Roman);

      if(n < m){
	Arabic += (m-n);
	i += 2;
      }else{
	Arabic += n;
	++i;
	if(i == str.size()-1)
	  Arabic += m;
      }
    }

    cout << Arabic << endl;
  }

  return 0;
}

int Search(char c, map<int, char> x){
  map<int, char>::iterator iter = x.begin();
  while(iter != x.end()){
    if(c == iter->second)
      return iter->first;
    ++iter;
  }
  return 0;
}