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 <string>
#include <vector>
using namespace std;

int main() {
    int X, Y;
    while (cin >> X >> Y, (X || Y)) {
        vector<vector<int>> sketch(Y, vector<int>(X, 0));
        for (int i=0; i<Y; ++i) {
            for (int j=0; j<X; ++j) {
                cin >> sketch[i][j];
            }
        }
        int dp[15][15] = {};
        int pattern = 0;
        for (int i=0; i<Y; ++i) {
            for (int j=0; j<X; ++j) {
                if (i == 0 && sketch[i][j] == 0) {
                    dp[i][j] = 1;
                }
                if (sketch[i][j] == 0) {
                    if (Y <= i+1) {
                        pattern += dp[i][j];
                        continue;
                    }
                    if (0 <= j-1 && sketch[i+1][j-1] == 0) {
                        dp[i+1][j-1] += dp[i][j];
                    }
                    if (sketch[i+1][j] == 0 || sketch[i+1][j] == 2) {
                        dp[i+1][j] += dp[i][j];
                    }
                    if (j+1 < X && sketch[i+1][j+1] == 0) {
                        dp[i+1][j+1] += dp[i][j];
                    }
                } else if (sketch[i][j] == 2) {
                    if (Y <= i+2) {
                        pattern += dp[i][j];
                        continue;
                    }
                    if (sketch[i+2][j] == 0 || sketch[i+2][j] == 2) {
                        dp[i+2][j] += dp[i][j];
                    }
                }
            }
        }
        cout << pattern << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int x,y,a[17][17],s,i,j;
void dfs(int y1,int x1){
  if(x1<1||x1>x)return;
  if(y1>=y){s++;return;}
  if(a[y1][x1]==2)dfs(y1+2,x1);
  else {if(a[y1+1][x1]!=1)dfs(y1+1,x1);
  if(a[y1+1][x1+1]==0)dfs(y1+1,x1+1);
  if(a[y1+1][x1-1]==0)dfs(y1+1,x1-1);}
  return;
}
int main(){
  while(cin>>x>>y,x){
    for(s=0,i=0;i<17;i++)for(j=0;j<17;j++)a[i][j]=0;    
    for(s=0,i=1;i<=y;i++)for(j=1;j<=x;j++)cin>>a[i][j];
    for(i=1;i<=x;i++){if(a[1][i]!=1)dfs(1,i);}
    cout<<s<<endl;
  }
}

C++: /*
 * src.cpp
 *
 *  Created on: 2016/08/01
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

const int MAX_X=15,MAX_Y=15;

int X,Y;
int c[MAX_Y][MAX_X];

int memo[MAX_Y][MAX_X];

int dfs(int x,int y){
	if (y<Y && c[y][x]==1){
		return 0;
	}
	if (y>=Y-1){
		return 1;
	}
	if (memo[y][x]!=-1){
		return memo[y][x];
	}
	if (c[y][x]==2){
		return dfs(x,y+2);
	}
	int res=0;
	if (x>0 && c[y+1][x-1]==0){
		res+=dfs(x-1,y+1);
	}
	if (x<X-1 && c[y+1][x+1]==0){
		res+=dfs(x+1,y+1);
	}
	res+=dfs(x,y+1);
	return memo[y][x]=res;
}

int main(){
	do{
		scanf("%d %d",&X,&Y);
		if (X || Y){
			REP(i,Y){
				REP(j,X){
					scanf("%d",&c[i][j]);
				}
			}
			memset(memo,-1,sizeof(memo));
			int ans=0;
			REP(i,X){
				ans+=dfs(i,0);
			}
			printf("%d\n",ans);
		}
	}while (X || Y);
	return 0;
}

C++: #include<iostream>
using namespace std;
typedef long long ll;
int H,W;
int t[20][20];
ll u[20][20],ans;

bool inField(int x){
  if(1<=x&&x<=W)return true;
  return false;
}

int main(){
  while(cin>>W>>H){
    if(H==0&&W==0)break;
    for(int i=0;i<20;i++)for(int j=0;j<20;j++)u[i][j]=0;
    for(int i=1;i<=H;i++)for(int j=1;j<=W;j++)cin>>t[i][j];

    for(int i=0;i<20;i++)u[1][i]=(t[1][i]==1?0:1);

    for(int i=1;i<H;i++){
      for(int j=1;j<=W;j++){
	if(t[i][j]==1)u[i][j]=0;
	if(u[i][j]==0)continue;
	if(t[i][j]==2){
	  u[i+2][j]+=u[i][j];
	  continue;
	}
	for(int k=-1;k<=1;k++){
	  if(!inField(j+k))continue;
	  if(t[i+1][j+k]==0){
	    u[i+1][j+k]+=u[i][j];
	  }else if(t[i+1][j+k]==2&&k==0){
	    u[i+1][j+k]+=u[i][j];
	  }
	}
      }//j
    }//i
    ans=0;
    for(int i=H;i<20;i++){
      for(int j=1;j<=W;j++){
	ans+=u[i][j];
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int X, Y;
	while(cin >> X >> Y && X)
	{
		vector<vint> field(Y, vint(X, 0)), dp(Y, vint(X, 0));
		rep(y, Y) rep(x, X)
			cin >> field[y][x];

		rep(x, X)
			dp[0][x] = !field[0][x];

		REP(y, 1, Y) rep(x, X)
		{
			if(field[y][x] == 1) continue;

			if(1 < y && field[y - 2][x] == 2) dp[y][x] = dp[y - 2][x];

			if(field[y][x] == 0)
			{
				int dx[] = {-1, 0, 1};
				rep(i, 3)
				{
					int nx = x + dx[i];
					if(0 <= nx && nx < X && field[y - 1][nx] != 2)
						dp[y][x] += dp[y - 1][nx];
				}
			}
			else
			{
				dp[y][x] += dp[y - 1][x];
			}
		}

		int res = accumulate(ALL(dp[Y-1]), 0);
		
		if(1 < Y)rep(x, X)
			res += field[Y-2][x] == 2 ? dp[Y-2][x] : 0;

		cout << res << endl;
	}
}