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>
#include <map>
using namespace std;
#define sz(c) int((c).size())

int parse(map<char, int>& m, string& s)
{
  int i, res, cur, next;
  res = 0;
  for (int i = 0; i < sz(s) - 1; i++) {
    cur = m[s[i]]; next = m[s[i+1]];
    if (cur < next)
      res -= cur;
    else
      res += cur;
  }
  res += next;
  return res;
}

int main(int argc, char **argv)
{
  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;

  for (;;) {
    cin >> s;
    if (cin.eof())
      break;
    cout << parse(m, s) << endl;
  }

  return 0;
}

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

string index="IVXLCDM";
int trans[]={1,5,10,50,100,500,1000};

int t_num(char c){
	for(int i=0;i<index.size();i++){
		if(c==index[i]){
			return trans[i];
		}
	}
}

int main(){
	string input;
	while(cin>>input){
		int ans=0;
		vector<int> in;
		for(int i=0;i<input.size();i++){
			in.push_back(t_num(input[i]));
		}
		int tmp=0;
		tmp=in[0];
		for(int i=1;i<in.size();i++){
			if(in[i]>in[i-1]){
				tmp=in[i]-tmp;
			}else if(in[i]<in[i-1]){
				ans+=tmp;
				tmp=in[i];
			}else{
				tmp+=in[i];
			}
		}
		ans+=tmp;
		cout<<ans<<endl;
		
	}
	return 0;
}

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

using namespace std;

int main(void){
	
	
	char ruman_num[100];
	int sum=0,temp[100],num[100];
	
	
	while(cin>>ruman_num){
	
		
		for(int i=0;i<100;i++){
			ruman_num[i]='0';
			temp[i]=num[i]=0;
		}
		
		
		for(int i=0;i<100;i++){
			if(ruman_num[i]=='0'){
				break;
			}
			if(ruman_num[i]=='I'){
				num[i]=1;
			}else if(ruman_num[i]=='V'){
				num[i]=5;
			}else if(ruman_num[i]=='X'){
				num[i]=10;
			}else if(ruman_num[i]=='L'){
				num[i]=50;
			}else if(ruman_num[i]=='C'){
				num[i]=100;
			}else if(ruman_num[i]=='D'){
				num[i]=500;
			}else if(ruman_num[i]=='M'){
				num[i]=1000;
			}
		}
		
		
		for(int i=0;i<99;i++){
			if(num[i]==0){
				break;
			}
			if(num[i]<num[i+1]){
				temp[i]=num[i+1]-num[i];
			}
		}
		for(int i=0;i<100;i++){
			sum=sum+temp[i];
		}
		cout<<sum<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
 
using namespace std;
 
const double eps=1e-10;

int main()
{
	string s;

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

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


	return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int a, b, n;
  while (cin >> a >> b >> n) {
    a %= b;
    int s = 0;
    rep(i, n) {
      a *= 10;
      s += a / b % 10;
      a %= b;
    }
    cout << s << endl;
  }
}

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

char ary[200];
int main(){
	map<char,int> ma;
	ma.insert(make_pair('I',1));
	ma.insert(make_pair('V',5));
	ma.insert(make_pair('X',10));
	ma.insert(make_pair('L',50));
	ma.insert(make_pair('C',100));
	ma.insert(make_pair('D',500));
	ma.insert(make_pair('M',1000));
	while(true){
		cin>>ary;
		if(cin.eof()) break;
		int res=0;
		int n=strlen(ary);
		for(int i=0;i<n-1;i++){
			if(ma[ary[i]]<ma[ary[i+1]]){
				res-=ma[ary[i]];
			}
			else{
				res+=ma[ary[i]];
			}
		}
		res+=ma[ary[n-1]];
		cout<<res<<endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
string s;
map<char,int> a;
int main(void){
  a['I'] = 1;
  a['V'] = 5;
  a['X'] = 10;
  a['L'] = 50;
  a['C'] = 100;
  a['D'] = 500;
  a['M'] = 1000;

  while(cin >> s){
    int ans = 0;

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

C++: #define scanf_s scanf
//#define gets_s gets
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 101
#define MIN -100001
#define _MAX 8


int main(void)
{
	char roman[102];
	char fig[8] = { "IVXLCDM" };
	int value[7] = { 1,5,10,50,100,500,1000 };
	int  sum = 0, b = _MAX;
	while (scanf_s("%s", &roman, MAX) != EOF) {
		for (int i = 0; roman[i] != '\0'; ++i) {
			for (int j = 0; j < 8; ++j) {
				if (roman[i] == fig[j]) {
					if (b >= j) sum += value[j];
					else { sum -= value[b]; sum += value[j] - value[b]; }
					b = j;
				}
			}
		}
		printf("%d\n", sum);
		sum = 0; b = _MAX;
	}
}