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() {

  vector<int> hand;

  int rock,scissors,paper;


  while(1) {

    int temp;

    cin >> temp;

    hand.clear();

    hand.push_back(temp);

    if(hand[0]==0) break;

    for(int i=1;i<5;i++) {

      cin >> temp;
      hand.push_back(temp);

    }

    rock=scissors=paper=0;

    for(int i=0;i<5;i++) {

      if(hand[i]==1) rock=1;

      if(hand[i]==2) scissors=1;

      if(hand[i]==3) paper=1;

    }

    if(rock==1 && scissors==1 && paper==1) {

      for(int i=0;i<5;i++) cout << "3" << endl;

    }

    else if(rock==1 && scissors==1) {

      for(int i=0;i<5;i++) {

	if(hand[i]==1) cout << "1" << endl;

	else if(hand[i]==2) cout << "2" << endl;

      }

    }

    else if(scissors==1 && paper==1) {

      for(int i=0;i<5;i++) {

	if(hand[i]==2) cout << "1" << endl;

	else if(hand[i]==3) cout << "2" << endl;

      }

    }

    else if(paper==1 && rock==1) {

      for(int i=0;i<5;i++) {

	if(hand[i]==3) cout << "1" << endl;

	else if(hand[i]==1) cout << "2" << endl;

      }

    }

    else if(rock==1) {

      for(int i=0;i<5;i++) cout << "3" << endl;

    }

    else if(scissors==1) {

      for(int i=0;i<5;i++) cout << "3" << endl;

    }

    else if(scissors==1) {

      for(int i=0;i<5;i++) cout << "3" << endl;

    }

    else cout << "error!" << endl;

  }

  return 0;

}

C++: #include<stdio.h>

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

C++: #include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	int y = 0;
	for (int u = 0; u < 200; u++)
	{
		int a[6],h1 = 0,h2 = 0,h3 = 0;

		for (int i = 0; i < 5; i++)
		{
			a[i] = 0;
		}
		for (int i = 0; i < 5; i++)
		{
			cin >> a[i];
			if (a[i] == 0)
			{
				y = -1;
				break;
			}
		}
		if (y == -1)
		{
			break;
		}

		for (int i = 0; i < 5; i++)
		{
			if (a[i] == 1)
			{
				h1 += 1;
			}
			else if (a[i] == 2)
			{
				h2 += 1;
			}
			else if (a[i] == 3)
			{
				h3 += 1;
			}
		}


		int ke = 0;
		if (h1 != 0 && h2 != 0)
		{
			if (h3 != 0)
			{
				ke += 1;
				for (int gg = 0; gg < 5; gg++)
				{
					cout << '3' << endl;
				}
			}
		}

		if (h1 == 0 && ke == 0)
		{
			for (int j = 0; j < 5; j++)
			{
				if (a[j] == 2)
				{
					cout << '1' << endl;
				}
				else
				{
					cout << '2' << endl;
				}
			}
		}
		else if (h2 == 0 && ke == 0)
		{
			for (int j = 0; j < 5; j++)
			{
				if (a[j] == 1)
				{
					cout << '2' << endl;
				}
				else
				{
					cout << '1' << endl;
				}
			}
		}
		else if (h3 == 0 && ke == 0)
		{
			for (int j = 0; j < 5; j++)
			{
				if (a[j] == 1)
				{
					cout << '1' << endl;
				}
				else
				{
					cout << '2' << endl;
				}
			}
		}
	}
}

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

using namespace std;

int main() {

  vector<int> hand;

  int rock,scissors,paper;


  while(1) {

    int temp;

    cin >> temp;

    hand.clear();

    hand.push_back(temp);

    if(hand[0]==0) break;

    for(int i=1;i<5;i++) {

      cin >> temp;
      hand.push_back(temp);

    }

    rock=scissors=paper=0;

    for(int i=0;i<5;i++) {

      if(hand[i]==1) rock=1;

      if(hand[i]==2) scissors=1;

      if(hand[i]==3) paper=1;

    }

    if(rock==1 && scissors==1 && paper==1) {

      for(int i=0;i<5;i++) cout << "3" << endl;

    }

    else if(rock==1 && scissors==1) {

      for(int i=0;i<5;i++) {

	if(hand[i]==1) cout << "1" << endl;

	else if(hand[i]==2) cout << "2" << endl;

      }

    }

    else if(scissors==1 && paper==1) {

      for(int i=0;i<5;i++) {

	if(hand[i]==2) cout << "1" << endl;

	else if(hand[i]==3) cout << "2" << endl;

      }

    }

    else if(paper==1 && rock==1) {

      for(int i=0;i<5;i++) {

	if(hand[i]==3) cout << "1" << endl;

	else if(hand[i]==1) cout << "2" << endl;

      }

    }

    else if(rock==1) {

      for(int i=0;i<5;i++) cout << "3" << endl;

    }

    else if(scissors==1) {

      for(int i=0;i<5;i++) cout << "3" << endl;

    }

    else if(paper==1) {

      for(int i=0;i<5;i++) cout << "3" << endl;

    }

    else cout << "error!" << endl;

  }

  return 0;

}

C++: #include <stdio.h>
 
int main( ) {                                                                  
    int a[4];
	int b[4];
	int hit;
	int blow;

	while( scanf("%d%d%d%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3]) != EOF ){
		hit = 0;
		blow = 0;

		for( int i = 0; i < 4; i++ ) {
			for( int j = 0; j < 4; j++ ) {
				if( a[i] == b[j] && i == j ){
					hit++;
				}else if( a[i] == b[j] ){
					blow++;
				}
			}
		}
		printf("%d %d\n",hit,blow);
	}

    return 0;                                                                  
}

C++: //rock//
#include <iostream>

using namespace std;

int main(){
	int hand[5];
	bool handbe[3];
	bool isdraw;
	while (1){
		isdraw = false;
		handbe[0] = false;
		handbe[1] = false;
		handbe[2] = false;

		cin >> hand[0];
		if (hand[0] == 0)break;
		handbe[hand[0]-1] = true;
		for (int i = 1; i < 5; ++i){
			cin >> hand[i];
			handbe[hand[i]-1] = true;
		}

		if (handbe[0]){//あいこ判定
			if (handbe[1] == handbe[2])isdraw = true;
		} else{
			if (handbe[1] != handbe[2])isdraw = true;
		}

		if (isdraw){
			for (int i = 0; i < 5; ++i){
				cout << "3" << endl;
			}
			continue;
		}

		for (int j = 0; j < 3; ++j){
			if (handbe[j] && handbe[(j+1)%3]){
				for (int i = 0; i < 5; ++i){
					cout << (hand[i] == j+1 ? 1 : 2) << endl;
				}
			}
		}
	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void print_aiko()
{
	rep(i, 5) cout << 3 << endl;
}

int main()
{
	int hand[5];
	map<int, int> num;

	while (cin >> hand[0])
	{
		num.clear();
		if (hand[0] == 0) break;
		num[hand[0]]++;

		for (int i = 1; i < 5; i++)
		{
			cin >> hand[i];
			num[hand[i]]++;
		}

		if (num[1] > 0 && num[2] > 0 && num[3] > 0)
		{
			print_aiko();
			continue;
		}

		//??°??????0???
		if (num[1] == 0)
		{
			num[2] = 1;
			num[3] = 2;
		}
		//?????§??????0???
		else if (num[2] == 0)
		{
			num[1] = 2;
			num[3] = 1;
		}
		else if (num[3] == 0)
		{
			num[1] = 1;
			num[2] = 2;
		}

		rep(i, 5)
		{
			cout << num[hand[i]] << endl;
		}
	}
}