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>

#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<LL>
#define VVL vector<vector<LL>>
#define VVVL vector<vector<vector<LL>>>
#define VB vector<bool>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> void print(T x) { std::cout << x << std::endl; }

const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, -1, 0, 1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）

using namespace std;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    while (true) {
        int X, Y;
        cin >> X >> Y;
        if (X == 0 and Y == 0) { break; }

        VVI field(Y, VI(X, 0));
        FOR(y, 0, Y) {
            FOR(x, 0, X) {
                int c;
                cin >> c;
                field[y][x] = c;
            }
        }

        VVI dp(Y, VI(X, 0));
        FOR(x, 0, X) {
            dp[0][x] = (field[0][x] == 0 ? 1 : 0);
        }

        FOR(y, 0, Y - 1) {
            FOR(x, 0, X) {
                // 移動可能なマス
                if (field[y][x] == 0) {
                    if (0 <= x - 1 and field[y + 1][x - 1] == 0) {
                        dp[y + 1][x - 1] += dp[y][x];
                    }
                    if (field[y + 1][x] != 1) {
                        dp[y + 1][x] += dp[y][x];
                    }
                    if (x + 1 < X and field[y + 1][x + 1] == 0) {
                        dp[y + 1][x + 1] += dp[y][x];
                    }
                // ジャンプ台
                } else if (field[y][x] == 2) {
                    if (y + 2 >= Y) {
                        dp[Y -1][x] += dp[y][x];
                    }
                    else if (y + 2 < Y and field[y + 2][x] != 1) {
                        dp[y + 2][x] += dp[y][x];
                    }
                }
            }
        }
        print(SUM(dp[Y - 1]));
    }

    return 0;
}

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

#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)

int x, y, c[16][16], dp[30][30];
const int dx[3] = {-1, 0, 1};

void solve() {
  memset(dp, 0, sizeof dp);
  
  rep(i,y) rep(j,x) cin>>c[i][j];
  
  rep(i,x) if (c[0][i] == 0) dp[0][i] = 1;
  
  rep(i,y) rep(j,x) {
    if (c[i][j] == 1) {
      continue;
    } else if (c[i][j] == 0) {
      rep(z,3) {
        int ti = i + 1, tj = j + dx[z];
        if (ti < 0 || tj < 0 || ti >= y || tj >= x) continue;
        if (c[ti][tj] == 1) continue;
        if (c[ti][tj] == 2 && tj != j) continue;
        dp[ti][tj] += dp[i][j];
      }
    } else if (c[i][j] == 2) {
      dp[i+2][j] = dp[i][j];
    }
  }
  /*
  rep(i,y+1) {
    rep(j,x) printf("%8d",dp[i][j]);
    cout<<endl;
  }*/
  
  int res = 0;
  REP(i,y-1,y+1) rep(j,x) res += dp[i][j];
  cout<<res<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>x>>y, x||y) {
    solve();
  }
  return 0;
}

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

using namespace std;

#define MAX 20

int W,H;
int arr[MAX][MAX];
int dp[MAX][MAX];
const int dx[] = {-1,0,1};
const int dy[] = {1,1,1};

bool inField(int y,int x){
  return 0 <= y && y < H && 0 <= x && x < W;
}

int solve(int y,int x){
  if(y == H-1){
    if(arr[y][x] == 0 || arr[y][x] == 2){
      return 1;
    }else{
      return 0;
    }
  }
  if(dp[y][x] != -1) return dp[y][x];

  int res = 0;
  if(arr[y][x] != 2){
    for(int i = 0 ; i < 3 ; i++){
      int nx = x + dx[i];
      int ny = y + dy[i];
      if(!inField(ny,nx)) continue;
      if(arr[ny][nx] == 1) continue;
      if(arr[ny][nx] == 0){
        res += solve(ny,nx);
      }else{
        if(x == nx){
          res += solve(ny,nx);
        }
      }
    }
  }else{
    int nx = x, ny = y + 2;
    if(!inField(ny,nx)) return 1;
    res += solve(ny,nx);
  }
  return dp[y][x] = res;
}

int main(){
  while(cin >> W >> H, (W | H)){
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
        cin >> arr[i][j];
        dp[i][j] = -1;
      }
    }
    int res = 0;
    for(int i = 0 ; i < W ; i++){
      if(arr[0][i] == 0){
        res += solve(0,i);
      }
    }
    cout << res << endl;
  }

  return 0;
}

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

const int MAX_SIZE = 15;
char field[MAX_SIZE+1][MAX_SIZE+3];
int dp[MAX_SIZE+1][MAX_SIZE+3];
int w, h;

bool judge(int i, int j){
	if(j > 0 && j <= w && field[j][i] == '0')
		return true;
	return false;
}

int main(){
	while(cin >> w >> h){
		if(w == 0 && h == 0) break;
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++)
				cin >> field[j][i];
		}
		int pattern = 0;
		for(int i = 0; i < MAX_SIZE+1; i++){
			for(int j = 0; j < MAX_SIZE+3; j++){
				dp[i][j] = 0;
			}
		}
		for(int i = 1; i <= w; i++){
			dp[i][1] = 1;
		}
		for(int i = 1; i <= h; i++){
			for(int j = 1; j <= w; j++){
				if(field[j][i] == '2')
					dp[j][i+2] += dp[j][i];
				if(field[j][i] == '0'){
					dp[j][i+1] += dp[j][i];
					if(judge(i+1, j-1)) dp[j-1][i+1] += dp[j][i];
					if(judge(i+1, j+1)) dp[j+1][i+1] += dp[j][i];
				}
			}
		}
		int count = 0;
		for(int i = h+1; i <= h+2; i++){
			for(int j = 1; j <= w; j++){
				count += dp[j][i];
			}
		}
		cout << count << endl;
	}
	return 0;
}