Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		X, _ := strconv.Atoi(buf[0])
		Y, _ := strconv.Atoi(buf[1])
		if X == 0 && Y == 0 {
			break
		}
		tbl := make([][]int, Y+2)
		field := make([][]int, Y+2)
		for i := range field {
			field[i] = make([]int, X+2)
			tbl[i] = make([]int, X+2)
			for j := range field[i] {
				field[i][j] = 2
				tbl[i][j] = 0
			}
		}
		buf_ := make([][]string, Y)
		for i := range buf_ {
			scanner.Scan()
			buf_[i] = strings.Split(scanner.Text(), " ")
		}
		for i := 1; i <= Y; i++ {
			for j := 1; j <= X; j++ {
				field[i][j], _ = strconv.Atoi(buf_[i-1][j-1])
				switch field[i][j] {
				case 0:
					if i == 1 {
						tbl[i][j] = 1 // スタートy=1
					} else {
						if field[i-1][j-1] != 2 {
							tbl[i][j] += tbl[i-1][j-1] // 左上からやってくる
						}
						if field[i-1][j] != 2 {
							tbl[i][j] += tbl[i-1][j] // 真上からやってくる
						}
						if field[i-1][j+1] != 2 {
							tbl[i][j] += tbl[i-1][j+1] // 右上からやってくる
						}
						if field[i-2][j] == 2 {
							tbl[i][j] += tbl[i-2][j] // ジャンプしてくる
						}
					}
				case 1:
					tbl[i][j] = 0 // 障害物あり
				case 2:
					if field[i-1][j] != 2 {
						tbl[i][j] += tbl[i-1][j] // 真上からくる
					}
					if field[i-2][j] == 2 {
						tbl[i][j] += tbl[i-2][j] // ジャンプ台からジャンプしてくる
					}
				}
			}
		}
		sum := 0
		for i := 1; i <= X; i++ {
			sum += tbl[Y][i] // とびこさないでゴール
			if field[Y-1][i] == 2 {
				sum += tbl[Y-1][i] // 飛び越してゴール
			}
		}
		fmt.Println(sum)
	}
}

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

int dmap[15][15];
int dpmap[15][15];
int dfs(int, int, int);
int dx[]={-1, 0, 1};
int h, w;

