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

int num_from_roma(string roma, int x) {
	if (roma[x] == 'I')return 1;
	else if (roma[x] == 'V')return 5;
	else if (roma[x] == 'X')return 10;
	else if (roma[x] == 'L')return 50;
	else if (roma[x] == 'C')return 100;
	else if (roma[x] == 'D')return 500;
	else if (roma[x] == 'M')return 1000;
}
int main() {
	string roma; int total;
	while (cin >> roma) {
		total = 0;
		for (int i = 0; i < roma.size()-1; i++) {
			if (num_from_roma(roma, i) < num_from_roma(roma, i + 1))total -= num_from_roma(roma, i);
			else total += num_from_roma(roma, i);
		}
		cout << total+num_from_roma(roma,roma.size()-1) << endl;
	}
}

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

int main(void){
	string str;
	map<string, int> num;
	num.insert( map<string,int>::value_type("I",1));
	num.insert( map<string,int>::value_type("II",2));
	num.insert( map<string,int>::value_type("III",3));
	num.insert( map<string,int>::value_type("IV",4));
	num.insert( map<string,int>::value_type("V",5));
	num.insert( map<string,int>::value_type("VI",6));
	num.insert( map<string,int>::value_type("VII",7));
	num.insert( map<string,int>::value_type("VIII",8));
	num.insert( map<string,int>::value_type("IX",9));
	num.insert( map<string,int>::value_type("X",10));
	num.insert( map<string,int>::value_type("XI",11));
	num.insert( map<string,int>::value_type("XII",12));
	num.insert( map<string,int>::value_type("XIII",13));
	num.insert( map<string,int>::value_type("XIV",14));
	num.insert( map<string,int>::value_type("XV",15));
	num.insert( map<string,int>::value_type("XVI",16));
	num.insert( map<string,int>::value_type("XVII",17));
	num.insert( map<string,int>::value_type("XVIII",18));
	num.insert( map<string,int>::value_type("XIX",19));
	num.insert( map<string,int>::value_type("XX",20));
	num.insert( map<string,int>::value_type("XXX",30));
	num.insert( map<string,int>::value_type("XL",40));
	num.insert( map<string,int>::value_type("L",50));
	num.insert( map<string,int>::value_type("LX",60));
	num.insert( map<string,int>::value_type("LXX",70));
	num.insert( map<string,int>::value_type("LXXX",80));
	num.insert( map<string,int>::value_type("XC",90));
	num.insert( map<string,int>::value_type("C",100));
	num.insert( map<string,int>::value_type("CD",400));
	num.insert( map<string,int>::value_type("D",500));
	num.insert( map<string,int>::value_type("CM",900));
	num.insert( map<string,int>::value_type("M",1000));
	while(cin >> str){
		int ans=0;
		string s;
		for(int i=0;i<str.size();i++){
			string ss=s;
			s+=str[i];
			if(num[s]==0){
				if(num[ss]>0){
					ans+=num[ss];
					s=str[i];
				}
			}
			if(i==str.size()-1){
				ans+=num[s];
			}
		}
		printf("%d\n",ans);
	}
    return 0;
}

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

int main(void){
  char s[104];
	int alpha[256];

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

	while(scanf("%s",s) != EOF){
		int sum = 0;
		int len = strlen(s);

		for(int i=0;i<len;i++){
			if(alpha[s[i]] >= alpha[s[i+1]]){
				sum += alpha[s[i]];
			}
			else{
				sum -= alpha[s[i]];
			}
		}
		cout<<sum<<endl;
	}

  return 0;
}

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

using namespace std;

int main()
{
    string input;
    map<char, int> alpha;

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

    while (cin >> input) {
        long long ans = 0;
        
        input += 'A';

        for (int i = 0; i < input.size(); ) {
            if (alpha[input[i]] >= alpha[input[i + 1]]) {
                ans += alpha[input[i]];
                i++;
            }
            else {
                ans += (alpha[input[i + 1]] - alpha[input[i]]);
                i += 2;
            }
        }

        cout << ans << endl;
    }

    return 0;
}

C++:  #include<stdio.h>

int main(){
char ch;
char p[101]={};
int sum;
int w,b,a;
sum=0;ch=NULL;w=0;b=0;a=0;
//scanf("%s",p);printf("%c",(p[1]));
while(scanf("%s",p)!=EOF)
{
for(int i=0;i<101;i++){

	ch=p[i];
 if(ch=='I')w=1;
else if(ch=='V')w=5;
else if(ch=='X')w=10;
else if(ch=='L')w=50;
else if(ch=='C')w=100;
else if(ch=='D')w=500;
else if(ch=='M')w=1000;
switch(w){
case 1:
a=1;break;
case 5:
	if(b==1){a=3;break;}
else  if(b!=1)a=5;break;
case 10:
if(b==1){a=8;break;}
else  if(b!=1)a=10;break;
case 50:
if(b==10){a=30;break;}
else  if(b!=10)a=50;break;
case 100:
if(b==10){a=80;break;}
else  if(b!=10)a=100;break;
case 500:
if(b==100){a=300;break;}
else  if(b!=100)a=500;break;
case 1000:
if(b==100){a=800;break;}
else  if(b!=100)a=1000;break;
}

sum+=a;b=a;
ch='\0';w=0;a=0;
}
printf( "%d\n",sum);
sum=0;ch='\0';w=0;b=0;a=0;
for(int i=0;i<101;i++)
	p[i]='\0';


}

return 0;
}

C++: /*#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>
*/
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define rrep()
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    map<char,int> mp;
    
    mp['I']=1;
    mp['V']=5;
    mp['X']=10;
    mp['L']=50;
    mp['C']=100;
    mp['D']=500;
    mp['M']=1000;
    
    string s;
    while(cin>>s){
        int ans=0;
        rep(i,0,s.length()-1){
            if(mp[s[i]]<mp[s[i+1]]) {
                ans-=mp[s[i]]; 
            }
            else ans+=mp[s[i]];
        }
        cout<<ans+mp[s[s.length()-1]]<<endl;
    }
    
    return 0;
}

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

int main(){
	string str;
	while(cin >> str){
		int ans = 0;
		vector<int> array;
		for(int i = 0; i < str.size(); i++){
			if(str[i] == 'I'){
				array.push_back(1);
			}
			else if(str[i] == 'V'){
				array.push_back(5);
			}
			else if(str[i] == 'X'){
				array.push_back(10);
			}
			else if(str[i] == 'L'){
				array.push_back(50);
			}
			else if(str[i] == 'C'){
				array.push_back(100);
			}
			else if(str[i] == 'D'){
				array.push_back(500);
			}
			else{
				array.push_back(1000);
			}
		}
		for(int i = 0; i < array.size()-1; i++){
			if(array[i] < array[i+1]){
				array[i] = -1*array[i];
			}
		}
		for(int i = 0; i < array.size(); i++){
			ans = ans+array[i];
		}
		cout << ans << endl;
	}
}