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 <queue>
using namespace std;
??
??
int check(char c){
????if(c == 'I') return 1;
????else if(c == 'V') return 5;
????else if(c == 'X') return 10;
????else if(c == 'L') return 50;
????else if(c == 'C') return 100;
????else if(c == 'D') return 500;
????else if(c == 'M') return 1000;
}
??
int main(void){
????string str;
????while(cin >> str){
????????int ans = 0;
????????for(int i = 0; i < str.size() - 1; i++){
????????????if(check(str[i]) >= check(str[i+1])) ans += check(str[i]);
????????????else ans -= check(str[i]);
????????}
????????ans += check(str[str.size() - 1]);
????????cout << ans << endl;
????}
????return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>

typedef long long ll;
using namespace std;

//char name[] = {'I','V','X','L','C','D','M'};
//int num[] = {1,5,10,50,100,500,1000};

int roma2num(char c){
	return c=='I'? 1:
		c=='V'? 5:
		c=='X'? 10:
		c=='L'? 50:
		c=='C'? 100:
		c=='D'? 500: 1000;
}

int main(){
	string str;
	while(1){
		cin >> str;
		int sum=0;
		int idx=0;
		for(int i=0;i<str.size()-1;i++){
			int now = roma2num(str[i]);
			int next = roma2num(str[i+1]);

			if(now >= next){
				sum += now;
			}else{
				sum += next - now;
				i++;
			}
			idx=i;
		}

		if(idx < str.size()) sum += roma2num(str[idx]);

		cout << sum << endl;

		if(cin.eof()) break;
	}
}

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

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

C++: #include<iostream>
#include<string>
int main() {
	std::string s;
	while (std::cin >> s){
		int sum = 0;
		for (int i = 0; i != s.size(); i++){
			if (s[i] == 'I'){
				if (s[i + 1] == 'V') {
					sum += 4;i++;
				}
				else if (s[i + 1] == 'X'){
					sum += 9; i++;
				}
				else sum++;
			}
			else if (s[i] == 'V')sum += 5;
			else if (s[i] == 'X'){
				if (s[i + 1] == 'L'){
					sum += 40;i++;
				}
				else if (s[i + 1] == 'C'){
					sum += 90;i++;
				}
				else sum += 10;
			}
			else if (s[i] == 'L')sum += 50;
			else if (s[i] == 'C') {
				if (s[i + 1] == 'D'){
					sum += 400; i++;
				}
				else if (s[i + 1] == 'M'){
					sum += 900; i++;
				}
			}
			else if (s[i] == 'D')sum += 500;
			else if (s[i] == 'M')sum += 1000;
		}
		std::cout << sum << std::endl;
	}
}

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

int main() {
  string n;

  while (cin >> n) {

    n += ".";

    int num[] = {1, 5, 10, 50, 100, 500, 1000};
    char ch[] = {'I', 'V', 'X', 'L', 'C', 'D', 'M'};

    int cnt = 0;
    vector<int> a;
    for (int i = 0; i < n.size(); ++i) {
      int x = 0;
      for (int j = 0; j < 7; ++j) {
        if (n[i] == ch[j]) x = num[j];
      }
      cnt += x;
      if (n[i] == n[i + 1]) continue;
      a.push_back(cnt);
      cnt = 0;
    }

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

    cout << ans << endl;
  }
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;
int st(char t)
{
	switch(t)
	{
		case 'I':return 1;
		case 'V':return 5;
		case 'X':return 10;
		case 'L':return 50;
		case 'C':return 100;
		case 'D':return 500;
		case 'M':return 1000;
		default :return 0;
	}
}
int main()
{
	char num[101];
	while(cin >> num)
	{
		int ans=0;
		int len=strlen(num);
		for(int i=0;i<len;i++)
		{
			if(st(num[i])<st(num[i+1]))
			{
				ans -= st(num[i]);
				continue;
			}
			ans += st(num[i]);
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <stdio.h>

int main(void){
    char fig[101];
    int num;
    
    while (scanf("%s", fig) != EOF){
        num = 0;
        for (char *pt=fig; *pt!='\0'; pt++){
            switch (*pt){
            case 'I':
                switch(*(pt+1)){
                case 'V':
                    num += 4;
                    pt++;
                    break;
                case 'X':
                    num += 9;
                    pt++;
                    break;
                default:
                    num += 1;
                    break;
                }
                break;
            case 'V':
                num += 5;
                break; 
            case 'X':
                switch(*(pt+1)){
                case 'L':
                    num += 40;
                    pt++;
                    break;
                case 'C':
                    num += 90;
                    pt++;
                    break;
                default:
                    num += 10;
                    break;
                }
                break;
            case 'L':
                num += 50;
                break;
            case 'C':
                switch(*(pt+1)){
                case 'D':
                    num += 400;
                    pt++;
                    break;
                case 'M':
                    num += 900;
                    pt++;
                    break;
                default:
                    num += 100;
                    break;
                }
                break;
            case 'D':
                num += 500;
                break;
            case 'M':
                num += 1000;
                break;
            }
        }
        printf("%d\n", num);
    }
        
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main(void)
{
    ios::sync_with_stdio(false);
    string s;

    map<char, int> conv;
    conv['I'] =1;
    conv['V'] =5;
    conv['X'] =10;
    conv['L'] =50;
    conv['C'] =100;
    conv['D'] =500;
    conv['M'] =1000;

    while(cin >> s) {
        long ans = 0;
        for(int i=0; i<s.size()-1; i++) {
            if(conv[s[i]] < conv[s[i+1]])
                ans -= conv[s[i]];
            else
                ans += conv[s[i]];
        }
        ans += conv[s[s.size()-1]];
        cout << ans << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
#define MCI map<char,int>
using namespace std;
int main()
{
  MCI m;
  m.insert(MCI::value_type('I',1));
  m.insert(MCI::value_type('V',5));
  m.insert(MCI::value_type('X',10));
  m.insert(MCI::value_type('L',50));
  m.insert(MCI::value_type('C',100));
  m.insert(MCI::value_type('D',500));
  m.insert(MCI::value_type('M',1000));

  string s;
  while(cin >> s){
    int l = s.length();
    char p = s[0];
    int n=0;
    for(int i=1;i<l;i++){
      char c = s[i];
      if(m[p] < m[c]) n -= m[p];
      else n += m[p];
      p = c;
    }
    n += m[p];
    cout << n << endl;
  }
  return 0;
}