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 <bits/stdc++.h>
using namespace std;

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

const int N = 5,M = 9;
int edge [25] [25];
const int dx [] = {0,1,0,-1};
const int dy [] = {-1,0,1,0};
string d = "URDL";

bool in_range(int y,int x)
{
	return y >= 0 && y < N && x >= 0 && x < N;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	FOR(i,0,M){
		string s;
		cin >> s;
		FOR(j,0,s.size()) if(s [j] == '1'){
			if(i % 2 == 0){
				edge [(i / 2) * N + j] [(i / 2) * N + j + 1] = true;
				edge [(i / 2) * N + j + 1] [(i / 2) * N + j] = true;
			}
			else{
				edge [(i / 2) * N + j] [(i / 2 + 1) * N + j] = true;
				edge [(i / 2 + 1) * N + j] [(i / 2) * N + j] = true;
			}
		}
	}

	string ans(1,'R');
	int y = 0,x = 1,dir = 1;
	while(y || x){
		for(int i = 3;i <= 6;i++){
			int ny = y + dy [(dir + i) % 4],nx = x + dx [(dir + i) % 4];
			if(in_range(ny,nx) == false || edge [y * N + x] [ny * N + nx] == false) continue;
			y = ny;
			x = nx;
			ans += d [(dir + i) % 4];
			(dir += i) %= 4;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<math.h>
#include<queue>
using namespace std;

int main(){
	char stage[9][5] = {};
	for (int i = 0; i < 9; i++){
		cin >> stage[i];
		for (int j = 0; j < 5; j++){
			if (stage[i][j] != 0){
				stage[i][j] -= '0';
			}
		}
	}

	//for (int i = 0; i < 9; i++){ for (int j = 0; j < 5; j++) printf("%d ", stage[i][j]); puts(""); }

	int y = 0, x = 0, ny, nx, situ = 1;
	int situ_y[4] = { -1, 0, 1, 0 }, situ_x[4] = { 0, 0, 0, -1 };
	int np_y[4] = { -2, 0, 2, 0 }, np_x[4] = { 0, 1, 0, -1 };
	char situ_char[4] = { 'U', 'R', 'D', 'L' };
	do{
		situ += 3;
		situ %= 4;
		//printf("%d,%d  ", x, y);
		for (int i = 0; i < 4; i++, situ = (situ + 1) % 4){
			ny = y + situ_y[situ];
			nx = x + situ_x[situ];
			//printf(" %d:%d,%d", situ, ny, nx);
			if (ny < 0 || 8 < ny || nx < 0 || 4 < nx) continue;
			if (stage[ny][nx] == 1){
				y += np_y[situ];
				x += np_x[situ];
				//printf("test\n");
				printf("%c", situ_char[situ]);
				break;
			}
		}
	} while (y != 0 || x != 0);
	puts("");
	return 0;
}

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

using db = double;
using ll = long long;
using vi = vector <int>;
#define op operator
#define pb push_back

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

const int N = 11;
bool a[N][N][4];
char c[4] = {'R', 'D', 'L', 'U'};

int main() {
	//ios :: sync_with_stdio(0);

	for(int i = 0; i < 9; i ++) {
		string s; cin >> s;
		if(i & 1) {
			for(int j = 0; j < 5; j ++)
				if(s[j] == '1') {
					a[i / 2][j][1] = 1;
					a[i / 2 + 1][j][3] = 1;
				}
		} else {
			for(int j = 0; j < 4; j ++)
				if(s[j] == '1') {
					a[i / 2][j][0] = 1;
					a[i / 2][j + 1][2] = 1;
				}
		}
	}

	int x = 0, y = 0, d = 0;
	for(;;) {
		d = (d + 3) % 4;
		while(!a[x][y][d])
			d = (d + 1) % 4;
		//cout << x << ' ' << y << ' ' << d << '\n';
		x += dx[d]; y += dy[d];
		cout << c[d];
		if(!x && !y) break;
	}
	cout << '\n';

	return 0;
}

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

const int horz_node_count = 5;
const int vert_node_count = 5;
const int direction_count = 4;	// [0]:left, [1]:up, [2]:right [3]:down
enum { left, up, right, down };

int index(int x, int y, int direction)
{
	return (y * horz_node_count + x) * direction_count + direction;
}

void read_data(int* walls)
{
	std::vector<std::string> input;
	for (int i = 0; i < vert_node_count * 2 - 1; ++i) {
		std::string line;
		if (std::getline(std::cin, line)) {
			input.push_back(line);
		}
	}

	std::fill_n(walls, horz_node_count * vert_node_count * direction_count, 0);

	for (int y = 0; y < vert_node_count; ++y) {
		for (int x = 0; x < horz_node_count - 1; ++x) {
			if (input[y*2][x] == '1') {
				walls[index(x,y,right)] = 1;
				walls[index(x+1,y,left)] = 1;
			}
		}
	}
	for (int y = 0; y < vert_node_count - 1; ++y) {
		for (int x = 0; x < horz_node_count; ++x) {
			if (input[y*2+1][x] == '1') {
				walls[index(x,y,down)] = 1;
				walls[index(x,y+1,up)] = 1;
			}
		}
	}
}

bool wall_exists(const int* walls, int x, int y, int direction)
{
	return (0 <= x && x < horz_node_count)
		&& (0 <= y && y < vert_node_count)
		&& (walls[index(x,y,direction)] != 0);
}

int main()
{
	int walls[horz_node_count * vert_node_count * direction_count] = {};
	read_data(walls);

	int x = 0, y = 0, direction = right;
	do {
		// determine the next direction
		direction = (direction + direction_count - 1) % direction_count;
		for (int i = 0; i < 4; ++i) {
			if (wall_exists(walls, x, y, direction)) {
				break;
			}
			direction = (direction + 1) % direction_count;
		}
		// step forward
		switch (direction) {
			case left:
				--x;
				std::cout << 'L';
				break;
			case up:
				--y;
				std::cout << 'U';
				break;
			case right:
				++x;
				std::cout << 'R';
				break;
			case down:
				++y;
				std::cout << 'D';
				break;
		}
	} while (x > 0 || y > 0);

	return 0;
}

C++: #include<stdio.h>
char f[6][6],s[6],i,j,a,y,x,p,b;
int main()
{
	for(;i<9;++i,b=!b){
		scanf("%s",s);
		for(j=0;j<4+b;++j){
			a=s[j]-48;
			f[i/2][j]|=a<<1+b;
			f[i/2+b][j+!b]|=a<<3-b*3;
		}
	}
	do{
		while(!((f[y][x]>>(p=(p+1)%4))&1));
		putchar("URDL"[p]);
		x+=p?2-p:0;
		y+=p==3?0:p-1;
		p=(p+2)%4;
	}while(y|x|f[0][0]==6&p==3);
	return!puts(""); 
}

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

string str[100];
int len;
int fie[101][101];
int m;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
char s[4]={'R','D','L','U'};
int main(void){
	int n=0;
	while(cin >> str[n])n++;
	if(n>9){
		printf("0\n")
		return 0;
	}
	m=str[0].size();
	for(int i=0;i<n;i++){
		for(int j=0;j<str[i].size();j++){
			if(str[i][j]=='1'){
				if(i%2==0)fie[j*2+2][i+1]=1;
				if(i%2==1)fie[j*2+1][i+1]=1;
			}
		}
	}
	int x=2,y=0,dir=0;
	while(1){
		int nx=x+dx[(dir+1)%4],ny=y+dy[(dir+1)%4];
		if(nx>=0 && nx<=m*2+2 && ny>=0 && ny<=n+1){
			if(fie[nx][ny]==1)printf("%c",s[dir]);
		}
		nx=x+dx[dir],ny=y+dy[dir];
		if(nx>=0 && nx<=m*2+2 && ny>=0 && ny<=n+1){
			if(fie[nx][ny]==0){
				x+=dx[dir]*2;
				y+=dy[dir]*2;
				if(fie[x+dx[(dir+1)%4]][y+dy[(dir+1)%4]]==0){
					dir=(dir+1)%4;
				}
			}else{
				if(fie[x+dx[(dir+3)%4]][y+dy[(dir+3)%4]]==0){
					dir=(dir+3)%4;
					x+=dx[dir]*2;
					y+=dy[dir]*2;
					printf("%c",s[dir]);
				}else{
					dir=(dir+2)%4;
					x+=dx[dir]*2;
					y+=dy[dir]*2;
					printf("%c",s[(dir+1)%4]);
					printf("%c",s[dir]);
				}
			}
		}else dir=(dir+1)%4;
		//printf("%d %d %d %d %d\n",x,y,dir,dx[dir],dy[dir]);
		if(x==0 && y==0)break;
	}
	printf("\n");
	return 0;
}