Go: package main

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

var points [5][5][4]bool

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for i := 0; i < 9; i++ {
		y := i/2
		if i%2 == 0 {
			scanner.Scan()
			info := strings.Split(scanner.Text(), "")
			for k := range info {
				e, _ := strconv.Atoi(info[k])
				if e != 0 {
					points[y][k][1], points[y][k+1][3] = true, true
				}
			}
		} else {
			scanner.Scan()
			info := strings.Split(scanner.Text(), "")
			for k := range info {
				e, _ := strconv.Atoi(info[k])
				if e != 0 {
					points[y][k][2], points[y+1][k][0] = true, true
				}
			}
		}
	}
	x := 1
	y := 0
	dir := 1
	dx := []int{0, 1, 0, -1}
	dy := []int{-1, 0, 1, 0}
	ds := "URDL"
	fmt.Printf("%s", string(ds[dir]))
	for !(x == 0 && y == 0) {
		if points[y][x][(dir+3)%4] {
			dir = (dir+3)%4
		} else if points[y][x][dir] {

		} else if points[y][x][(dir+1)%4] {
			dir = (dir+1)%4
		} else {
			dir = (dir+2)%4
		}
		x += dx[dir]
		y += dy[dir]
		fmt.Printf("%s", string(ds[dir]))
	}
	fmt.Println()
}

C++: #include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
vector<string> strs;
int H,W;
bool isroad(int fx,int fy,int tx,int ty){
    int fromx,fromy,tox,toy;
    fromx=min(fx,tx);
    fromy=min(fy,ty);
    tox=max(fx,tx);
    toy=max(fy,ty);
    if(fromx<1 || tox<1 || tox>W || fromx>W || fromy<1 || toy<1 || fromy>H || toy>H) return false;
    if(fromx==tox){
        if(strs[(fromy-1)*2+1][fromx-1]=='1') return true;
        else{
            return false;
        }
    }else{
        if(strs[(fromy-1)*2][fromx-1]=='1') return true;
        else{
            return false;
        }
    }
}
int vx[]={1,0,-1,0},vy[]={0,-1,0,1};
int main(){
    string ins;
    while(cin>>ins){
        strs.push_back(ins);
    }
    W=strs[0].size()+1;
    H=strs.size()/2+1;
    int nx=2,ny=1,v=0;
    string outs="R";
    while(nx!=1 || ny!=1){
        for(int i=5;i>=2;i--){
            bool r=isroad(nx,ny,nx+vx[(v+i)%4],ny+vy[(v+i)%4]);
            if(r){
                v=(v+i)%4;
                nx+=vx[v];
                ny+=vy[v];
                if(v==0) outs+='R';
                else if(v==1) outs+='U';
                else if(v==2) outs+='L';
                else outs+='D';
                break;
            }
        }
    }
    cout<<outs<<endl;
}

C++: #include<stdio.h>///////AOJ0037
                            int
                            w[5
       ][5],i,j;char(b)[    128
       ],*           p;F    (//
       int           v){    for
       (i=    scanf("%s"    ,b)
       -1,    p=b    ;*p    ;++
       p){    w[p    -b+    1-v
       ][j    +v]|=((w[p    -b]
       [j]                  |=(
       p[0                  ]==
       49)<<3-v)&8>>v)>>2;}j+=v

     ;}
    main
  (){  for
 (;F     (0)
,j-       4;F
(1));for(p=b,
j=(       *b=
3)^       3;i        +=-66+"BAB\
C"[       *b]      ,j+=       "?\
@A"       "@"      [*b        ]-(
                   1<<        6),*
                   ++p        =(*
                   b)[        "U"
                   "L"        "D"
                   "R"        ],i
                    +j;)for((++*
  b)&=~4;!((1<<*
         b)&
         w[i
         ][j
]);      (*b
+=3      )&=
~4)     ;re\
turn   !puts
  (b+1);}

C++: #include<string> 
#include<vector>
#include<iostream>
using namespace std;
bool map[20][20][4];
vector< string > maphor,mapver;
int xsize,ysize;
void init(){
	for(int i=0;i<xsize;i++){
		for(int j=0;j<ysize;j++){
			for(int k=0;k<4;k++){
				map[i][j][k]=0;
			}
		}
	}
}
void setmap(){
	for(int i=0;i<xsize;i++){
		for(int j=0;j<ysize;j++){
			if(-1<i&&i<ysize&&-1<j&&j<xsize){
				if(maphor[i][j]=='1'){
					map[i][j][0]=1;
				}
			}
			if(-1<i&&i<ysize&&-1<j-1&&j-1<xsize){
				if(maphor[i][j-1]=='1'){
					map[i][j][2]=1;
				}
			}
			if(-1<i&&i<ysize-1&&-1<j&&j<xsize){
				if(mapver[i][j]=='1'){
					map[i][j][3]=1;
				}
			}
			if(-1<i-1&&i-1<ysize-1&&-1<j&&j<xsize){
				if(mapver[i-1][j]=='1'){
					map[i][j][1]=1;
				}
			}
		}
	}
}

