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>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {1, 1, 1};
int dy[] = {-1, 0, 1};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int board[20][20], dp[30][30];
 
signed main() {
    int W, H;
    while(cin >> W >> H, W || H) {
        memset(board, 0, sizeof(board));
        for(int i=0; i<H; i++) {
            for(int j=0; j<W; j++) {
                cin >> board[i][j];
            }
        }

        memset(dp, 0, sizeof(dp));
        for(int i=0; i<W; i++) if(board[0][i] == 0) dp[0][i] = 1;

        for(int i=0; i<H - 1; i++) {
            for(int j=0; j<W; j++) {
                if(board[i][j] == 1) continue;
                for(int k=0; k<3; k++) {
                    if(board[i][j] == 2 and k != 1) continue;
                    int dbl = (board[i][j] == 2 ? 2 : 1);

                    int ni = i + dx[k] * dbl, nj = j + dy[k];
                    if(ni < 0 or nj < 0 or nj >= W) continue;
                    if(board[ni][nj] == 1) continue;
                    if(board[ni][nj] == 2 and k != 1) continue;
                    dp[ni][nj] += dp[i][j];
                }
            }
        }

        int ans = 0;
        for(int i=H-1; i<H+5; i++) {
            for(int j=0; j<W; j++) {
                ans += dp[i][j];
            }
        }

        cout << ans << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int field[16][15];
int dp[15][15];

int n, m;

bool isIn(int x, int y){
    return 0 <= x && x < n && 0 <= y && y < m;
}

int main(){
    while(cin >> n >> m, n+m){
        for(int i=0; i < n; i++) for(int j=0; j< m; j++){cin >> field[i][j]; dp[i][j] = 0;}
        for(int i=0; i < m; i++) dp[0][i] = 1;
        for(int i=0; i < n-1; i++){
            for(int j=0; j < m; j++){
                if(field[i][j] == 0){
                    for(int k=-1; k <= 1; k++){
                        if(isIn(i+1, j+k) && !(k != 0 && field[i+1][j+k] == 2)){
                            dp[i+1][j+k] += dp[i][j];
                        }
                    }
                }
                else if(field[i][j] == 1) dp[i][j] = 0;
                else if(field[i][j] == 2) dp[i+2][j] += dp[i][j];
            }
        }
        int count = 0;
        for(int i=0; i< m; i++) count += dp[n-1][i];
        cout << count << endl;
    }
}

C++: #include <iostream>

int main()
{
    int x, y;
    int dx[3] = {-1, 0, 1};
    
    while (std::cin >> x >> y, x, y) {
        int field[20][20] = {{0}}, dp[20][20] = {{0}};
        
        for (int i = 0; i < 20; ++i) {
            for (int j = 0; j < 20; ++j) {
                field[i][j] = 1;
            }
        }
        
        for (int i = 1; i <= y; ++i) {
            for (int j = 1; j <= x; ++j) {
                std::cin >> field[i][j];
            }
        }

        for (int i = 1; i <= x; ++i) {
            if (field[1][i] == 0) dp[1][i] = 1;
        }
        
        //calc
        int ans = 0;

        for (int i = 1; i <= y; ++i) {
            for (int j = 1; j <= x; ++j) {
                
                switch (field[i][j]) {
                    case 0:
                        for (int k = 0; k < 3; ++k) {
                            int px = j + dx[k], py = i + 1;
                            
                            if ((field[py][px] == 2 && k == 1) || field[py][px] == 0) {
                                dp[py][px] += dp[i][j];
                            }
                        }
                        break;
                    case 2:
                        //y-1
                        if (i == y -1) ans += dp[i][j];
                        if (dp[i + 2][j] != 1) dp[i + 2][j] += dp[i][j];
                        break;
                    default:
                        break;
                }
            }
        }

        for (int i = 1; i <= x; ++i) {
            ans += dp[y][i];
        }

        std::cout << ans << std::endl;
    }

    return 0;
}