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<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<map>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int kabe[5][5][5][5];

enum direct {
  RIGHT = 0,
  DOWN  = 1,
  LEFT  = 2,
  UP    = 3
};

const char *dstr = "RDLU";

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

#define D(d) (((d)+4)%4)

bool go(int x1, int y1, int x2, int y2){
  if(x2 < 0 || y2 < 0 || x2 >= 5 || y2 >= 5) return false;
  return kabe[x1][y1][x2][y2] == 1;
}

int main(){
  string str;
  REP(i,9){
    cin>>str;
    if(i%2 == 0){
      REP(j,4){
	int x = j;
	int y = i/2;
	if(str[j] == '1'){
	  kabe[x][y][x+1][y] = kabe[x+1][y][x][y] = 1;
	}
      }
    }else{
      REP(j,5){
	int x = j;
	int y = i/2;
	if(str[j] == '1'){
	  kabe[x][y][x][y+1] = kabe[x][y+1][x][y] = 1;
	}
      }
    }
  }
  int x = 0, y = 0;
  int d = RIGHT;
  while(x != 0 || y != 0 || d == RIGHT){
    d = D(d-1);
    while(!go(x,y,x+dx[d],y+dy[d])) d = D(d+1);
    putchar(dstr[d]);
    x += dx[d]; y += dy[d];
  }
  puts("");
  return 0;
}

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

bool flg = true;
int pos = 0;
char dir = 'R';
int bar[11][6] = {0};

void move(void)
{
	flg = false;
	switch(dir){
	case 'R':
		if	   (bar[pos/10  ][pos%10  ]) {pos-=20; dir='U'; cout<<dir;}
		else if(bar[pos/10+1][pos%10+1]) {pos+= 1; dir='R'; cout<<dir;}
		else if(bar[pos/10+2][pos%10  ]) {pos+=20; dir='D'; cout<<dir;}
		else							 {pos-= 1; dir='L'; cout<<dir;}
		break;
	case 'L':
		if	   (bar[pos/10  ][pos%10  ]) {pos-=20; dir='U'; cout<<dir;}
		else if(bar[pos/10+1][pos%10  ]) {pos-= 1; dir='L'; cout<<dir;}
		else if(bar[pos/10+2][pos%10  ]) {pos+=20; dir='D'; cout<<dir;}
		else							 {pos+= 1; dir='R'; cout<<dir;}
		break;
	case 'U':
		if	   (bar[pos/10+1][pos%10  ]) {pos-= 1; dir='L'; cout<<dir;}
		else if(bar[pos/10  ][pos%10  ]) {pos-=20; dir='U'; cout<<dir;}
		else if(bar[pos/10+1][pos%10+1]) {pos+= 1; dir='R'; cout<<dir;}
		else							 {pos+=20; dir='D'; cout<<dir;}
		break;
	case 'D':
		if	   (bar[pos/10+1][pos%10+1]) {pos+= 1; dir='R'; cout<<dir;}
		else if(bar[pos/10+2][pos%10  ]) {pos+=20; dir='D'; cout<<dir;}
		else if(bar[pos/10+1][pos%10  ]) {pos-= 1; dir='L'; cout<<dir;}
		else							 {pos-=20; dir='U'; cout<<dir;}
		break;
	}
}

int main(void)
{
	string str[10];

	for(int i=1; i<10; i++)
		cin >> str[i];

	for(int i=1; i<10; i++)
	{
		for(int j=0; j<5; j++)
		{
			if(i%2 == 1)
			{
				if(j!=0)
				{
					bar[i][j] = atoi(str[i].substr(j-1,1).c_str());
				}
			}
			else
			{
				bar[i][j] = atoi(str[i].substr(j,1).c_str());
			}
		}
	}
	
	while(pos!=0 || flg==true)
		move();

	cout << endl;

	return 0;
}

C++: #include <cstdio>
#include <cctype>
#include <utility>
#include <array>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

struct P {int x, y;};

int main() {
	const int d[4][4] = {{0, 0, 1, 0}, {0, -1, 0, -2}, {-1, 0, -1, 0}, {0, 1, 0, 2}};
	array<array<int, 6>, 11> m{};
	for (int i = 1; i <= 9; i++) {
		for (int j = 1, e = 5 - i % 2; j <= e; j ++)
			m[i][j] = gcu() - '0';
		gcu();
	}
	P p = {1, 1};
	int r = 0;
	do {
		for (r = (r + 1) % 4;; r = (r + 3) % 4)
			if (m[p.y + d[r][1]][p.x + d[r][0]]) {
				p.x += d[r][2], p.y += d[r][3];
				break;
			}
		out("RULD"[r]);
	} while(!(p.x == 1 && p.y == 1));
	outl();
}

C++: //35
#include<iostream>

using namespace std;

int main(){
  bool w[11][11]={{}};
  for(int i=1;i<=9;i++){
    for(int j=1+i%2;j<10;j+=2){
      char c;
      cin>>c;
      w[i][j]=c-'0';
    }
  }
  int y=0,x=2;
  int d=1;
  int dy[]={-1,0,1,0};
  int dx[]={0,1,0,-1};
  do{
    const char *s="URDL";
    d=(d+1)%4;
    while(w[y+dy[d]][x+dx[d]]){
      cout<<s[(d+3)%4];
      d=(d+3)%4;
    }
    y+=dy[d]*2;
    x+=dx[d]*2;
  }while(x||y);
  cout<<endl;
  return 0;
}