void solve(){
	int x=0,y=0;
	int v=0;
	string vec="RULD";
	int loop[4]={1,0,3,2};
	int vx[4]={1,0,-1,0};
	int vy[4]={0,-1,0,1};
	int count=0;
	while(1){
		for(int i=0;i<4;i++){
			if(count!=0
				&&x==0
				&& y==0
				&&(((v+loop[i])%4)==2 || ((v+loop[i])%4==1))){
				return;
			}
			if(map[y][x][(v+loop[i])%4]==1){
				v+=loop[i];
				v=v%4;
				x+=vx[v];
				y+=vy[v];
				cout<<vec[v];
				break;
			}
			count++;
		}
	}
}

int main(){
	string tmp;
	for(int i=0;cin.eof()!=true;i++){
		cin>>tmp;
		if(i%2==0){
			maphor.push_back(tmp);
		}else{
			mapver.push_back(tmp);
		}
	}
	xsize=maphor[0].size()+1;
	ysize=mapver.size()+1;
	init();setmap();
	
	/*
	for(int i=0;i<xsize;i++){
		for(int j=0;j<ysize;j++){
			for(int k=0;k<4;k++){
				cout<<map[i][j][k];
			}
			cout<<" ";
		}
		cout<<endl;
	}*/
	solve();
	cout<<endl;
	
	return 0;
	
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

int hk=5; //0:上 1:右 2:下 3:左
int cnt=0;
string  w[12],ans="";
string shk[4]={"U","R","D","L"};

	rep(i,9) {
		cin >> w[i+1] ;
		w[i+1] = " " + w[i+1];
	}

	int x=1, y=1;
	if(w[1][1]=='1') { hk = 1; cout <<"R";}
	else			 {hk = 2; cout << "U";}

	while(1){
//		printf("\n%d h=%d (%d,%d) %c:",cnt,hk,y,x,w[y][x]);
		switch( hk){
		case  0:
			if(w[y-1][x-1] == '1' ) {
				hk = 3; y--; x--;}
			else if(w[y-2][x] == '1') {
				hk = 0; y -=2;}
			else if(w[y-1][x] == '1'){
				hk = 1; y--;}
			else {
				hk = 2; }
			break;
		case 1:
			if(w[y-1][x+1] == '1' ){
				hk = 0; y--; x++;}
			else if(w[y][x+1] == '1') {
				hk = 1; x++;}
			else if(w[y+1][x+1] == '1'){
				hk = 2; y++; x++;}
			else {
				hk = 3; }
			break;
		case 2:
			if(w[y+1][x] == '1' ) {
				hk = 1; y++; }
			else if(w[y+2][x] == '1' ) {
				hk = 2; y +=2;}
			else if( w[y+1][x-1] == '1'){
				hk = 3; y++; x--;}
			else {
				hk = 0;}
			break;
		case 3:
			if(w[y+1][x] == '1' ){
				hk = 2; y++; }
			else if(w[y][x-1] == '1') {
				hk = 3; x--;}
			else if( w[y-1][x] == '1'){
				hk = 0; y--; }
			else {
				hk = 1; }
			break;
		}
		cout << shk[hk];
//		ans = ans + shk[hk];
		cnt++; if(cnt>200) break;
		if(x==1 && y ==1) break;
	}	
	cout << endl;
//	cout << ans << endl;
	
	return 0;
	
	
}

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

using namespace std;

int can[40][40];
int inside[40][40];

// DLUR
int dx[] = {0,-1,0,1};
int dy[] = {1,0,-1,0};

string answer;

vector<int> v;
int dfs(int x,int y,int hand){
	if(x == 1 && y == 2 ) return 0;
	//cout << x << " " << y << endl;
	
	if( !can[y+dy[hand]][x+dx[hand]] ){
		//v.push_back(hand);
		y += dy[hand];
		x += dx[hand];
		hand = (hand+1)%4;
		
	}
	if( can[y+dy[(hand+3)%4]][x+dx[(hand+3)%4]] ){
		do{
			hand = (hand+1)%4;
		}while(!can[y+dy[hand]][x+dx[hand]]);
		v.push_back(hand);
	}
	v.push_back(hand);
	dfs(x+dx[(hand+3)%4],y+dy[(hand+3)%4],hand);
	
}
int main(){

	for(int i = 0 ; i < 9 ; i++){
		if( i % 2 ){
			for(int j = 0 ; j < 5 ; j++){
				char c;
				cin >> c;
				if( c == '1' ){
					can[1+i/2*3][1+3*j] = 1;
					can[1+i/2*3+1][1+3*j] = 1;
					can[1+i/2*3+2][1+3*j] = 1;
					can[1+i/2*3+3][1+3*j] = 1;
				}
			}
		}else{
			for(int j = 0 ; j < 4 ; j++){
				char c;
				cin >> c;
				if( c == '1' ){
					can[i/2*3+1][1+j*3+0] = 1; 
					can[i/2*3+1][1+j*3+1] = 1;
					can[i/2*3+1][1+j*3+2] = 1;  
					can[i/2*3+1][1+j*3+3] = 1; 
				}
			}
		}
	}
	dfs(1,0,0);
	v.push_back(-1);
	int idx = 0;
	for(int i = 1 ; i < v.size() ; i++){
		if( v[i] != v[i-1] ){
			int len = (i - idx);
			//cout << len << endl;
			cout << string((len+1)/3,"RDLU"[v[idx]]);
			idx = i;
		}
	}
	cout << endl;
	
}
/*
RRRRRDDDDDLLLLUUUURRRDDDLLUURULLDDDRRRUUUULLLL
RRRRDDDDLLLUUURRDDLURULLDDDRRRUUUULLLL
*/