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 <stdio.h>
#include <string.h>
#define ROW_BLOCK 4
#define COL_BLOCK 4
#define ROW_NUM (ROW_BLOCK + 2) * 2 - 1
#define COL_NUM (COL_BLOCK + 2) * 2 - 1
#define UP 0
#define RIGHT 1
#define DOWN 2
#define LEFT 3

const char command[5] = "URDL";
const int dy[4] = {-1,0,1,0}, dx[4] = {0,1,0,-1};
const int gy = 1, gx = 1;

int main(void){
	int i, j, stage[ROW_NUM][COL_NUM];
	memset(stage,0,sizeof(stage));
	for(i = 1;i < ROW_NUM - 1;i++){
		char str[ROW_BLOCK + 2];
		scanf("%s",str);
		for(j = 1 + i % 2;j < COL_NUM - 1;j+=2){
			stage[i][j] = str[(j - 1) / 2] - '0';
		}
	}
	int nd = RIGHT, nx = 1, ny = 1, add = 1;
	do{
		if(stage[ny + dy[nd]][nx + dx[nd]] == 0 && stage[ny + dy[(nd + 3) % 4]][nx + dx[(nd + 3) % 4]] == 0){ // 今向いている方向に壁がなければ
			nd = (nd + 1) % 4;
			ny += dy[nd] * 2;
			nx += dx[nd] * 2;
		}else if(stage[ny + dy[(nd + 3) % 4]][nx + dx[(nd + 3) % 4]] == 1){
			nd = (nd + 3) % 4;
			ny += dy[nd] * 2;
			nx += dx[nd] * 2;
		}else{
			ny += dy[nd] * 2;
			nx += dx[nd] * 2;
		}

		printf("%c",command[nd]);
/*		for(i = 0;i < ROW_NUM;i++){
			for(j = 0;j < COL_NUM;j++){
				if(ny == i && nx == j){
					printf("# ");
				}else{
					printf("%d ",stage[i][j]);
				}
			}
			printf("\n");
		}*/
	}while(!((nx == gx) && (ny == gy)));
	printf("\n");
	return 0;
}

C++: #include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>  
#include<map>
#include<set>
using namespace std;

int main(){
	bool f[13][13]={};
	int TT[15][15]={};
	string p,q;
	for(int i=1;i<=4;i++){
		cin>>p>>q;
		for(int j=0;j<p.size();j++)
			if(p[j]=='1')f[2*i-1][j+1]=1;
		for(int j=0;j<q.size();j++)
			if(q[j]=='1')f[i*2][j+1]=1;
	}
	cin>>p;
		for(int j=0;j<p.size();j++)
			if(p[j]=='1')f[9][j+1]=1;
	/*for(int i=0;i<=10;i++){
		for(int j=0;j<=5;j++)
			cout<<f[i][j];
		cout<<endl;
	}*/
	int x=1,y=1;
	char z='R';int v=0;
	while(1){
		if(z=='R'){
			if(f[y-1][x]){
				cout<<"U";z='U';y-=2;
			}
			else if(f[y][x]){
				cout<<"R";z='R';x++;
			}
			else{
				cout<<"D";z='D';y+=2;
			}
		}
		else if(z=='L'){
			if(f[y+1][x]){
				cout<<"D";z='D';y+=2;
			}
			else if(f[y][x-1]){
				cout<<"L";z='L';x--;
			}
			else{
				cout<<"U";z='U';y-=2;
			}
		}

		else if(z=='U'){
			if(f[y][x-1]){
				cout<<"L";z='L';x--;
			}
			else if(f[y-1][x]){
				cout<<"U";z='U';y-=2;
			}
			else{
				cout<<"R";z='R';x++;
			}
		}
		else if(z=='D'){
			if(f[y][x]){
				cout<<"R";z='R';x++;
			}
			else if(f[y+1][x]){
				cout<<"D";z='D';y+=2;
			}
			else{
				cout<<"L";z='L';x--;
			}
		}
		if(x==1&&y==1)break;
		v++;
		//if(v>30)break;
		//cout<<x<<" "<<y<<"#"<<v<<endl;
		TT[y][x]=v;
	}/*
	for(int i=0;i<=10;i++){
		for(int j=0;j<=5;j++)
			cout<<TT[i][j];
		cout<<endl;
	}
	*/

	cout<<endl;
	return 0;
}

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

