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 <vector>
using namespace std;

int main(){
	char input[100];
	vector<int> v;
	int tmp,sum;

	while(cin>>input){
		sum=0;
		for(int i=0;input[i]!='\0';i++){
			if(input[i]!='\n'){
				if(input[i]=='I'){
					v.push_back(1);
				}else if(input[i]=='V'){
					v.push_back(5);
				}else if(input[i]=='X'){
					v.push_back(10);
				}else if(input[i]=='L'){
					v.push_back(50);
				}else if(input[i]=='C'){
					v.push_back(100);
				}else if(input[i]=='D'){
					v.push_back(500);
				}else if(input[i]=='M'){
					v.push_back(1000);
				}
			}
		}

		tmp=v[0];sum+=tmp;
		for(int i=1;i<v.size();i++){
			if(tmp>=v[i]){
				sum+=v[i];
			}else{
				sum+=v[i]-2*tmp;
			}
			tmp=v[i];
		}

		cout<<sum<<endl;
		v.clear();
	}
}

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

using namespace std;

int main(void){
	
	
	vector<int> temp;
	vector<int> num;
	char ruman_num[100];
	int sum;
	
	
	while(scanf("%s",ruman_num)!=EOF){
		sum=0;
		
		for(int i=0;i<100;i++){
			if(ruman_num[i]=='I'){
				num.push_back(1);
			}else if(ruman_num[i]=='V'){
				num.push_back(5);
			}else if(ruman_num[i]=='X'){
				num.push_back(10);
			}else if(ruman_num[i]=='L'){
				num.push_back(50);
			}else if(ruman_num[i]=='C'){
				num.push_back(100);
			}else if(ruman_num[i]=='D'){
				num.push_back(500);
			}else if(ruman_num[i]=='M'){
				num.push_back(1000);
			}
		}
		
		
		for(int i=0;i<(num.size())-1;i++){
			if(num[i]<num[i+1]){
				temp.push_back(num[i+1]-num[i]);
				i++;
			}else{
				temp.push_back(num[i+1]+num[i]);
				i++;
			}
		}
			
			
		for(int i=0;i<temp.size();i++){
			sum=sum+temp[i];
		}
			
			
		cout<<sum<<endl;
		temp.clear();
		num.clear();
		for(int i=0;i<100;i++){
			ruman_num[i]='0';
		}
	}
	return 0;
}

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

string str;
int convert(char a){
    if(a == 'I') return 1;
    else if(a == 'V') return 5;
    else if(a == 'X') return 10;
    else if(a == 'L') return 50;
    else if(a == 'C') return 100;
    else if(a == 'D') return 500;
    else return 1000;
}
int main(){
    bool state=false;
    int a, b;
    int ans;
    int i;
    while(cin >> str){
        ans = 0;
        for(i=1;i<str.size();i++){
            a = convert(str[i-1]);
            b = convert(str[i]);
            if(a < b){
                ans+=b-a;
                i++;
            }else{
                ans+=a;
            }
        }
        if(i==str.size()){
            ans += convert(str[i-1]);
        }
        cout << ans << endl;
    }
}

