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 <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
using namespace std;
typedef pair<int,int> P;
const int INF = ~(1<<31) / 2;

int field[15][15];
int dp[15][15];

int main(){
    while(1){
        int X,Y;
        scanf("%d %d",&X,&Y);
        if(X==0)break;
        for(int i=0;i<Y;i++){
            for(int j=0;j<X;j++){
                scanf("%d",&field[i][j]);
            }
        }

        for(int j=0;j<X;j++){
            dp[Y-1][j] = field[Y-1][j] == 1 ? 0 : 1;
        }

        for(int i=Y-2;i>=0;i--){
            for(int j=0;j<X;j++){
                if(field[i][j]==1){
                    dp[i][j] = 0;
                }else if(field[i][j]==2){
                    dp[i][j] = i+2<Y ? dp[i+2][j] : 1;
                }else{
                    dp[i][j] = 0;
                    if(j-1>=0 && field[i+1][j-1]==0){
                        dp[i][j] += dp[i+1][j-1];
                    }
                    if(j+1<X && field[i+1][j+1]==0){
                        dp[i][j] += dp[i+1][j+1];
                    }
                    if(field[i+1][j]!=1){
                        dp[i][j] += dp[i+1][j];
                    }
                }
            }
        }
        int ans = 0;
        for(int j=0;j<X;j++){
            ans += dp[0][j];
        }
        printf("%d\n",ans);
    }

    return 0;
}
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
using namespace std;
typedef pair<int,int> P;
const int INF = ~(1<<31) / 2;

int field[15][15];
int dp[15][15];

int main(){
    while(1){
        int X,Y;
        scanf("%d %d",&X,&Y);
        if(X==0)break;
        for(int i=0;i<Y;i++){
            for(int j=0;j<X;j++){
                scanf("%d",&field[i][j]);
            }
        }

        for(int j=0;j<X;j++){
            dp[Y-1][j] = field[Y-1][j] == 1 ? 0 : 1;
        }

        for(int i=Y-2;i>=0;i--){
            for(int j=0;j<X;j++){
                if(field[i][j]==1){
                    dp[i][j] = 0;
                }else if(field[i][j]==2){
                    dp[i][j] = i+2<Y ? dp[i+2][j] : 1;
                }else{
                    dp[i][j] = 0;
                    if(j-1>=0 && field[i+1][j-1]==0){
                        dp[i][j] += dp[i+1][j-1];
                    }
                    if(j+1<X && field[i+1][j+1]==0){
                        dp[i][j] += dp[i+1][j+1];
                    }
                    if(field[i+1][j]!=1){
                        dp[i][j] += dp[i+1][j];
                    }
                }
            }
        }
        int ans = 0;
        for(int j=0;j<X;j++){
            ans += dp[0][j];
        }
        printf("%d\n",ans);
    }

    return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int n, m;
	while (true){
		cin >> n >> m;
		if (n == 0 && m == 0){
			break;
		}
		int map[100][100] = { 0 };
		int dp[100][100] = { 0 };
		for (int i = 0; i < m; i++){
			for (int i2 = 0; i2 < n; i2++){
				cin >> map[i][i2];
			}
		}
		for (int i = 0; i < n; i++){
			if (map[0][i] == 0){
				dp[0][i] = 1;
			}
		}
		for (int i = 0; i < m; i++){
			for (int i2 = 0; i2 < n; i2++){
				if (map[i][i2] == 0){
					if ((map[i + 1][i2] == 0 || map[i + 1][i2] == 2)){
						dp[i + 1][i2] += dp[i][i2];
					}
					if (i2+1<n &&map[i + 1][i2 + 1] == 0&&i<m-1){
						dp[i + 1][i2 + 1] += dp[i][i2];
					}
					if (i2 - 1 >= 0 && map[i + 1][i2 - 1] == 0&&i<m - 1){
						dp[i + 1][i2 - 1] += dp[i][i2];
					}
				}
				if (map[i][i2] == 2){
					if (map[i + 2][i2] == 0 || map[i + 2][i2] == 2){
						dp[i + 2][i2] += dp[i][i2];
					}
				}
			}
		}
		int ans = 0;
		for (int i = 0; i < n; i++){
			ans += dp[m][i];
			ans += dp[m + 1][i];
		}
		cout << ans << endl;
	}
}

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

using namespace std;

int width,height;
vector< vector<int> > m;
vector< vector<int> > mm;

int Get(int y,int x);

int main(){
	int self;
	while(scanf("%d",&width) != EOF){
		scanf("%d",&height);
		if(width == 0 && height == 0){
			break;
		}
		//printf("%d:%d\n",width,height);
		m.clear();
		mm.clear();
		
		for(int j=0;j<height;j++){
			vector<int> v;
			for(int i=0;i<width;i++){
				scanf("%d",&self);
				v.push_back(self);
			}
			m.push_back(v);
		}
		for(int j=0;j<=height;j++){
			vector<int> vv;
			for(int i=0;i<width;i++){
				vv.push_back(0);
			}
			mm.push_back(vv);
		}
		
		/*
		for(int j=0;j<height;j++){
			for(int i=0;i<width;i++){
				printf("%d ",m[j][i]);
			}
			printf("\n");
		}
		*/
		
		int xx,yy;

		for(int y = 0; y <= height; y ++){
			for(int x = 0; x < width; x ++){
				xx = x;
				yy = y - 1;
				if(y == height){
					mm[y][x] += mm[yy][xx];
					yy = y - 2;
					if(yy >= 0){
						if(m[yy][xx] == 2){
							mm[y][x] += mm[yy][xx];
						}
					}
				}else{
					switch(m[y][x]){
						case 0: //ó
							if(yy == -1){
								mm[y][x] = 1;
							}else{
								mm[y][x] += Get(yy,xx-1) + Get(yy,xx) + Get(yy,xx+1);
								yy = y - 2;
								if(yy >= 0){
									if(m[yy][xx] == 2){
										mm[y][x] += mm[yy][xx];
									}
								}
							}
							break;
						case 1: //áQ¨
							break;
						case 2: //Wvä
							mm[y][x] += Get(yy,xx);
							yy = y - 2;
							if(yy >= 0){
								if(m[yy][xx] == 2){
									mm[y][x] += mm[yy][xx];
								}
							}
							break;
					}
				}
			}
			
		}
		
		/*
		for(int j=0;j<=height;j++){
			for(int i=0;i<width;i++){
				printf("%d	",mm[j][i]);
			}
			printf("\n");
		}
		*/
		int ans = 0;
		for(int i=0;i<width;i++){
			ans += mm[height][i];
		}
		printf("%d\n",ans);
	}
	return 0;
}

int Get(int y,int x){
	if(y >= height){ return 0; }
	if(x >= width){ return 0; }
	if(y < 0){ return 0; }
	if(x < 0){ return 0; }
	if(m[y][x] == 2){ return 0; }
	return mm[y][x];
}