int i, j, a[6][6] = {}, b[6][5] = {};
string output = "";

int right(), left(), up(), down();

int right(){
	output += "R";
	if(b[i-1][j] == 1){
		i--;
		up();
	}
	else if(a[i][j+1] == 1){
		j++;
		right();
	}
	else if (a[i][j + 1] == 2) {  }
	else {
		down();
	}
	return 0;
}

int left(){
	output += "L";
	if (b[i][j-1] == 1) {
		j--;
		down();
	}
	else if (a[i][j-1] == 1) {
		j--;
		left();
	}
	else if (a[i][j - 1] == 2) { output += "L"; }
	else {
		i--;
		j--;
		up();
	}
	return 0;
}

int up(){
	output += "U";
	if (a[i][j] == 1) {
		left();
	}
	else if (a[i][j] == 2) { output += "L"; }
	else if (b[i-1][j] == 1) {
		i--;
		up();
	}
	else if (a[i][j + 1] == 2) {  }
	else {
		j++;
		right();
	}
	return 0;
}

int down(){
	output += "D";
	if (a[i+1][j+1] == 1) {
		i++;
		j++;
		right();
	}
	else if (a[i + 1][j + 1] == 2) {  }
	else if (b[i + 1][j] == 1) {
		i++;
		down();
	}
	else if (a[i + 1][j] == 2) { output += "L"; }
	else {
		i++;
		left();
	}
	return 0;
}

int main(){
	string input, k;
	for(i = 1; i<10;i++){
		getline(cin, input);
		if (input.size() != 4) {
			for(int j= 0;j<5;j++){
				k = input[j];
				b[i / 2][j] = stoi(k);
			}
		}
		else{
			for(int j = 1;j<5;j++){
				k = input[j-1];
				a[(i + 1)/ 2][j] = stoi(k);
			}
		}

	}

	a[1][1] = 2;
	i = 1;
	j = 1;
	right();
	cout << output << endl;
	return 0;
}

C++: 
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int g[6][6][4]={};//top,bottom,left,right

int main(void) {
  int i,j;
  rep(i,9){
    string s;
    cin>>s;
    if(i%2){
      rep(j,5){
        g[i/2+1][j][3] = s[j] - '0';
        g[i/2+1][1+j][2] = g[i/2+1][j][3];
      }
    }else{
      rep(j,4){
        g[i/2+1][1+j][0] = s[j] - '0';
        g[i/2][1+j][1] = g[i/2+1][1+j][0];
      }
    }
  }

  char s[5] = {"LRDU"};
  int dx[4] = {0,0,1,-1};
  int dy[4] = {-1,1,0,0};

  int x=0,y=1,z=1;//(x,y)右手がz

  while(x+y){
    if(g[x][y][z]){
        cout<<s[z];
        if((z==1 && g[x][y][1] && g[x][y][3]) || (z==0 && g[x][y][0] && g[x][y][2]) ||
          (z==2 && g[x][y][2] && g[x][y][1]) || (z==3 && g[x][y][3] && g[x][y][0])){
            switch(z){
              case 0: z=2;break;
              case 1: z=3;break;
              case 2: z=1;break;
              case 3: z=0;break;
            }
        }else{
          x = x + dx[z];
          y = y + dy[z];
        }
    }else{
      switch(z){
        case 0: z=3;x--;break;
        case 1: z=2;x++;break;
        case 2: z=0;y--;break;
        case 3: z=1;y++;break;
      }
    }
  }
    cout<<endl;
}