Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		h := make([]int, 5)
		h[0], _ = strconv.Atoi(scanner.Text())
		if h[0] == 0 {
			break
		}
		for i := 1; i <= 4; i++ {
			scanner.Scan()
			h[i], _ = strconv.Atoi(scanner.Text())
		}
		tbl := make([]bool, 3)
		aiko := false
		for _, v := range h {
			tbl[v-1] = true
		}
		if tbl[0] && tbl[1] && tbl[2] { // 全ての手があるあいこ
			aiko = true
		}
		if h[0] == h[1] && h[1] == h[2] && h[2] == h[3] && h[3] == h[4] {
			aiko = true
		}
		if aiko {
			fmt.Printf("3\n3\n3\n3\n3\n")
		} else {
			win := 0
			if !tbl[0] {
				win = 2
			}
			if !tbl[1] {
				win = 3
			}
			if !tbl[2] {
				win = 1
			}
			for i := 0; i < 5; i++ {
				if h[i] == win {
					fmt.Println(1)
				} else {
					fmt.Println(2)
				}
			}
		}
	}
}

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

int main() {
    int a[5];
    while (cin >> a[0], a[0]) {
        for (int i=1; i<5; ++i) {
            cin >> a[i];
        }
        int r = 0, p = 0, s = 0;
        for (int i=0; i<5; ++i) {
            if (a[i] == 1) r ++;
            else if (a[i] == 2) p ++;
            else s ++;
        }
        int res[4];
        if ((0 < r && 0 < p && 0 < s) || r == 5 || p == 5 || s == 5) {
            cout << "3\n3\n3\n3\n3\n";
        } else {
            if (r == 0) {
                res[2] = 1;
                res[3] = 2;
            } else if (p == 0) {
                res[1] = 2;
                res[3] = 1;
            } else if (s == 0) {
                res[1] = 1;
                res[2] = 2;
            }
            for (int i=0; i<5; ++i) {
                cout << res[a[i]] << endl;
            }
        }
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]){
  int n[5];
  while(std::cin >> n[0], n[0]){
    n[0]--;
    for (int i = 0; i < 4; i++) {
      std::cin >> n[i + 1];
      n[i + 1]--;
    }
    bool used[3] = {}, draw = false;
    for (int i = 0; i < 5; i++) {
      used[n[i]] = true;
    }
    int cnt = 0, win = -1;
    for (int i = 0; i < 3; i++) {
      if(used[i])cnt++;
    }
    if(cnt == 1 || cnt == 3){
      draw = true;
    }
    for (int i = 0; i < 5; i++) {
      win = max(win, n[i]%3);
    }
    std::cout << "draw:" << draw << std::endl;
    if(draw){
      for (int i = 0; i < 5; i++) {
        std::cout << 3 << std::endl;
      }
    }else{
      for (int i = 0; i < 5; i++) {
        if(n[i] + 1 == win)std::cout << 1 << std::endl;
        else std::cout << 2 << std::endl;
      }
    }
  }
  return 0;
}

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

int main(){
	while(1){
		int n, hand[3] = {0};
		cin >> n;
		if(n == 0) break;
		hand[n - 1] = 1;
		for(int i = 1;i < 5;i++){
			int h;
			cin >> h;
			hand[h - 1] |= 1 << i;
		}
		for(int i = 0;i < 5;i++){
			int h = 0;
			while(!(hand[h] & 1 << i)) h++;
			int ans = 0;
			if(hand[(h + 1) % 3]) ans += 1;
			if(hand[(3 + h - 1) % 3]) ans += 2;
			if(ans == 0) ans = 3;
			cout << ans << endl;
		}
	}
		
	return 0;
}

C++: #include <cstdio>

