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++: /* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
// clang-format off
/* }}} */

#include <bits/stdc++.h>
using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
// clang-format on
/* }}} */

int w, h;
int field[20][20];

ll dfs(int y, int x, int yy = -1, int xx = -1) {
  if (!inside(y, x, h + 1, w)) return 0;
  if (field[y][x] == 1) return 0;
  if (y >= h - 1) return 1;
  if (field[y][x] == 2 && x != xx) return 0;

  ll res;
  if (field[y][x] == 2) {
    res = dfs(y + 2, x, y, x);
  } else {
    res = dfs(y + 1, x, y, x) + dfs(y + 1, x + 1, y, x) + dfs(y + 1, x - 1, y, x);
  }

  return res;
}

signed main() {
  while (cin >> w >> h, w || h) {
    REP(i, h) REP(j, w) field[i][j] = in();
    ll ans = 0;
    REP(i, w) {
      ans += dfs(0, i);
    }
    print(ans);
  }

  return 0;
}

C++: #include<iostream>

using namespace std;

int map[16][16];
int x,y;
int ans;
int goalmap[16][16];
int s_map[16][16];

void serch(int nowx,int nowy)
{
	int next[3]={-1,0,1};
/*
	s_map[nowy][nowx]=1;
	
	getchar();
	
	system("cls");
	cout << "x:" << nowx << " y:" << nowy << endl;
	cout << "ans:" << ans << endl;
	for(int i=0;i<y;i++)
	{
		for(int j=0;j<x;j++)
		{
			cout << s_map[i][j] << " " ;
		}
		cout << endl;
	}
//*/
	if(goalmap[nowy][nowx]==-1)
	{
//		cout << "ツ湘。ツ害ツ閉ィツづ按つ、" << endl;
		s_map[nowy][nowx]=0;
		return ;
	}
	
	if(map[nowy][nowx]==2)
	{
//		cout << "jump" << endl;
		
		if(nowy+2>=y-1)
		{
//			cout << "goalup_jump" << endl;
			ans++;
			s_map[nowy][nowx]=0;
			return ;
		}
		
		serch(nowx,nowy+2);
	}
	else
	{
		for(int i=0;i<3;i++)
		{
			if(nowx+next[i]>=0 && nowx+next[i]<x)
			{
				if(map[nowy+1][nowx+next[i]]!=-1)
				{
					if(nowy+1>=y)
					{
//						cout << "goalup" << endl;
						ans++;
						s_map[nowy][nowx]=0;
						return ;
					}
//					cout << "next 2" << endl;
					if(map[nowy+1][nowx+next[i]]!=2)
						serch(nowx+next[i],nowy+1);
					else
					{
						if(nowx+next[i]==nowx)
							serch(nowx+next[i],nowy+1);
					}
				}
			}
		}
	}
	s_map[nowy][nowx]=0;
	return ;
}

int main()
{
	int i,j;
	
	for(;;)
	{
		cin >> x >> y ;
		if(x==0 && y==0)
			break;
		
		for(i=0;i<y;i++)
		{
			for(j=0;j<x;j++)
			{
				cin >> map[i][j] ;
			}
		}
		
		ans=0;
		
		for(i=0;i<y;i++)
			for(j=0;j<x;j++)
			{
				if(map[i][j]==1)
					goalmap[i][j]=-1;
				else
					goalmap[i][j]=0;
				s_map[i][j]=0;
			}
		
		for(i=0;i<x;i++)
		{
			serch(i,0);
		}
		
/*
		for(i=0;i<x;i++)
		{
			cout << goalmap[0][i] << endl;
			if(goalmap[0][i]!=-1)
				ans+=goalmap[0][i];
		}
		

		for(i=0;i<y;i++)
		{
			for(j=0;j<x;j++)
			{
				cout << goalmap[i][j] << " " ;
			}
			cout << endl;
		}
//*/
		
		cout << ans << endl;
	}
	
}