C++: #include<iostream>
using namespace std;
int main(){
  string s;
  while(cin >>s){
    int ans = 0,a,b=100000;
    for(int i=0; i<s.size(); i++){
      if(s[i] == 'I') a = 1;
      if(s[i] == 'V') a = 5;
      if(s[i] == 'X') a = 10;
      if(s[i] == 'L') a = 50;
      if(s[i] == 'C') a = 100;
      if(s[i] == 'D') a = 500;
      if(s[i] == 'M') a = 1000;
      ans+=a;
      if(b<a) ans-=b*2;
      b = a;
    }
    cout <<ans<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

#define pci pair<char,int>
int main() {
  map<char,int> hoge;
  hoge.insert(pci('I',1));
  hoge.insert(pci('V',5));
  hoge.insert(pci('X',10));
  hoge.insert(pci('L',50));
  hoge.insert(pci('C',100));
  hoge.insert(pci('D',500));
  hoge.insert(pci('M',1000));

  string s;
  while(cin >> s) {
    vector<int> v;
    REP(i,s.length()) {
      v.push_back((*hoge.find(s[i])).second);
    }
    int ans = 0;
    REP(i,v.size()) {
      if (i<v.size()-1 && v[i]<v[i+1])
        ans -= v[i];
      else
        ans += v[i];
    }
    cout << ans << endl;
  }
}

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

int main() {
  string str;
  while(getline(cin, str)) {
    int before = 0;
    int now;
    int ans = 0;
    for(int i = 0; i < str.length(); i++) {
      switch(str[i]) {
      case 'I': now = 1; break;
      case 'V': now = 5; break;
      case 'X': now = 10; break;
      case 'L': now = 50; break;
      case 'C': now = 100; break;
      case 'D': now = 500; break;
      case 'M': now = 1000; break;
      }
      if(now > before) {
	ans = ans - before + (now - before);
      } else {
	ans += now;
      }

      before = now;
    }


    cout << ans << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
using namespace std;
int main(){
	
	
	string d;
	map<char,int> a;
	a['I']=1;
	a['V']=5;
	a['X']=10;
	a['L']=50;
	a['C']=100;
	a['D']=500;
	a['M']=1000;
	while(cin>>d){
	int s=0,m=100000000;
	for(int i=0;i<d.size();i++){
		int k=a[d[i]];
		if(m<k) s-=m*2;
		s+=k;
		m=k;			
	}
	
	cout<<s<<endl;
	}
	
}

C++: #include <cstdio>
#include <map>

using namespace std;

int main()
{
	map <string, int> list;
	
	list["I"] = 1;
	list["V"] = 5;
	list["X"] = 10;
	list["L"] = 50;
	list["C"] = 100;
	list["D"] = 500;
	list["M"] = 1000;
	list["N"] = 0;
		
	char s[10001];
	while(scanf("%s", s) != EOF){
		string str = s;
		string str_next = s;
		
		int len = str.size();
		int sum = 0;
		
		
		for(int i = 0; i < len; i++){
			str = s[i];
			str_next = s[i+1];
			
			if(list[str] < list[str_next]){
				sum += list[str_next] - list[str];
				i++;
			}
			
			else sum += list[str];
		}
		
		printf("%d\n", sum);
	}
}

C++: #include<cstdio>
#include<cstring>

using namespace std;
int main(void)
{
	char r[100000];
	int kari[100000] = {0};
	while(scanf("%s",r) != EOF)
	{
		long long int ans = 0;
		int rs = strlen(r);
		for(int i = 0;i < rs;i++)
		{
			     if(r[i] == 'I') kari[i] = 1;
			else if(r[i] == 'V') kari[i] = 5;
			else if(r[i] == 'X') kari[i] = 10;
			else if(r[i] == 'L') kari[i] = 50;
			else if(r[i] == 'C') kari[i] = 100;
			else if(r[i] == 'D') kari[i] = 500;
			else if(r[i] == 'M') kari[i] = 1000;
		}

		for(int i = 0;i < rs - 1;i++)
		{
			if(kari[i] < kari[i+1]) ans -= kari[i];
			else ans += kari[i];
		}
		ans += kari[rs -1];
		printf("%lld\n",ans);
	}
	return 0;
}

C++: #include<cstdio>
#include<cmath>
#include <stdlib.h>
#include<algorithm>

using namespace std;

int main(){
	int ans;
	char sen[100];
	while( scanf("%s",&sen) != EOF ){
		ans=0;
		for(int i=0;sen[i]!='\0';i++){
			if(sen[i]=='I'){
				if(sen[i+1]=='V'||sen[i+1]=='X'){
					ans--;
				}
				else{
					ans++;
				}
			}
			if(sen[i]=='V'){
				ans+=5;
			}
			if(sen[i]=='X'){
				if(sen[i+1]=='L'||sen[i+1]=='C'){
					ans-=10;
				}
				else{
					ans+=10;
				}
			}
			if(sen[i]=='L'){
				ans+=50;
			}
			if(sen[i]=='C'){
				if(sen[i+1]=='D'||sen[i+1]=='M'){
					ans-=100;
				}
				else{
					ans+=100;
				}
			}
			if(sen[i]=='D'){
				ans+=500;
			}
			if(sen[i]=='M'){
				ans+=1000;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}