int main(){
  while(1){
    cin >> w >> h;
    if(w==0 && h==0) break;

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin >> dmap[i][j];
      }
    }


    int ans=0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	dpmap[i][j]=-1;
      }
    }
    for(int i=0;i<w;i++){
      if(dmap[0][i]==0){
	int tmp=dfs(0,i,1);
	if(tmp!=0) ans+=tmp;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

int dfs(int y, int x, int d){
  int sum=0;
  if(y>=h){
    return 1;
  }
  else if(dmap[y][x]==1){
    dpmap[y][x]=0;
    return 0;
  }
  else if(dmap[y][x]==2){
    if(d==1){
      if(y==h-2){
	dpmap[y][x]=1;
	return 1;
      }
      if(dpmap[y+2][x]!=-1){
	sum+=dpmap[y+2][x];
	dpmap[y][x]=sum;
	return sum;
      }
      else{
	sum+=dfs(y+2, x, 1);
	dpmap[y][x]=sum;
	return sum;
      }
    }
    else{
      return 0;
    }
  }
else if(y==h-1){
    sum+=dfs(y+1, x, 1);
    dpmap[y][x]=sum;
    return sum;
  }
 else{
    for(int i=0;i<3;i++){
      int tx=x+dx[i];
      int ty=y+1;
      if(tx<0 || tx>=w) continue;
      if(dmap[ty][tx]==1) continue;
      if(dmap[ty][tx]==2 && i!=1) continue;
      if(dpmap[ty][tx]!=-1){
	sum+=dpmap[ty][tx];
      }
      else sum+=dfs(ty, tx, i);
    }
  }
  dpmap[y][x]=sum;
  return sum;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 20000
#define MAX_M 16

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int x, y;
int field[16][16];
int dp[16][16];

int main(){
	while (cin >> x >> y&&x + y){
		REP(i, 16){
			REP(j, 16){
				dp[i][j] = 0;
				field[i][j] = 0;
			}
		}
		REP(i, y)REP(j, x)cin >> field[i][j];
		REP(j, x){
			if (field[0][j] == 0)dp[0][j] = 1;
		}
		REP(i, y-1){
			REP(j, x){
				if (field[i][j] == 0){
					if (field[i + 1][j] != 1)dp[i + 1][j] += dp[i][j];
					if (j - 1 >= 0 && field[i + 1][j - 1] == 0){
						dp[i + 1][j - 1] += dp[i][j];
					}
					if (j + 1 < x&&field[i + 1][j + 1] == 0){
						dp[i + 1][j + 1] += dp[i][j];
					}
				}
				else if (field[i][j] == 2){
					if (i <= y - 3 && dp[i + 2][j] != 1){
						dp[i + 2][j] += dp[i][j];
					}
					else if (i == y - 2){
						dp[i + 1][j] += dp[i][j];
					}
				}
			}
		}
		cout << endl;
		REP(i, y + 1){
			REP(j, x){
				cout << dp[i][j] << " ";
			}
			cout << endl;
		}
		int ans = 0;
		REP(j, x)ans += dp[y-1][j];
		cout << ans << endl;
	}
}

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

using namespace std;

int vis[15][15];

int bfs(int a[15][15], int n, int m, int s, int t)
{
  int c = 0;
  if(s+1 == n){
    vis[s][t] = 1;
    return 1;
  }

  if(vis[s][t] > 0){
    return vis[s][t];
  }

  if(a[s][t] == 2){
    if(s+2 >= n){
      vis[s][t] = 1;
      return 1;
    }
    c = bfs(a, n, m, s+2, t);
  } else {

    if(t-1 >= 0){
      if(a[s+1][t-1] == 0){
	c += bfs(a, n, m, s+1, t-1);
      }
    }
    if(a[s+1][t] != 1){
      c += bfs(a, n, m, s+1, t);
    }
    
    if(t+1 < m){
      if(a[s+1][t+1] == 0){
      c += bfs(a, n, m, s+1, t+1);
      }
    }
  }
  vis[s][t] = c;

  return c;
}

int main()
{
  int n, m, c;
  int a[15][15];

  while(1){
    cin >> m >> n;
    if(n == 0 && m == 0){
      break;
    }

    fill(&vis[0][0], &vis[14][14], -1);

    for(int i = 0; i < n; i++){
      for(int j = 0; j < m; j++){
	cin >> a[i][j];
      }
    }
    c = 0;
    for(int i = 0; i < m; i++){
      if(a[0][i] != 1){
	c += bfs(a, n, m, 0, i);
      }
    }
    for(int i = 0; i < n; i++){
      for(int j = 0; j < m; j++){
	printf("%2d ", vis[i][j]);
      }
      cout << endl;
    }

    cout << c << endl;
  }


  return 0;
}

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

int main()
{
	int X, Y;

	while( cin >> X >> Y && ( X || Y ) ){
		vector< vector< int > > map( Y + 1, vector< int >( X + 2, 0 ) );
		vector< vector< int > > memo = map;
		for( int i = 1; i < Y + 1; ++i ){
			for( int j = 1; j < X + 1; ++j ){
				cin >> map[ i ][ j ];
			}
		}
		for( int i = 1; i < X + 1; ++i ){
			if( map[ 1 ][ i ] == 0 ){
				memo[ 1 ][ i ] = 1;
			}
		}
		for( int i = 2; i < Y + 1; ++i ){
			for( int j = 1; j < X + 1; ++j ){
				if( map[ i ][ j ] == 1 ) continue;
				if( map[ i ][ j ] == 2 ){
					memo[ i ][ j ] = memo[ i - 1 ][ j ];
				}else{
					for( int k = -1; k < 2; ++k ){
						if( map[ i - 1 ][ j + k ] == 0 ){
							memo[ i ][ j ] += memo[ i - 1 ][ j + k ];
						}
					}
				}
				if( map[ i - 2 ][ j ] == 2 ){
					memo[ i ][ j ] += memo[  i - 2 ][ j ];
				}
			}
		}
		int ans = 0;
		for( int i = 1; i < X + 1; ++i ){
			ans += memo[ Y ][ i ];
			if( map[ Y - 1 ][ i ] == 2 ){
				ans += memo[ Y - 1 ][ i ];
			}
		}
		cout << ans << endl;
	}

	return 0;
}