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 <vector>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <complex>

#define EPS	1.0e-10
#define rep(idx, max)	for(int idx = 0, idx##Max = max; idx < idx##Max; idx ++)
#define rrep(idx, min, max)	for(int idx = min, idx##Max = max; idx < idx##Max; idx ++)
#define erep(idx, min, max)	for(int idx = min, idx##Max = max; idx <= idx##Max; idx ++)

#define rev(idx, max)	for(int idx = max - 1; idx >= 0; idx --)

typedef unsigned int UINT;
typedef std::vector<int>	VEC;
typedef struct _POINT
{
	int x, y;
	_POINT(){}
	_POINT(int _x, int _y): x(_x), y(_y){}
} POINT;

enum
{
	JMP = 2,
	BLK = 1,
	FLOOR = 0, 
};

#define MAX_N	32

int g_width, g_height;
int g_map[MAX_N][MAX_N];
int g_cache[MAX_N][MAX_N];

void	PrintCache()
{
	rep(y, g_height + 2)
	{	rep(x, g_width + 2)	{	::printf("%2d|", g_cache[y][x]);	}	::puts("");	}
	::puts("");
}

int	Solve()
{
	erep(y, 1, g_height) erep(x, 1, g_width)
	{
	//	::PrintCache();
		switch (g_map[y][x])
		{
		case BLK:	break;
		case FLOOR:
			erep(dx, -1, +1)
			{
				int &fieldn = g_map[y + 1][x + dx];
				if (fieldn == BLK || (fieldn == JMP && dx != 0)) { continue; }
				g_cache[y + 1][x + dx] += g_cache[y][x];
			}
			break;
		case JMP:
			if (g_map[y + 2][x] != BLK) { g_cache[y + 2][x] += g_cache[y][x]; }
			break;
		}
	}

	int count = 0;
	erep(x, 1, g_width)
	{
		count += g_cache[g_height + 1][x] + g_cache[g_height][x];
	}
	return(count);
}

void	PrintMap()
{
	rep(y, MAX_N)
	{	rep(x, MAX_N)	{	::printf("%2d|", g_map[y][x]);	}	::puts("");	}
	::puts("");
}

void	InitMap()
{
//	::memset(g_map, BLK, sizeof(g_map));
	rep(y, MAX_N) rep(x, MAX_N) { g_map[y][x] = BLK; }
	erep(y, 1, g_height) erep(x, 1, g_width)	{	std::cin >> g_map[y][x];	}
}

void	InitCache()
{
	::memset(g_cache, 0, sizeof(g_cache));
//	rep(y, MAX_N) rep(x, MAX_N) { g_cache[y][x] = -1; }
	erep(x, 1, g_width) { g_cache[1][x] = 1; }
}

int main(int nArgs, char **lplpszArgs)
{
	while (std::cin >> g_width >> g_height, g_width)
	{
		InitMap();
		InitCache();
	//	PrintMap();
		::printf("%d\n", ::Solve());
	}
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int w,h;
  while(cin>>w>>h, w+h){
    int f[h][w];
    long long ans[h+2][w];
    memset(ans, 0, sizeof(ans));
    REP(i,h) REP(j,w) cin>>f[i][j];
    REP(i,w) if(f[0][i] == 0) ans[0][i] = 1;
    REP(i,h) REP(j,w){
      if(ans[i][j] != 0){
        int y = i + (f[i][j]==2?2:1);
        REP(k,3){
          if((f[i][j]==2 || i == h - 1) && k!=1) continue;
          int x = j + k - 1;
          if(x < 0 || x >= w) continue;
          if(y >= h || f[y][x] == 0)
            ans[y][x] += ans[i][j];
          else if(k == 1 && f[y][x] == 2)
            ans[y][x] += ans[i][j];
        }
      }
    }
    //REP(i,h+2){REP(j,w)printf("%lld ",ans[i][j]); puts("");}
    long long sum = 0;
    REP(i,2) REP(j,w) sum += ans[h+i][j];
    cout << sum << endl;
  }
  return 0;
}

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

int main(){

  int x,y;
  int a[100][100];
  int w[100][100];

  while(true){
    cin >> x >> y;
    if(!x && !y) break;

    memset(w,0,sizeof(w));
    int ans = 0;

    for(int i=0;i<y;i++){
      for(int j=0;j<x;j++) cin >> a[i][j];
    }

    for(int i=0;i<x;i++){
      if(a[0][i] == 0) w[0][i] = 1;
    }

    for(int i=1;i<y;i++){
      for(int j=0;j<x;j++){

	if(a[i][j] == 1) w[i][j] += 0;

	else if(a[i][j] == 2 && a[i+2][j] != 1)  w[i+2][j] += w[i-1][j];

	else if(a[i][j] == 0){
	  if(i-3 > 0 && (a[i-3][j+1] == 2 || a[i-3][j-1] == 2)) w[i][j] += w[i-1][j];
	  else if(j-1 < 0) w[i][j] += w[i-1][j] + w[i-1][j+1];
	  else if(j+1 == y) w[i][j] += w[i-1][j-1] + w[i-1][j];
	  else w[i][j] += w[i-1][j-1] + w[i-1][j] + w[i-1][j+1];
	}


      }

    }

    for(int i=0;i<x;i++) ans += w[y-1][i] + w[y][i] + w[y+1][i];
    cout << ans << endl;
  }
}

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' && j <= h)
		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++){
			if(field[i][1] == '0')
				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];
				}
				if(field[j][i] == '1')
					dp[j][i] = 0;
			}
		}
		int count = 0;
		for(int i = h; i <= h+1; i++){
			for(int j = 1; j <= w; j++){
				count += dp[j][i];
			}
		}
		cout << count << endl;
	}
	return 0;
}