Language: C++

#include<bits/stdc++.h>
using namespace std;

string tmp[6];

void rotN() {
  string t = tmp[0];
  tmp[0] = tmp[5];
  tmp[5] = tmp[2];
  tmp[2] = tmp[4];
  tmp[4] = tmp[0];

  t = tmp[2];
  tmp[2][0] = t[6];
  tmp[2][1] = t[7];
  tmp[2][2] = t[8];
  tmp[2][6] = t[0];
  tmp[2][7] = t[1];
  tmp[2][8] = t[2];
  
  t = tmp[5];
  tmp[5][0] = t[6];
  tmp[5][1] = t[7];
  tmp[5][2] = t[8];
  tmp[5][6] = t[0];
  tmp[5][7] = t[1];
  tmp[5][8] = t[2];
  
  t = tmp[1];
  tmp[1][0] = t[2];
  tmp[1][1] = t[5];
  tmp[1][2] = t[8];
  tmp[1][3] = t[1];
  tmp[1][4] = t[4];
  tmp[1][5] = t[7];
  tmp[1][6] = t[0];
  tmp[1][7] = t[3];
  tmp[1][8] = t[6];

  t = tmp[3];
  tmp[3][0] = t[6];
  tmp[3][1] = t[3];
  tmp[3][2] = t[0];
  tmp[3][3] = t[7];
  tmp[3][4] = t[4];
  tmp[3][5] = t[1];
  tmp[3][6] = t[6];
  tmp[3][7] = t[3];
  tmp[3][8] = t[0];
}

void rotE() {

  string t = tmp[4];
  tmp[4][0] = t[6];
  tmp[4][1] = t[3];
  tmp[4][2] = t[0];
  tmp[4][3] = t[7];
  tmp[4][4] = t[4];
  tmp[4][5] = t[1];
  tmp[4][6] = t[6];
  tmp[4][7] = t[3];
  tmp[4][8] = t[0];

  t = tmp[1];
  tmp[1][0] = t[6];
  tmp[1][1] = t[3];
  tmp[1][2] = t[0];
  tmp[1][3] = t[7];
  tmp[1][4] = t[4];
  tmp[1][5] = t[1];
  tmp[1][6] = t[6];
  tmp[1][7] = t[3];
  tmp[1][8] = t[0];
  
  t = tmp[5];
  tmp[5][0] = t[6];
  tmp[5][1] = t[3];
  tmp[5][2] = t[0];
  tmp[5][3] = t[7];
  tmp[5][4] = t[4];
  tmp[5][5] = t[1];
  tmp[5][6] = t[6];
  tmp[5][7] = t[3];
  tmp[5][8] = t[0];

  t = tmp[3];
  tmp[3][0] = t[6];
  tmp[3][1] = t[3];
  tmp[3][2] = t[0];
  tmp[3][3] = t[7];
  tmp[3][4] = t[4];
  tmp[3][5] = t[1];
  tmp[3][6] = t[6];
  tmp[3][7] = t[3];
  tmp[3][8] = t[0];
  
  t = tmp[1];
  tmp[1] = tmp[4];
  tmp[4] = tmp[3];
  tmp[3] = tmp[5];
  tmp[5] = t;

   t = tmp[2];
  tmp[2][0] = t[2];
  tmp[2][1] = t[5];
  tmp[2][2] = t[8];
  tmp[2][3] = t[1];
  tmp[2][4] = t[4];
  tmp[2][5] = t[7];
  tmp[2][6] = t[0];
  tmp[2][7] = t[3];
  tmp[2][8] = t[6];

  t = tmp[0];
  tmp[0][0] = t[6];
  tmp[0][1] = t[3];
  tmp[0][2] = t[0];
  tmp[0][3] = t[7];
  tmp[0][4] = t[4];
  tmp[0][5] = t[1];
  tmp[0][6] = t[6];
  tmp[0][7] = t[3];
  tmp[0][8] = t[0];
}

