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>
using namespace std;


int main() {
    int field[16][17], pattern[17][17];
    int X, Y, i, j, k;

    while ((cin >> X >> Y) && X) {
        for (i = 1; i <= Y; i++) {
            field[i][0] = field[i][X+1] = 0;
            for (j = 1; j <= X; j++) {
                cin >> field[i][j];
            }
        }

        for (i = 2; i <= Y+1; i++) {
            for (j = 0; j <= X + 1; j++) {
                pattern[i][j] = 0;
            }
        }
        for (j = 1; j <= X; j++) {
            pattern[1][j] = field[1][j] == 0;
        }

        for (i = 1; i < Y; i++) {
            for (j = 1; j <= X; j++) {
                switch (field[i][j]) {
                    case 0:
                    for (k = -1; k <= 1; k++) {
                        switch (field[i+1][j+k]) {
                            case 0:
                            pattern[i+1][j+k] += pattern[i][j];
                            break;
                            case 2:
                            if (k == 0) {
                                pattern[i+1][j+k] += pattern[i][j];
                            }
                            break;
                            default: break;
                        }
                    }
                    break;
                    case 2:
                    if (field[i+2][j] != 1) {
                        pattern[i+2][j] += pattern[i][j];
                    }
                    break;
                    default: break;
                }
            }
        }
        /* 
        for (i = 1; i <= Y; i++) {
            for (j = 1; j <= X; j++) {
                cout << " " << pattern[i][j];
            }
            cout << endl;
        }
        cout << endl;
        */
        int sum = 0;
        for (i = Y; i <= Y + 1; i++) {
            for (j = 1; j <= X; j++) {
                sum += pattern[i][j];
            }
        }
        cout << sum << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int w,h;cin>>w>>h,w|h;){
		vvi field(h+1,vi(w));
		rep(i,h) rep(j,w)
			cin>>field[i][j];
		
		vvi dp(h+1,vi(w));
		rep(i,w)
			if(field[0][i]!=1)
				dp[0][i]=1;
		rep(i,h-1){
			rep(j,w){
				if(field[i][j]==1){
					dp[i][j]=0;
					continue;
				}
				if(field[i][j]==2 && field[i+2][j]!=1){
					dp[i+2][j]+=dp[i][j];
					continue;
				}
				if(field[i+1][j]==2)
					dp[i+1][j]+=dp[i][j];
				for(int k=-1;k<=1;k++)
					if(0<=j+k && j+k<w && field[i+1][j+k]==0)
						dp[i+1][j+k]+=dp[i][j];
			}
		}
		ll res=0;
		repi(i,h-1,h+1) rep(j,w)
			if(field[i][j]!='1')
				res+=dp[i][j];
		cout<<res<<endl;
	}
	
	return 0;
}

C++: #include<stdio.h>

int dx[3] = {-1, 0, 1};
int dy[3] = {1, 1, 1};

int main(void)
{
	int **map, f1, f2, f3, **temp, x, y, sum, px, py;
	
	while(scanf("%d %d", &x, &y) && y > 0)
	{
		map = new int *[y];
		temp = new int *[y];
		sum = 0;

		//マップ土地&動的計画作成
		for(f1 = 0; f1 < y; f1++)
		{
			map[f1] = new int [x];
			temp[f1] = new int [x];
		}
		//マップ構成入力&初期化
		for(f1 = 0; f1 < y; f1++)
		{
			for(f2 = 0; f2 < x; f2++)
			{
				scanf("%d",&map[f1][f2]);
				temp[f1][f2] = 0;
			}
		}
		//最上のスタート地点設定
		for(f1 = 0; f1 < x; f1++)
		{
			if(map[0][f1] != 1)
			{
				temp[0][f1] = 1;
				sum++;
			}
		}
		//探索
		if(y >= 2)
		{
			sum = 0;
			for(f1 = 0; f1 < y - 1; f1++)
			{
				for(f2 = 0; f2 < x; f2++)
				{
					if(map[f1][f2] == 0 && temp[f1][f2] > 0)
					{
						for(f3 = 0; f3 < 3; f3++)
						{
							//移動
							px = f2 + dx[f3];
							py = f1 + dy[f3];
							//範囲内か
							if(px >= 0 && px < x)
							{
								//同じｘ座標からのジャンプ台
								if(f3 == 1 && py < y - 1){
									//ｙ軸2つ先へ
									while(py < y - 1 && map[py][px] == 2)
										py += 2;
								}
								//着地した場所がゴール地点のｙ座標と同じで障害物にぶつかってないか
								//ゴール地点のｙ座標を超えたか
								if(py > y - 1 || py == y - 1 && map[py][px] != 1)
									sum += temp[f1][f2];
								//超えてないが、障害物がない地点に着地したか
								else if(map[py][px] == 0)
									temp[py][px] += temp[f1][f2];
							}
						}
					}
				}
			}
		}
		//出力
		printf("%d\n",sum);
	}

	return 0;
}

C++: #include<iostream>

using namespace std;

int map[15][15];

int count[15][15];

int main () {

	while(true) {
		int w, h;
		cin >> w >> h;

		if ( w == 0 )
			break;
	
		for ( int i=0; i<h; i++ ) {
			for ( int j=0; j<w; j++ ) {
				cin >> map[i][j];
			}
		}

		for ( int i=1; i<h; i++ ) {
			for ( int j=0; j<w; j++ ) {
				count[i][j] = 0;
			}
		}
		
		for ( int i=0; i<w; i++ ) {
			if ( map[0][i] != 1 )
				count[0][i] = 1;
		}

		for ( int i=1; i<h; i++ ) {
			for ( int j=0; j<w; j++ ) {
				if ( map[i][j] != 1 ) {
					if ( map[i][j] != 2 ) {
						if ( j-1 >= 0 ) {
							if ( map[i-1][j-1] == 0 ) {
								count[i][j] += count[i-1][j-1];
							}
						}

						if ( j+1 < w ) {
							if ( map[i-1][j+1] == 0 ) {
								count[i][j] += count[i-1][j+1];
							}
						}
					}
					if ( map[i-1][j] == 0 ) {
						count[i][j] += count[i-1][j];
					}

					if ( i-2 >= 0 ) {
						if ( map[i-2][j] == 2 ) {
							count[i][j] += count[i-2][j];
						}
					}
				}

			}
		}

		
		for ( int i=0; i<h; i++ ) {
			for ( int j=0; j<w; j++ ) {
				cout << count[i][j] << "\t";
			}
			cout << endl;
		}
		cout << endl;
		
		int sum = 0;

		for ( int i=0; i<w; i++ ) {
			sum += count[h-1][i];
		}

		for ( int i=0; i<w; i++ ) {
			if ( map[h-2][i] == 2 )
				sum += count[h-2][i];
		}

		cout << sum << endl;
	}
}