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 <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int w, h;
        cin >> w >> h;
        if(w == 0)
            return 0;

        vector<vector<int> > grid(h+1, vector<int>(w+2, 0));
        for(int i=0; i<h+1; ++i)
            grid[i][0] = grid[i][w+1] = 1;
        for(int i=0; i<h; ++i){
            for(int j=1; j<=w; ++j){
                cin >> grid[i][j];
            }
        }

        vector<vector<int> > num(h+1, vector<int>(w+2, 0));
        for(int i=1; i<=w; ++i){
            if(grid[0][i] == 0)
                num[0][i] = 1;
        }

        for(int y=0; y<h-1; ++y){
            for(int x=1; x<=w; ++x){
                if(grid[y][x] == 2){
                    num[y+2][x] += num[y][x];
                }else{
                    for(int dx=-1; dx<=1; ++dx){
                        if(grid[y+1][x+dx] == 1 || (grid[y+1][x+dx] == 2 && dx != 0))
                            continue;
                        num[y+1][x+dx] += num[y][x];
                    }
                }
            }
        }

        int ret = accumulate(num[h-1].begin(), num[h-1].end(), 0);
        ret += accumulate(num[h].begin(), num[h].end(), 0);
        cout << ret << endl;
    }
}

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

int main() {
	int x, y;
	while (cin >> x >> y ,x,y) {
		vector<vector<int>> course(y + 2, vector<int>(x + 2, 0));
		for (int i = 1; i <= y; i++) {
			for (int j = 1; j <= x; j++) {
				cin >> course[i][j];
			}
		}

		vector<vector<int>> path(y + 2, vector<int>(x + 2, 0));
		//?????????????????????????????????1????????????
		for (int i = 1; i <= x; i++) {
			if (course[1][i] != 1) path[1][i] = 1;
		}

		for (int i = 1; i <= y; i++) {
			for (int j = 1; j <= x; j++) {
				//????????????????????´????????????????????´??????????????????????????????????????????
				//?????????????§????????????????????????´?????????????????????????????£????????°?????´????????????????????????
				if (course[i][j] == 0) {
					if (course[i + 1][j + 1] == 0) path[i + 1][j + 1] += path[i][j];
					if (course[i + 1][j] != 1) path[i + 1][j] += path[i][j];
					if (course[i + 1][j - 1] == 0) path[i + 1][j - 1] += path[i][j];
				}
				//?¬???????????????´???????????£????????°????????????????????????????????????
				//?????????????????£????????§??´??????????????´???????????????(?????£?????????????????????????????´???????????????)
				if (course[i][j] == 2) {
					if (i + 2 > y) path[y][j] += path[i][j];
					else path[i + 2][j] += path[i][j];
				}
				//???????????´???????????????????????????????????????
				if (course[i][j] == 1) {/*do anything*/ }
			}
		}

		cout << accumulate(path[y].begin() + 1, path[y].end() - 1, 0) << endl;

	}
	return 0;
}

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

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;

int w, h;
vvi field;
vvi memo;

int solve(int y, int x)
{
	if(memo[y][x] != -1)
		return memo[y][x];
	
	memo[y][x] = 0;
	if(field[y][x] == 1)
		return 0;
	if(y == 0)
		return memo[y][x] = 1;
	
	const int dx[] = {-1, 0, 1};
	rep(i, 3){
		int px = x + dx[i];
		if(px<0 || w<=px || field[y-1][px]!=0 || (field[y][x]==2 && dx[i]!=0))
			continue;
		memo[y][x] += solve(y-1, px);
	}
	
	if(y>=2 && field[y-2][x] == 2)
		memo[y][x] += solve(y-2, x);
	return memo[y][x];
}

int main()
{
	while(scanf("%d%d", &w, &h), w){
		field.assign(h, vi(w));
		memo.assign(h, vi(w, -1));
		rep(i, h) rep(j, w)
			scanf("%d", &field[i][j]);

		int sum = 0;
		rep(i, w){
			sum += solve(h-1, i);
			if(h>=2 && field[h-2][i] == 2)
				sum += solve(h-2, i);
		}
		printf("%d\n", sum);
	}
	return 0;
}

C++: #include<stdio.h>

int main(void){
	int X,Y;
	
	while(scanf("%d%d", &X, &Y) && X && Y){
		int masu[32][32]={0};
		int co[32][32]={0};
		int ans = 0;
		for(int i = 0; i < Y; i++){
			for(int j = 0; j < X; j++){
				scanf("%d", &masu[i][j]);
			}
		}
		
		for(int i = 0; i < X; i++){
			if(!masu[0][i])co[0][i] = 1;
		}
		
		for(int i = 0; i < Y-1; i++){
			for(int j = 0; j < X; j++){
				if(masu[i][j] == 0){
					if(masu[i+1][j] != 1)co[i+1][j] += co[i][j];
					if(masu[i+1][j+1] == 0)co[i+1][j+1] += co[i][j];
					if(masu[i+1][j-1] == 0 && j-1 > -1)co[i+1][j-1] += co[i][j];
				}else if(masu[i][j] != 1){
					co[i+2][j] += co[i][j];
				}
			}
		}
		
		for(int i = 0; i < X; i++){
			ans += co[Y-1][i];
		}
		for(int i = 0; i < X; i++){
			ans += co[Y][i];
		}
		printf("%d\n",ans);
	}
	return 0;
}

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


int main(){
	int map[20][20];
	int ans_map[20][20];
	int x,y;
	while(cin>>x>>y,(x!=0)&&(y!=0)){
		long int ans=0;
		for(int i=0;i<y;i++){
			for(int j=0;j<x;j++){
				cin>>map[i][j];
				ans_map[i][j]=0;
			}
		}
		for(int i=0;i<x;i++){
			ans_map[y][i]=0;
		}
		for(int i=0;i<x;i++){
			if(map[0][i]==0){
				ans_map[0][i]=1;
			}
		}
		for(int i=0;i+1<y;i++){
			for(int j=0;j<x;j++){
				if(map[i][j]==2){
					if(i+2<y){
						ans_map[i+2][j]+=ans_map[i][j];
					}else{
						ans_map[y][j]+=ans_map[i][j];
					}
					ans_map[i][j]=0;
				}else if(map[i][j]==1){
					ans_map[i][j]=0;
				}else{ 
					for(int k=-1;k<=1;k++){
						if((j+k<0)||(j+k>x-1)){
							continue;
						}else{
							if(map[i+1][j+k]==0){
								ans_map[i+1][j+k]+=ans_map[i][j];
							}else if((k==0)&&(map[i+1][j+k]==2)){
								ans_map[i+1][j+k]+=ans_map[i][j];
							}else{
							}
						}
					}
				}
			}
		}
		for(int i=0;i<x;i++){
			ans_map[y][i]+=ans_map[y-1][i];
		}
		for(int i=0;i<x;i++){
			ans+=ans_map[y][i];
		}
		cout<<ans<<endl;
		
	}
}