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<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int x,y;
int c[20][20];
int dp[20][20];

void solve() {
    rep(i,20) rep(j,20) c[i][j]=1;
    rep(i,20) rep(j,20) dp[i][j]=0;
    rep(i,y) rep(j,x) cin>>c[i][j];
    rep(i,x) if(c[0][i]!=1) dp[0][i]=1;//????????????????????????????????£??????DP???????????????????¨?????????????
    for(int i=0;i<y;i++) {
        for(int j=0;j<x;j++) {
            if(c[i][j]==2) {
                dp[i+2][j] += dp[i][j];
            }
            else if(c[i][j]==0) {
                if(c[i+1][j]!=1) {
                    dp[i+1][j] += dp[i][j];
                }
                if(0<=j-1 && c[i+1][j-1]==0) {
                    dp[i+1][j-1] += dp[i][j];
                }
                if(j+1 < x && c[i+1][j+1]==0) {
                    dp[i+1][j+1] += dp[i][j];
                }
            }
        }
    }
    int ans=0;
    rep(i,x) if(c[y-1][i]!=1) ans+=dp[y-1][i];
    rep(i,x) ans+=dp[y][i];
    cout<<ans<<endl;
}
int main() {
    while(cin>>x>>y) {
        if(x+y==0) return 0;
        solve();
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cassert>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

int m[500][500];
int dp[500][500];

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

int solve(int r,int c){
  rep(i,r+2)rep(j,c)dp[i][j]=0;
  rep(j,c)if(m[0][j] == 0)dp[0][j]=1;

  rep(i,r){
    rep(j,c){
      if (m[i][j] == 0 && i != r-1){
	rep(k,3){
	  int nex = j+dx[k];
	  if (nex<0||nex>=c)continue;
	  if (m[i+1][nex] == 0)dp[i+1][nex]+=dp[i][j];
	  else if (m[i+1][nex] == 2 && k == 1)dp[i+1][nex]+=dp[i][j];
	}
      }else if (m[i][j] == 2 && m[i+2][j] != 1){
	dp[i+2][j]+=dp[i][j];
      }
    }
  }
  
  int ans = 0;
  rep(j,c)ans+=dp[r][j]+dp[r-1][j];//+dp[r+1][j];
  return ans;
}

main(){
  int c,r;
  while(cin>>c>>r && r){
    rep(i,r)rep(j,c)cin>>m[i][j];
    rep(j,c)if (m[r-1][j] == 2){
      assert(false);
    }
    rep(j,c)m[r][j]=m[r+1][j]=0;
    cout << solve(r,c) << endl;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 30;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

int n, m;
int dp[ 16 ][ 16 ];
int _array[ 16 ][ 16 ];
VI can_start;

int solve( int now, int x ) {
	if ( now >= m ) {
		return 1;
	}
	if ( _array[ now ][ x ] == 1 ) {
		return 0;
	}
	if ( now >= m - 1 ) {
		return 1;
	}
	if ( dp[ now ][ x ] >= 0 ) {
		return dp[ now ][ x ];
	}
	int res = 0;
	if ( _array[ now ][ x ] == 2 ) {
		res += solve( now + 2, x );
	}
	else {
		for ( int i = 0; i < 3; i++ ) {
			if ( x + dx[ i ] < 0 || x + dx[ i ] >= n || ( now + 1 != m && _array[ now + 1 ][ x + dx[ i ] ] == 2 && dx[ i ] != 0 ) ) {
				continue;
			}
			res += solve( now + 1, x + dx[ i ] );
		}
	}
	return dp[ now ][ x ] = res;
}

int main() {
	while ( ~scanf( "%d %d", &n, &m ) && n != 0 && m != 0 ) {
		for ( int i = 0; i < m; i++ ) {
			for ( int j = 0; j < n; j++ ) {
				scanf( "%d", &_array[ i ][ j ] );
				if ( i == 0 && _array[ i ][ j ] == 0 ) {
					can_start.push_back( j );
				}
			}
		}
		NCLR( dp );
		int ans = 0;
		for ( int i = 0; i < can_start.size(); i++ ) {
			ans += solve( 0, can_start[ i ] );
		}
		printf( "%d\n", ans );
		can_start.clear();
	}
	return 0;
}

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

using namespace std;

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

int main() {
    while (1) {
        int dp[17][15] = { 0 };
        int field[15][15] = { 0 };
        int h, w;

        cin >> w >> h;
        if (w == 0) {
            break;
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cin >> field[i][j];
            }
        }
        
        for (int j = 0; j < w; j++) {
            if (field[0][j] != 1) {
                dp[0][j] = 1;
            }
        }
        
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (dp[i][j] > 0) {
                    if (field[i][j] == 2) {
                        if (field[i + 2][j] != 1) {
                            dp[i + 2][j] += dp[i][j];
                        }
                        continue;
                    }
                    if (i == h - 1) {
                        dp[i + 1][j] = dp[i][j];
                        continue;
                    }
                    for (int k = 0; k < 3; k++) {
                        int nx = j + dx[k];
                        int ny = i + dy[k];
                        if (nx < 0 || nx >= w) {
                            continue;
                        }
                        if (field[ny][nx] == 0 || (field[ny][nx] == 2 && k == 1)) {
                            dp[ny][nx] += dp[i][j];
                        }
                    }
                }
            }
        }
        
        int ans = 0;
        for (int i = h; i <= h + 1; i++) {
            for (int j = 0; j < w; j++) {
                ans += dp[h][j];
            }
        }
        cout << ans << endl;
    }
    
    return 0;
}