int main()
{
  string s[18];
  while( 1 ) {
    cin >> s[0];
    if( s[0][0] == '#' ) break;
    for(int i=1; i<18; i++) cin >> s[i];

    
    string dice[6];
    
    for(int i=0; i<6; i++) dice[i] = "";
    
    for(int i=0; i<6; i++) {
      
      dice[i] = s[i*3] + s[i*3+1] + s[i*3+2];
      
    }

    
    int mn = 1e9;
    for(int i=0; i<4; i++) {
      for(int j=0; j<4; j++) {
	  
	  for(int k=0; k<6; k++) tmp[k] = dice[k];
	  
	  for(int k=0; k<i; k++) rotN();
	  
	  for(int k=0; k<j; k++) rotE();
	  
	  if( (dice[0][6] == '*' || dice[0][7] == '*' || dice[0][8] == '*') &&  (dice[2][6] == '*' || dice[2][7] == '*' || dice[2][8] == '*') ) {
	    int sum = 0;
	    if( i > 2 ) sum += 4 - i;
	    else sum += i;#include<bits/stdc++.h>
using namespace std;

string tmp[6];

void rotN() {
  string t = tmp[0];
  tmp[0] = tmp[5];
  tmp[5] = tmp[2];
  tmp[2] = tmp[4];
  tmp[4] = tmp[0];

  t = tmp[2];
  tmp[2][0] = t[6];
  tmp[2][1] = t[7];
  tmp[2][2] = t[8];
  tmp[2][6] = t[0];
  tmp[2][7] = t[1];
  tmp[2][8] = t[2];
  
  t = tmp[5];
  tmp[5][0] = t[6];
  tmp[5][1] = t[7];
  tmp[5][2] = t[8];
  tmp[5][6] = t[0];
  tmp[5][7] = t[1];
  tmp[5][8] = t[2];
  
  t = tmp[1];
  tmp[1][0] = t[2];
  tmp[1][1] = t[5];
  tmp[1][2] = t[8];
  tmp[1][3] = t[1];
  tmp[1][4] = t[4];
  tmp[1][5] = t[7];
  tmp[1][6] = t[0];
  tmp[1][7] = t[3];
  tmp[1][8] = t[6];

  t = tmp[3];
  tmp[3][0] = t[6];
  tmp[3][1] = t[3];
  tmp[3][2] = t[0];
  tmp[3][3] = t[7];
  tmp[3][4] = t[4];
  tmp[3][5] = t[1];
  tmp[3][6] = t[6];
  tmp[3][7] = t[3];
  tmp[3][8] = t[0];
}

void rotE() {

  string t = tmp[4];
  tmp[4][0] = t[6];
  tmp[4][1] = t[3];
  tmp[4][2] = t[0];
  tmp[4][3] = t[7];
  tmp[4][4] = t[4];
  tmp[4][5] = t[1];
  tmp[4][6] = t[6];
  tmp[4][7] = t[3];
  tmp[4][8] = t[0];

  t = tmp[1];
  tmp[1][0] = t[6];
  tmp[1][1] = t[3];
  tmp[1][2] = t[0];
  tmp[1][3] = t[7];
  tmp[1][4] = t[4];
  tmp[1][5] = t[1];
  tmp[1][6] = t[6];
  tmp[1][7] = t[3];
  tmp[1][8] = t[0];
  
  t = tmp[5];
  tmp[5][0] = t[6];
  tmp[5][1] = t[3];
  tmp[5][2] = t[0];
  tmp[5][3] = t[7];
  tmp[5][4] = t[4];
  tmp[5][5] = t[1];
  tmp[5][6] = t[6];
  tmp[5][7] = t[3];
  tmp[5][8] = t[0];

  t = tmp[3];
  tmp[3][0] = t[6];
  tmp[3][1] = t[3];
  tmp[3][2] = t[0];
  tmp[3][3] = t[7];
  tmp[3][4] = t[4];
  tmp[3][5] = t[1];
  tmp[3][6] = t[6];
  tmp[3][7] = t[3];
  tmp[3][8] = t[0];
  
  t = tmp[1];
  tmp[1] = tmp[4];
  tmp[4] = tmp[3];
  tmp[3] = tmp[5];
  tmp[5] = t;

   t = tmp[2];
  tmp[2][0] = t[2];
  tmp[2][1] = t[5];
  tmp[2][2] = t[8];
  tmp[2][3] = t[1];
  tmp[2][4] = t[4];
  tmp[2][5] = t[7];
  tmp[2][6] = t[0];
  tmp[2][7] = t[3];
  tmp[2][8] = t[6];

  t = tmp[0];
  tmp[0][0] = t[6];
  tmp[0][1] = t[3];
  tmp[0][2] = t[0];
  tmp[0][3] = t[7];
  tmp[0][4] = t[4];
  tmp[0][5] = t[1];
  tmp[0][6] = t[6];
  tmp[0][7] = t[3];
  tmp[0][8] = t[0];
}

int main()
{
  string s[18];
  while( 1 ) {
    cin >> s[0];
    if( s[0][0] == '#' ) break;
    for(int i=1; i<18; i++) cin >> s[i];

    
    string dice[6];
    
    for(int i=0; i<6; i++) dice[i] = "";
    
    for(int i=0; i<6; i++) {
      
      dice[i] = s[i*3] + s[i*3+1] + s[i*3+2];
      
    }

    
    int mn = 1e9;
    for(int i=0; i<4; i++) {
      for(int j=0; j<4; j++) {
	  
	  for(int k=0; k<6; k++) tmp[k] = dice[k];
	  
	  for(int k=0; k<i; k++) rotN();
	  
	  for(int k=0; k<j; k++) rotE();
	  
	  if( (dice[0][6] == '*' || dice[0][7] == '*' || dice[0][8] == '*') &&  (dice[2][6] == '*' || dice[2][7] == '*' || dice[2][8] == '*') ) {
	    int sum = 0;
	    if( i > 2 ) sum += 4 - i;
	    else sum += i;
	    if( j > 2 ) sum += 4 - j;
	    else sum += j;
	    
	    mn = min(mn, sum);
	  }
      }
    }
    cout<<'b'<<endl;
    cout << mn << endl;
  }
}

	    if( j > 2 ) sum += 4 - j;
	    else sum += j;
	    
	    mn = min(mn, sum);
	  }
      }
    }
    cout<<'b'<<endl;
    cout << mn << endl;
  }
}

