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 <sstream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef vector <string> VS;
const int size = 9;

int main() {
    VS lines( size );
    for ( int i = 0; i < size; ++ i ) {
        cin >> lines[i];
    }

    bool O[size + 5][size + 5];
    for ( int i = 0; i < size + 5; ++ i ) {
        for ( int j = 0; j < size + 5; ++ j ) {
            O[i][j] = false;
        }
    }
    for ( int i = 0; i < size; ++ i ) {
        for ( int j = 0; j < ( i % 2 == 0 ? 4 : 5 ); ++ j ) {
            O[i+2][j+2] = ( lines[i][j] == '1' );
        }
    }

    const string T  = "RDLU";
    const int R = 0;
    const int D = 1;
    const int L = 2;
    const int U = 3;
    int r = 2;
    int c = 2;
    int s = R;

    while ( true ) {
        putchar( T[s] );
        if ( r == 2 && c == 2 && s == L ) break;
        if ( r == 3 && c == 2 && s == U ) break;

        if ( s == L ) {
            if ( O[r + 1][c] ) {
                ++ r;
                s = D;
            } else if ( O[r][c - 1] ) {
                -- c;
                s = L;
            } else if ( O[r - 1][c] ) {
                -- r;
                s = U;
            } else if ( O[r][c + 1] ) {
                ++ c;
                s = R;
            } else {
                break;
            }
        } else if ( s == R ) {
            if ( O[r - 1][c + 1] ) {
                -- r;
                ++ c;
                s = U;
            } else if ( O[r][c + 1] ) {
                ++ c;
                s = R;
            } else if ( O[r + 1][c + 1] ) {
                ++ r;
                ++ c;
                s = D;
            } else if ( O[r][c - 1] ) {
                -- c;
                s = L;
            } else {
                break;
            }
        } else if ( s == U ) {
            if ( O[r - 1][c - 1] ) {
                -- r;
                -- c;
                s = L;
            } else if ( O[r - 2][c] ) {
                r -= 2;
                s = U;
            } else if ( O[r - 1][c] ) {
                -- r;
                s = R;
            } else if ( O[r + 2][c] ) {
                r += 2;
                s = D;
            } else {
                break;
            }
        } else if ( s == D ) {
            if ( O[r + 1][c] ) {
                ++ r;
                s = R;
            } else if ( O[r + 2][c] ) {
                r += 2;
                s = D;
            } else if ( O[r + 1][c - 1] ) {
                ++ r;
                -- c;
                s = L;
            } else if ( O[r - 2][c] ) {
                r -= 2;
                s = U;
            } else {
                break;
            }
        }
    }
    putchar( '\n' );
    
    return 0;
}

C++: #include<stdio.h>
#define r(i,n) for(int i=0;i<n;++i)
int f[5][5];
main(e,f)
{
	r(i,9){
		char s[6];
		scanf("%s",s);
		if(i%2){
			r(j,5){
				int a=s[j]-'0';
				f[i/2][j]|=a<<2;
				f[i/2+1][j]|=a;
			}
		}else{
			r(j,4){
				int a=s[j]-'0';
				f[i/2][j]|=a<<1;
				f[i/2][j+1]|=a<<3;
			}
		}
	}
	printf("R");
	int y=0,x=1,p=1;
	do{
		p=(p+2)%4;
		int d=p;
		do
			d=(d+1)%4;
		while(!((f[y][x]>>d)&1));
		p=d;
		putchar("URDL"[d]);
		int dx[] = {0, 1, 0, -1};
		int dy[] = {-1, 0, 1, 0};
		x+=dx[d];
		y+=dy[d];
	}while(y!=0||x!=0||f[0][0]==6&&p==3);
	puts("");
}

C++: #include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;


int zu[20][20];

int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};//UP,RIGHT,DOWN,LEFT
char pr[]={'U','R','D','L'};

main(){
	
	for(int i=0;i<13;i++){
		zu[0][i]=1;
		zu[i][0]=1;
		zu[12][i]=1;
		zu[i][12]=1;
	}
	
	for(int i=0;i<9;i++){
		if(i&1){
			for(int j=0;j<5;j++){
				char c;
				cin>>c;
				if(c-'0'){
					zu[i+2][j*2+2]=1;
					zu[i+1][j*2+2]=1;
					zu[i+3][j*2+2]=1;
				}
			}
		}else{
			for(int j=0;j<4;j++){
				char c;
				cin>>c;
				if(c-'0'){
					zu[i+2][j*2+3]=1;
					zu[i+2][j*2+2]=1;
					zu[i+2][j*2+4]=1;
				}
			}
		}
	}
	
	int x=2,y=2,d=1;
	while(true){
		int td=(d+3)%4;
		for(int i=0;i<4;i++){
			if(zu[y+dy[td]][x+dx[td]])break;
			td=(td+1)%4;
		}
		d=td;
		cout<<pr[d];
		x+=2*dx[d];
		y+=2*dy[d];
		if(x==2 && y==2)break;
	}
	cout<<endl;
}

C++: ツづ卍つーツつ「

C++: #include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int a[9][9][4],x,y,dir=1;
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
string s="URDL";
int main(){
  r(i,9){
    if(i%2){
      r(j,5){
        scanf("%1d",&x);
        if(x)a[i/2][j][2]=a[i/2+1][j][0]=1;
      }
    }else{
      r(j,4){
        scanf("%1d",&x);
        if(x)a[i/2][j][1]=a[i/2][j+1][3]=1;
      }
    }
  }x=1;
  while(!(!x&&!y)){
    cout<<s[dir];
    if(a[y][x][(dir+3)%4])dir=(dir+3)%4;
    else if(a[y][x][dir]);
    else if(a[y][x][(dir+1)%4])dir=(dir+1)%4;
    else dir=(dir+2)%4;
    x+=dx[dir];
    y+=dy[dir];
  }
  cout<<endl;
}

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

int map[12][12] = {0};
enum Dir{ RIGHT , DOWN , LEFT , UP };
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
char d[4] = { 'R' , 'D' , 'L' , 'U'};

int main(){
	int x = 2, y = 0, dir = RIGHT;
	string f;

	for(int y=0 ; y<9 ; y++){
		cin >> f;
		for(unsigned int x=0 ; x<f.size() ; x++){
			map[y+1][2*x+((y+1)%2)+1] = f[x] - '0';
		}
	}
	
	while( 1 ){
		if( x==0 && y==2 ) break;
		int mx = x + dx[dir];
		int my = y + dy[dir];
		int nx = x + dx[(dir+1)%4];
		int ny = y + dy[(dir+1)%4];
		if( map[ny][nx] == 1 ){
			cout << d[dir];
		}

		if( map[my][mx] == 0 ){		
			if( map[ny][nx] == 0 ){
				dir = (dir + 1) % 4;
				nx = x + dx[(dir+1)%4];
				ny = y + dy[(dir+1)%4];
				if( map[ny][nx] == 1 ){
					cout << d[dir];
				}
				x += dx[dir] * 2;
				y += dy[dir] * 2;
			}else{
				x += dx[dir] * 2;
				y += dy[dir] * 2;
			}
		}else{
			if( map[ny][nx] == 0 ){
				dir = ( dir + 1 ) % 4;
				nx = x + dx[(dir+1)%4];
				ny = y + dy[(dir+1)%4];
				if( map[ny][nx] == 1 ){
					cout << d[dir];
				}
				x += dx[dir] * 2;
				y += dy[dir] * 2;
			}else{
				dir = ( dir + 3 ) % 4;
			}
		}
	}
	cout << endl;
	return 0;
}