int main() {
	int te[5];
	while (scanf("%d", &te[0])!=EOF) {
		if (te[0] == 0) break;
		for (int i=1; i<5; i++) scanf("%d", &te[i]);
		int num[3];
		for (int i=0; i<3; i++) num[i] = 0;
		for (int i=0; i<5; i++) num[te[i]-1]++;
		if (num[0]!=0&&num[1]!=0&&num[2]!=0) {
			for (int i=0; i<5; i++) printf("3\n");
			continue;
		} else if ((num[0]==0&&num[1]==0)||
			(num[1]==0&&num[2]==0)||(num[0]==0&&num[2]==0)) {
			for (int i=0; i<5; i++) printf("3\n");
			continue;
		}
		if (num[0] == 0) {
			for (int i=0; i<5; i++) {
				if (te[i] == 2) {
					printf("1\n");
				} else if (te[i] == 3) {
					printf("2\n");
				}
			}
		} else if (num[1] == 0) {
			for (int i=0; i<5; i++) {
				if (te[i] == 3) {
					printf("1\n");
				} else if (te[i] == 1) {
					printf("2\n");
				}
			}
		} else if (num[2] == 0) {
			for (int i=0; i<5; i++) {
				if (te[i] == 1) {
					printf("1\n");
				} else if (te[i] == 2) {
					printf("2\n");
				}
			}
		}
	}
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<map>
#include<queue>
#include<set>

using namespace std;
typedef pair<int,int> PII;
typedef long long ll;

int main(){
	int hand[5],num[3],result[5],lose;
  while(cin>>hand[0]>>hand[1]>>hand[2]>>hand[3]>>hand[4]){
		for(int i=0;i<3;i++){
			num[i] = 0;
			result[i] = 0;
		}
		for(int i=0;i<5;i++){
			num[hand[i]-1]++;
		}
		if(num[0]*num[1]*num[2] == 0 
			 && (num[0]+1)*(num[1]+1)*(num[2]+1) != 6){
			for(lose = 0;num[lose] != 0;lose++);
			for(int i=0;i<5;i++){
				result[i] = (hand[i] == lose) ? 2 : 1;
			}
		}
		else{
			for(int i=0;i<5;i++)
				result[i] = 3;
		}
		for(int i=0;i<5;i++)
			cout<<result[i]<<endl;
	}
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

void solve(){
}

int main(){
  while(1){
    int x[5];
    int cnt[] = {0,0,0};
    rep(i,5){
      if(cin>>x[i] && !x[i]) return 0;
      x[i]--;
      cnt[x[i]]++;
    }

    rep(i,5){
      if(cnt[0] && cnt[1] && cnt[2] || cnt[0] == 5 || cnt[1] == 5 || cnt[2] == 5){
        cout<<"3\n";
      }
      else if(cnt[(x[i] + 2) % 3]){
        cout<<"2\n";
      }
      else{
        cout<<"1\n";
      }
    }
  }
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	int people[6];
	int hand[5];

	while( cin >> people[0] , people[0] )
	{
		for(int i = 1; i <= 4; i++)
		{
			cin >> people[i];
		}

		memset(hand, 0, sizeof(hand));
		
		for(int i = 0; i < 5; i++)
		{
			hand[people[i]]++;
		}

		if(hand[1] && hand[2] && hand[3])
		{
			for(int i = 0; i < 5; i++)
			{
				people[i] = 3;
			}
		}
		else if(hand[1] && hand[2])
		{
			for(int i = 0; i < 5; i++)
			{
				if(people[i] == 1)
				{
					people[i] = 1;
				}
				else
				{
					people[i] = 2;
				}
			}
		}
		else if(hand[2] && hand[3])
		{
			for(int i = 0; i < 5; i++)
			{
				if(people[i] == 2)
				{
					people[i] = 1;
				}
				else 
				{
					people[i] = 2;
				}
			}
		}
		else if(hand[1] && hand[3])
		{
			for(int i = 0; i < 5; i++)
			{
				if(people[i] == 3)
				{
					people[i] = 1;
				}
				else
				{
					people[i] = 2;
				}
			}
		}
		else
		{
			for(int i = 0; i < 5; i++)
			{
				people[i] = 3;
			}
		}

		for(int i = 0; i < 5; i++)
		{
			cout << people[i] << endl;
		}
	}
}