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<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;

struct Edge{int to,from,cost;};

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define mp make_pair
#define PUTLINE cout<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

int c[20][20];
int r[20][20];

int main() {
	int x,y;
	for(;;){
		cin>>x>>y;
		if(x==0&&y==0)break;
		memset(c,0,sizeof(c));
		memset(r,0,sizeof(r));
		rep(i,y)rep(j,x)c[i][j+1]=in();
		rep(i,x)if(c[0][i+1]==0)r[0][i+1]=1;
		repn(i,1,y-1)repn(j,1,x){
			if(c[i][j]==0){
				if(c[i-1][j-1]==0)r[i][j]+=r[i-1][j-1];
				if(c[i-1][j]==0)r[i][j]+=r[i-1][j];
				if(c[i-1][j+1]==0)r[i][j]+=r[i-1][j+1];
				if(i>1&&c[i-2][j]==2)r[i][j]+=r[i-2][j];
			}
			if(c[i][j]==2){
				if(c[i-1][j]==0)r[i][j]+=r[i-1][j];
				if(i>1&&c[i-2][j]==2)r[i][j]+=r[i-2][j];
			}
		}
		int result=0;
		repn(i,1,x)result+=r[y-1][i];
		repn(i,1,x)if(c[y-2][i]==2)result+=r[y-2][i];
//rep(i,y){
//rep(j,x)cout<<" "<<r[i][j+1];
//cout<<endl;
//}
		cout<<result<<endl;
	}
	return 0;
}

C++: #include <iostream>

int main()
{
    int x, y;
    int dx[3] = {-1, 0, 1};
    
    while (std::cin >> x >> y) {

        if (x == 0 && y == 0) break;

        int field[20][20] = {{0}}, dp[20][20] = {{0}};
        
        for (int i = 0; i < 20; ++i) {
            for (int j = 0; j < 20; ++j) {
                field[i][j] = 1;
            }
        }
        
        for (int i = 1; i <= y; ++i) {
            for (int j = 1; j <= x; ++j) {
                std::cin >> field[i][j];
            }
        }

        for (int i = 1; i <= x; ++i) {
            if (field[1][i] == 0) dp[1][i] = 1;
        }
        
        //calc
        int ans = 0;

        for (int i = 1; i <= y; ++i) {
            for (int j = 1; j <= x; ++j) {
                
                switch (field[i][j]) {
                    case 0:
                        for (int k = 0; k < 3; ++k) {
                            int px = j + dx[k], py = i + 1;
                            
                            if ((field[py][px] == 2 && k == 1) || field[py][px] == 0) {
                                dp[py][px] += dp[i][j];
                            }
                        }
                        break;
                    case 2:
                        //y-1
                        if (i == y -1) ans += dp[i][j];
                        if (dp[i + 2][j] != 1) dp[i + 2][j] += dp[i][j];
                        break;
                    default:
                        break;
                }
            }
        }

        for (int i = 1; i <= x; ++i) {
            ans += dp[y][i];
        }

        std::cout << ans << std::endl;
    }

    return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <iomanip>
using namespace std;
int main(){
	int x,y;
	while(1){
		cin >> x >> y;
		if(x+y==0) break;
		int a[x][y];
		for(int j=0;j<y;j++) for(int i=0;i<x;i++) cin >> a[i][j];
		long long d[x][y];
		for(int i=0;i<x;i++) d[i][0] = 1 - a[i][0];
		for(int j=1;j<y;j++){
			for(int i=0;i<x;i++){
				if(a[i][j]==1) d[i][j] = 0;
				else if(a[i][j]==0){
					if(a[i][j-1]!=2) d[i][j] = d[i][j-1];
					if(i>0 and a[i-1][j-1]!=2) d[i][j] += d[i-1][j-1];
					if(i<x-1 and a[i+1][j-1]!=2) d[i][j] += d[i+1][j-1];
					if(j>1 and a[i][j-2]==2) d[i][j] += d[i][j-2];
				}
				else{
					d[i][j] = d[i][j-1];
					if(j>1 and a[i][j-2]==2) d[i][j] += d[i][j-2];
				}
			}
		}
		long long s = 0;
		for(int i=0;i<x;i++){
			if(y>2 and a[i][y-2]==2) s += d[i][y-2];
			s += d[i][y-1];
		}
		cout << s << endl;
	}
}

C++: #include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	int x,y;
	int stage[17][17][2];

	while( cin >> x >> y && x != 0 && y != 0 ){
		for( int i = 0;i < 17;i++ ){
			for( int j = 0;j < 17;j++ ){
				stage[i][j][0] = stage[i][j][1] = 0;
			}
		}
		
		
		for( int i = 1;i <= y;i++ ){
			for( int j = 1;j <= x;j++ ){
				cin >> stage[j][i][0];
			}
		}

		for( int i = 0;i < 17;i++ ) if(stage[i][1][0] != 1 ) stage[i][1][1] = 1;

		for( int j = 1;j < y;j++ ){
			for( int i = 1;i <= x;i++ ){
				if( stage[i][j][0] == 1 ) continue;
				if( stage[i][j][0] == 0 ){
					if( stage[i][j + 1][0] != 1 ) stage[i][j + 1][1] += stage[i][j][1];
					
					if( stage[i + 1][j + 1][0] == 0 && ( i + 1 ) <= x ) stage[i + 1][j + 1][1] += stage[i][j][1];
					if( stage[i - 1][j + 1][0] == 0 && ( i - 1 ) >= 1 ) stage[i - 1][j + 1][1] += stage[i][j][1];

				}
				if( stage[i][j][0] == 2 ){
					stage[i][j + 2][1] += stage[i][j][1];
				}
			}
		}
		int count = 0;
		for( int i = 1;i <= x;i++ ){
			count += stage[i][y+1][1] + stage[i][y][1];
		}
		cout << count << endl;
	}
	return 0;
}