Compiler output:
a.cc:160:27: error: stray '#' in program
  160 |             else sum += i;#include<bits/stdc++.h>
      |                           ^
a.cc: In function 'int main()':
a.cc:160:28: error: 'include' was not declared in this scope
  160 |             else sum += i;#include<bits/stdc++.h>
      |                            ^~~~~~~
a.cc:160:36: error: 'bits' was not declared in this scope
  160 |             else sum += i;#include<bits/stdc++.h>
      |                                    ^~~~
a.cc:160:41: error: 'stdc' was not declared in this scope; did you mean 'std'?
  160 |             else sum += i;#include<bits/stdc++.h>
      |                                         ^~~~
      |                                         std
a.cc:161:1: error: expected primary-expression before 'using'
  161 | using namespace std;
      | ^~~~~
a.cc:165:13: error: a function-definition is not allowed here before '{' token
  165 | void rotN() {
      |             ^
a.cc:211:13: error: a function-definition is not allowed here before '{' token
  211 | void rotE() {
      |             ^
a.cc:286:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
  286 | int main()
      |         ^~
a.cc:286:9: note: remove parentheses to default-initialize a variable
  286 | int main()
      |         ^~
      |         --
a.cc:286:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:287:1: error: a function-definition is not allowed here before '{' token
  287 | {
      | ^