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<stdio.h>

int main(){

int p[6];
int P=0;
bool f=true;
while(1){
scanf("%d",&p[0]);if(p[0]==0)break;
scanf("%d",&p[1]);if(p[1]==0)break;
scanf("%d",&p[2]);if(p[2]==0)break;
scanf("%d",&p[3]);if(p[3]==0)break;
scanf("%d",&p[4]);if(p[4]==0)break;
P=0;f=true;
for(int i=0;i<5;i++){
if(p[i]==1)f=false;
}
if(f==true){P=2;}

f=true;
for(int i=0;i<5;i++){
if(p[i]==2)f=false;
}
if(f==true){P=3;}

f=true;
for(int i=0;i<5;i++){
if(p[i]==3)f=false;
}
if(f==true){P=1;}



for(int i=0;i<5;i++)
{if(P!=0){if(p[i]==P)printf("1\n");else printf("2\n");}
else printf("3\n");
}
}
return 0;
}

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

int main() {
  int a[5],b[5],rock=0,paper=0,scissors=0;
  while(cin >> a[0],a[0]) {
    cin >> a[1] >> a[2] >> a[3] >> a[4];
    rock=0;paper=0;scissors=0;
    for(int i=0;i<5;i++) {
      if(a[i] == 1) rock++;
      else if(a[i] == 2) scissors++;
      else if(a[i] == 3) paper++;
    }

    if(rock >= 1 && scissors >= 1 && paper >= 1) {
      for(int i=0;i<5;i++) {
        b[i] = 3;
      }
    }
    else if(paper == 0) {
      for(int i=0;i<5;i++) {
        if(a[i] == 1) {
          b[i] = 1;
        }
        else {
          b[i] = 2;
        }
      }
    }
    else if(rock == 0) {
      for(int i=0;i<5;i++) {
        if(a[i] == 2) {
          b[i] = 1;
        }
        else {
          b[i] = 2;
        }
      }
    }
    else if(scissors == 0) {
      for(int i=0;i<5;i++) {
        if(a[i] == 3) {
          b[i] = 1;
        }
        else {
          b[i] = 2;
        }
      }
    }

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

C++: #include<bits/stdc++.h>

using namespace std;

int Person[5], Judge[4];


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

bool isDraw() {
	
	if (Judge[1] == 5 || Judge[2] == 5 || Judge[3] == 5) {
		return true;
	}
	if (Judge[1] != 0 && Judge[2] != 0 && Judge[3] != 0) {
		return true;
	}
	return false;
}

void judge() {
	int i, a, b;

	a = Person[0];
	for (i = 1; i < 5; ++i) {
		if (Person[i] != a) {
			b = Person[i];
			break;
		}
	}
	//cout << a << " " << b << endl;
	if ( (a == 1 && b == 2) || (a == 2 && b == 3) || (a == 3 && b == 1) ) {
		Person[0] = 1;
	}
	if ( (a == 1 && b == 3) || (a == 2 && b == 1) || (a == 3 && b == 2) ) {
		Person[0] = 2;
	}
	for (int j = 1; j < 5; ++j) {
		if (Person[j] == a) {
			Person[j] = Person[0];
		} else{
			Person[j] = (Person[0] == 1) ? 2 : 1;
		}
	}
}

int main() {

	while (cin >> Person[0], Person[0]) {
		memset(Judge, 0, sizeof(Judge));
		++Judge[Person[0]];
		for (int i = 1; i < 5; ++i) {
			cin >> Person[i];
			++Judge[Person[i]];
		}
		if (isDraw()) {
			fill(Person, Person + 5, 3);
			show();
			continue;
		}
		judge();
		show();
	}

	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])) return 0;
      x[i]--;
      cnt[x[i]]++;
    }

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

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

bool is_draw(int* first, int* last) {
    bool used[3] = {false, false, false};
    for (int* p = first; p != last; p++) {
        used[*p - 1] = true;
    }
    return all_of(used, used + 3, [used](bool x) {return x;});
}

int get_win(int* first, int* last) {
    int mi = 5, ma = 0;
    for (int*p = first; p != last; p++) {
        mi = min(mi, *p);
        ma = max(ma, *p);
    }
    if (ma - mi == 1) return mi;
    return ma;
}

int main() {
    int hands[5];
    while (cin >> hands[0], hands[0]) {
        for (int i = 1; i < 5; i++) {
            cin >> hands[i];
        }
        if (is_draw(hands, hands + 5)) {
            for (int i = 0; i < 5; i++) {
                cout << 3 << endl;
            }
        }
        else {
            int win = get_win(hands, hands + 5);
            for (int i = 0; i < 5; i++) {
                if (hands[i] == win) {
                    cout << 1 << endl;
                }
                else {
                    cout << 2 << endl;
                }
            }
        }
    }
    return 0;
}

C++: #include<iostream>
int main(){
	while(1){
		int n,h[3]={0},i,a=0;
		std::cin>>n;
		if(!n)break;
		h[n-1]=1;
		for(i=1;i<5;i++){
			std::cin>>n;
			h[n-1]|=1<<i;
		}
		for(i=0;i<5;i++){
			for(n=0;!(h[n]&1<<i);n++);
			if(h[(n+1)%3])a+=1;
			if(h[(3+n-1)%3])a+=2;
			std::cout<<(a?a:3)<<'\n';
		}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <set>
//#include <fstream>

using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.rps", "r", stdin );

	enum { WIN = 1, LOSE = 2, DRAW = 3 };
	enum { ROCK = 0, SISSOR = 1, PAPER = 2};
	int n;
	int i, j;

	while (1){

		vector <int> winlose (5, 0 );
		vector <int> res (5, 0 );
		set <int> hand;

		for (i = 0; i < 5; ++i ){
			cin >> n;

			if (n == 0){
				goto end;
			} // end if

			winlose[i] = n - 1; // 0: rock 1: sissor 2: paper
			hand.insert (winlose[i] );		
		} // end for

		if (hand.size() == 1 || hand.size() == 3 ){
			for (i = 0; i < 5; ++i){
				res[i] = DRAW;
			} // end for
		}else{
			vector <bool> h (3, false );
			set <int>::iterator it = hand.begin();
			for (; it != hand.end(); ++it ){
				h[(*it)] = true;
			} // end for
			for (j = 0; j < 3; ++j){	
				if (!h[j]){	// without hand;
					for (i = 0; i < 5; ++i){
						switch(j){
							case ROCK:
								res[i] = ( winlose[i] == SISSOR ? WIN : LOSE);					break;
							case SISSOR:
								res[i] = ( winlose[i] == PAPER ? WIN : LOSE);					break;
							case PAPER:
								res[i] = ( winlose[i] == ROCK ? WIN : LOSE);					break;
						} // end switch
					} // end for
					break;
				} // end if
			} // end for
		} // end for

		for (i = 0; i < 5; ++i){
			cout << res[i] << endl;
		} // end for
	} // end loop
end:		
	return 0;
}