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 <cstdio>

using namespace std;

int X, Y;
int field[15 + 2][15 + 2];
int dp[15 + 2][15 + 2];

void solve() {
	for (int i = 1; i <= X; i++) {
		if (field[0][i] == 0) {
			dp[0][i] = 1;
		}
	}
	for (int y = 0; y < Y - 1; y++) {
		for (int x = 1; x <= X; x++) {
			if (field[y][x] == 2) {
				if (field[y + 2][x] != 1) {
					dp[y + 2][x] += dp[y][x];
				}
			} else if (field[y][x] == 0) {
				if (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 (field[y + 1][x + 1] == 0) {
					dp[y + 1][x + 1] += dp[y][x];
				}
			}
		}
	}
	int sum = 0;
	for (int y = Y - 1; y <= Y; y++) {
		for (int x = 1; x <= X; x++) {
			sum += dp[y][x];
		}
	}
	printf("%d\n", sum);
}

int main() {
	while (scanf("%d %d ", &X, &Y) == 2) {
		if (X == 0 && Y == 0) {return 0;}

		fill(dp[0], &dp[15 + 2 - 1][15 + 2], 0);
		fill(field[0], &field[15 + 2 - 1][15 + 2], 1);
		for (int y = Y; y <= Y + 1; y++) {
			for (int x = 1; x <= X; x++) {
				field[y][x] = 2;
			}
		}
		for (int i = 0; i < Y; i++) {
			for (int j = 1; j <= X; j++) {
				scanf("%d ", &field[i][j]);
			}
		}
		/*
		for (int i = 0; i < Y + 2; i++) {
			for (int j = 0; j < X + 2; j++) {
				printf("%d ", field[i][j]);
			}
			printf("\n");
		}
		*/
		solve();
		/*
		for (int i = 0; i < Y + 2; i++) {
			for (int j = 0; j < X + 2; j++) {
				printf("%2d ", dp[i][j]);
			}
			printf("\n");
		}
		*/
	}
}

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

using namespace std;

int dp[32][15]; // dp[Y][X]
int field[32][16];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    while(true) {
        int X, Y;
        cin >> X >> Y;
        if(!X && !Y) break;

        // Initialize
        for(int i = 0; i < Y; ++i) {
            for(int j = 0; j < X; ++j) {
                cin >> field[i][j];
                dp[i][j] = 0;
            }
        }
        for(int j = 0; j < X; ++j) {
            dp[Y][j] = 0;
        }

        // Base case
        for(int i = 0; i < X; ++i) {
            if(field[0][i] == 0) dp[0][i] = 1;
            else dp[0][i] = 0;
        }
        for(int i = 0; i < Y-1; ++i) {
            for(int j = 0; j < X; ++j) {
                if(field[i][j] == 0) {
                    // Move
                    for(int dx = -1; dx <= 1; ++dx) {
                        const int nx = j + dx;
                        if(nx < 0 || nx >= X) continue;
                        if(field[i+1][nx] == 0) dp[i+1][nx] += dp[i][j];
                        else if(dx == 0 && field[i+1][nx] == 2) dp[i+1][nx] += dp[i][j];
                    }
                } else if(field[i][j] == 2) {
                    // Jump
                    if(field[i+2][j] != 1) dp[i+2][j] += dp[i][j];
                }
            }
        }
        int ans = 0;
        for(int i = 0; i < 2; ++i) {
            for(int j = 0; j < X; ++j) {
                ans += dp[Y-1+i][j];
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

int field[15][15];
int dp[15][15];
int x, y;

int calc_pattern()
{
	int pattern = 0;

	loop(i, 0, x)
	{
		if( field[0][i] != 1 )
		{
			dp[0][i] = 1;
		}
		else
		{
			dp[0][i] = 0;
		}
	}

	loop(i, 0, y - 1)
	{
		loop(j, 0, x)
		{
			if( field[i][j] == 0 )
			{
				if( j >= 1 && j < x - 1 )
				{
					dp[i + 1][j - 1] += field[i + 1][j - 1] == 0 ? dp[i][j] : 0;
					dp[i + 1][j    ] += field[i + 1][j    ] != 1 ? dp[i][j] : 0;
					dp[i + 1][j + 1] += field[i + 1][j + 1] == 0 ? dp[i][j] : 0;
				}
				else if( j == 0 )
				{
					dp[i + 1][j    ] += field[i + 1][j    ] != 1 ? dp[i][j] : 0;
					dp[i + 1][j + 1] += field[i + 1][j + 1] == 0 ? dp[i][j] : 0;
				}
				else if( j == x - 1 )
				{
					dp[i + 1][j - 1] += field[i + 1][j - 1] == 0 ? dp[i][j] : 0;
					dp[i + 1][j    ] += field[i + 1][j    ] != 1 ? dp[i][j] : 0;
				}
			}
			else if( field[i][j] == 1 )
			{
				dp[i][j] = 0;
			}
			else if( field[i][j] == 2 )
			{
				if( i != y - 2 )
				{
					dp[i + 2][j] += field[i + 2][j] != 1 ? dp[i][j] : 0;
				}
				else
				{
					pattern += dp[i][j];
				}
			}
		}
	}
	loop(i, 0, x)
	{
		pattern += dp[y - 1][i];
	}

	return pattern;
}

int main()
{
	int pattern;
	while( 1 )
	{
		scanf("%d%d", &x, &y);
		if( x == 0 && y == 0 )break;
		
		loop(i, 0, 15)
		{
			loop(j, 0, 15)
			{
				field[i][j] = 0;
				dp[i][j] = 0;
			}
		}
		loop(i, 0, y)
		{
			loop(j, 0, x)
			{
				field[i][j] = in();
			}
		}

		pattern = calc_pattern();
		printf("%d\n", pattern);
	}
	return (0);
}

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

using namespace std;

#define MAX 25

int main()
{
    int H, W;
    while (cin >> W >> H, W) {
        vector<vector<int>> a(H, vector<int>(W));
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cin >> a[i][j];
            }
        }
        int dp[MAX][MAX] = {{}};
        for (int i = 0; i < W; i++) {
            dp[0][i] = (a[0][i] == 0);
        }

        for (int i = 0; i < H - 1; i++) {
            for (int j = 0; j < W; j++) {
                if (dp[i][j] <= 0 || a[i][j] == 1) continue;
                if (a[i][j] == 2) {
                    int ni = min(i + 2, H - 1);
                    if (i + 2 < H && a[i+2][j] == 1) continue;
                    dp[ni][j] += dp[i][j];
                } else {
                    for (int k = -1; k <= 1; k++) {
                        int ni = i + 1;
                        int nj = j + k;
                        if (nj < 0 || nj >= W || ni >= H) continue;
                        if (a[ni][nj] == 1) continue;
                        if (a[ni][nj] == 2 && j != nj) continue;
                        dp[ni][nj] += dp[i][j];
                    }
                }
            }
        }
        int res = 0;
        for (int i = 0; i < W; i++) {
            res += dp[H-1][i];
        }
        cout << res << endl;
    }
    return 0;
}