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 <vector>

using namespace std;

int main() {
    while(true) {
        vector<int> v(5, 0);
        vector<int> cnt(3, 0);
        for(int i = 0; i < 5; ++i) {
            cin >> v[i];
            if(v[i] == 0) return 0;
            v[i]--;
            cnt[v[i]]++;
        }

        if(cnt[0] > 0 && cnt[1] > 0 && cnt[2] > 0) {
            for(int i = 0; i < 5; ++i) v[i] = 3;
        }
        else {
            for(int i = 0; i < 5; ++i) v[i] = cnt[(v[i]+1)%3]>0 ? 1 : 2;
        }

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

C++: #include<iostream>

using namespace std;

int main(){
  int hands[5], i, numRock, numScis, numPaper;
  while(cin >> hands[0], hands[0]){
    for(i=1; i<5; i++){
      cin >> hands[i];
    }
    numRock=0, numScis=0, numPaper=0;
    for(i=0; i<5; i++){
      if(hands[i]==1)numRock++;
      if(hands[i]==2)numScis++;
      if(hands[i]==3)numPaper++;
    }
    if(numRock==0 && numScis>0 && numPaper>0){
      for(i=0; i<5; i++){
        if(hands[i]==2){
          cout << 1 << endl;
        }else{
          cout << 2 << endl;
	}
      }
    }else if(numScis==0 && numRock>0 && numPaper>0){
      for(i=0; i<5; i++){
	if(hands[i]==3){
          cout << 1 << endl;
	}else{
          cout << 2 << endl;
        }
      }
    }else if(numPaper==0 && numRock>0 && numScis>0){
      for(i=0; i<5; i++){
        if(hands[i]==1){
          cout << 1 << endl;
        }else{
          cout << 2 << endl;
        }
      }
    }else{
      for(i=0; i<5; i++){
	cout << 3 << endl;
      }
    }
  }
}

C++: # include <iostream>

int a[5];
bool f[3];
int res[5];

int main() {
	while (1) {
		std::cin >> a[0];
		if (!a[0])
			break;
		std::fill(f, f + 3, false);

		for (int i = 1; i < 5; ++i) {
			std::cin >> a[i];
			if (!f[a[i] - 1]) {
				switch (a[i]) {
				case 1:
					f[0] = true; break;
				case 2:
					f[1] = true; break;
				case 3:
					f[2] = true; break;
				}
			}
		}
		if (f[0] && f[1] && f[2])
			std::fill(res, res + 5, 3);

		else if ((f[0] && !f[1] && !f[2]) ||
			(f[1] && !f[0] && !f[2]) ||
			(f[2] && !f[0] && !f[1]))
			std::fill(res, res + 5, 3);

		else {
			for (int i = 0; i < 5; ++i) {
				if (f[0] && f[1])
					res[i] = (a[i] == 1) ? 1 : 2;
				else if (f[1] && f[2])
					res[i] = (a[i] == 2) ? 1 : 2;
				else if (f[0] && f[2])
					res[i] = (a[i] == 3) ? 1 : 2;
			}
		}
		for (int i = 0; i < 5; ++i)
			std::cout << res[i] << std::endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(void){

  int j[5];
  bool R,S,P;


  while(cin >> j[0], j[0]){
    for( int i = 1 ; i < 5 ; i++ ){
      cin >> j[i];
    }
    R = S = P = false;
    for( int i = 0 ; i < 5 ; i++ ){
      if(j[i] == 1 ) R = true;
      if(j[i] == 2 ) S = true;
      if(j[i] == 3 ) P = true;
    }
    if( R && S && P )
      for( int i = 0 ; i < 5 ; i++ )
	cout << "3" << endl;

    else if( R && S && !P ) // パーなし
      for( int i = 0 ; i < 5 ; i++ ){
	switch(j[i]){
	case 1:
	  cout << "1" << endl;
	  break;
	case 2:
	  cout << "2" << endl;
	  break;
	}
      }
    else if( R && !S && P ) // チョキなし
      for( int i = 0 ; i < 5 ; i++ ){
	switch(j[i]){
	case 1:
	  cout << "2" << endl;
	  break;
	case 2:
	  cout << "1" << endl;
	  break;
	}
      }
    else if( !R && S && P ) // グーなし
      for( int i = 0 ; i < 5 ; i++ ){
	switch(j[i]){
	case 2:
	  cout << "1" << endl;
	  break;
	case 3:
	  cout << "2" << endl;
	  break;
	}
      }
    else if( (!R && !S && P) || (!R && S && !P ) || (R && !S && !P ) ){
      for( int i = 0 ; i < 5 ; i++ )
	cout << "3" << endl;
    }
  }
  return 0;
}

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;
    }
    int cnt = count(used, used + 3, true);
    return cnt == 1 || cnt == 3;
}

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>
#include <algorithm>

using namespace std;

int player[5];

int main()
{	
	while (cin >> player[0], player[0]){
		int a[2] = {0}, j = 0;
		int check[4] = {1};

		check[player[0]] = -1;
		for (int i = 1; i < 5; i++){
			cin >> player[i];
			check[player[i]] = -1;
		}
		
		for (int i = 1; i < 4; i++){
			check[0] *= check[i];
			if (check[i] == -1){
				a[j++] = i;
			}
		}
		if (check[0] == -1){
			for (int i = 0; i < 5; i++){
				player[i] = 3;
			}
		}
		else if (check[3] == -1){
			for (int i = 0; i < 5; i++){
				if (player[i] == 3)	player[i] = 1;
				else	player[i] = 2;
			}
		}
		else {
			for (int i = 0; i < 5; i++){
				if (player[i] == min(a[0], a[1]))	player[i] = 1;
				else 	player[i] = 2;
			}
		}
		for (int i = 0; i < 5; i++){
			cout << player[i] << endl;
		}
	}
	return (0);
}

C++: #include<iostream>
using namespace std;
int main(void){
  int a[5],f1,f2,f3;
  for(;;){
    cin >> a[0];
    if(!a[0]) break;
    cin >> a[1] >> a[2] >> a[3] >> a[4];
    f1=0; f2=0; f3=0;
    for(int i=0;i<5;i++){
      if(a[i]==1) f1=1;
      else if(a[i]==2) f2=1;
      else if(a[i]==3) f3=1;
    }
    if(f1 && f2 && f3 || f1 && !f2 && !f3 || !f1 && f2 && !f3 || !f1 && !f2 && f3){
      for(int i=0;i<5;i++) cout << "3" << endl;
    }
    else if(f1 && f2){
      for(int i=0;i<5;i++){
	if(a[i]==1) cout << "1" << endl;
	else cout << "2" << endl;
      }
    }
    else if(f2 && f3){
      for(int i=0;i<5;i++){
	if(a[i]==2) cout << "1" << endl;
	else cout << "2" << endl;
      }
    }
    else if(f1 && f3){
      for(int i=0;i<5;i++){
	if(a[i]==3) cout << "1" << endl;
	else cout << "2" << endl;
      }
    }
  }
}